Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl -u clientid:clientsecret http://myhost ... -d "grant_type=password&username=user&password=pw&client_id=OAUTH_CLIENT"
- curl http://myhost ... -d "grant_type=password&username=user&password=pw&client_id=OAUTH_CLIENT"
- curl http://myhost ... -d "grant_type=password&username=user&password=pw&client_id=OAUTH_CLIENT&client_secret=SECRET"
- @Configuration
- @EnableAuthorizationServer
- class OAuth2Config extends AuthorizationServerConfigurerAdapter {
- private final AuthenticationManager authenticationManager;
- public OAuth2Config(AuthenticationManager authenticationManager) {
- this.authenticationManager = authenticationManager;
- }
- @Override
- public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
- endpoints.authenticationManager(this.authenticationManager);
- }
- @Override
- public void configure(AuthorizationServerSecurityConfigurer oauth) throws Exception {
- // allows access of /auth/token endpoint without HTTP Basic authentication
- oauth.allowFormAuthenticationForClients();
- }
- @Override
- public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
- clients
- .inMemory()
- .withClient("acme")
- .autoApprove(true) // <- allows for client id only
- .authorizedGrantTypes("authorization_code", "refresh_token", "password").scopes("openid");
- }
- }
Add Comment
Please, Sign In to add comment