Hi,
I try to use Resource Owner Password Credentials grant type with Spring Security OAuth 2 provider (1.0.0.BUILD-20120718.114859-150).
My security config looks like
When I'm trying to get access_token with following Groovy codeCode:<security:http pattern="/oauth/token" create-session="stateless" entry-point-ref="oauth2AuthenticationEntryPoint" authentication-manager-ref="webClientAuthenticationManager"> <security:anonymous enabled="false" /> <security:http-basic /> <security:access-denied-handler ref="oauth2AccessDeniedHandler" /> </security:http> <oauth2:authorization-server client-details-service-ref="commonClientDetailsService" token-services-ref="tokenServices" user-approval-handler-ref="userApprovalHandler" token-endpoint-url="/oauth/token" authorization-endpoint-url="/oauth/authorize"> <oauth2:authorization-code /> <oauth2:implicit /> <oauth2:refresh-token /> <oauth2:client-credentials /> <oauth2:password /> </oauth2:authorization-server>
ResourceOwnerPasswordTokenGranter.getResourceOwner PasswordTokenGranter method throws exception and client gets 500 http status code.Code:def resourceOwnerAuth = Base64.byteArrayToBase64("$login:$password".getBytes("UTF-8")) println "Get access token for user $login" http.request(POST, JSON) {req -> uri.path = "/api/v0.1/oauth/token" uri.query = [grant_type: "password"] headers.'Authorization' = "Basic $resourceOwnerAuth" headers.'Content-Type' = "application/x-www-form-urlencoded;charset=UTF-8" response.success = { resp, json -> assert resp.statusLine.statusCode == 200 println "access_token: ${json.access_token}" println "token_type: ${json.token_type}" } }
I've noticed that username and passwoed are nulls after execution
in ResourceOwnerPasswordTokenGranter.getResourceOwner PasswordTokenGranter and as result inapropriate UsernamePasswordAuthenticationToken is passed to AuthenticationManager.Code:Map<String, String> parameters = clientToken.getAuthorizationParameters(); String username = parameters.get("username"); String password = parameters.get("password");
Is Spring Security OAuth 2 supporting Resource Owner Password Credentials grant type?
If so, does it need some tricky configuration?
Thank you,
Vitaly Kotlyarenko


Reply With Quote
