Guest User

Untitled

a guest
Feb 14th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. curl -u clientid:clientsecret http://myhost ... -d "grant_type=password&username=user&password=pw&client_id=OAUTH_CLIENT"
  2.  
  3. curl http://myhost ... -d "grant_type=password&username=user&password=pw&client_id=OAUTH_CLIENT"
  4.  
  5. curl http://myhost ... -d "grant_type=password&username=user&password=pw&client_id=OAUTH_CLIENT&client_secret=SECRET"
  6.  
  7. @Configuration
  8. @EnableAuthorizationServer
  9. class OAuth2Config extends AuthorizationServerConfigurerAdapter {
  10.  
  11. private final AuthenticationManager authenticationManager;
  12.  
  13. public OAuth2Config(AuthenticationManager authenticationManager) {
  14. this.authenticationManager = authenticationManager;
  15. }
  16.  
  17. @Override
  18. public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
  19. endpoints.authenticationManager(this.authenticationManager);
  20. }
  21.  
  22. @Override
  23. public void configure(AuthorizationServerSecurityConfigurer oauth) throws Exception {
  24. // allows access of /auth/token endpoint without HTTP Basic authentication
  25. oauth.allowFormAuthenticationForClients();
  26. }
  27.  
  28. @Override
  29. public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
  30. clients
  31. .inMemory()
  32. .withClient("acme")
  33. .autoApprove(true) // <- allows for client id only
  34. .authorizedGrantTypes("authorization_code", "refresh_token", "password").scopes("openid");
  35. }
  36.  
  37. }
Add Comment
Please, Sign In to add comment