将 client_id 配置为密码授予类型的强制参数
Configure client_id as mandatory param for password grant type
使 client_id
成为 password
授权类型的强制参数的正确方法是什么?
使用此请求,我想将 client_id 设置为强制值,并让 OAuth2 框架将其与返回到方法 loadClientByClientId
中的结果进行比较
curl --location --request POST 'http://localhost:8080/engine/oauth/token' \
--header 'Authorization: Basic YWRtaW46cXdlcnR5' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=qwerty' \
--data-urlencode 'client_id=some_value' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'scope=read_profile'
实现这个的最佳方法是什么?
您可以尝试使用 docs
中的方法 validateScope(TokenRequest tokenRequest, ...)
实现自定义 OAuth2RequestValidator
Ensure that the client has requested a valid set of scopes.
可以访问 TokenRequest.getRequestParameters()
编辑
另请参阅 TokenEndpoint
的文档
Clients must be authenticated (...) to access this endpoint, and the client id is extracted from the authentication token. (...)
使 client_id
成为 password
授权类型的强制参数的正确方法是什么?
使用此请求,我想将 client_id 设置为强制值,并让 OAuth2 框架将其与返回到方法 loadClientByClientId
curl --location --request POST 'http://localhost:8080/engine/oauth/token' \
--header 'Authorization: Basic YWRtaW46cXdlcnR5' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin' \
--data-urlencode 'password=qwerty' \
--data-urlencode 'client_id=some_value' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'scope=read_profile'
实现这个的最佳方法是什么?
您可以尝试使用 docs
中的方法validateScope(TokenRequest tokenRequest, ...)
实现自定义 OAuth2RequestValidator
Ensure that the client has requested a valid set of scopes.
可以访问 TokenRequest.getRequestParameters()
编辑 另请参阅 TokenEndpoint
的文档Clients must be authenticated (...) to access this endpoint, and the client id is extracted from the authentication token. (...)