Advertisement
Guest User

Untitled

a guest
Apr 9th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. @Configuration
  2. @EnableWebSecurity
  3. public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
  4. private final UserServiceInterface userService;
  5.  
  6. @Autowired
  7. public SecurityConfiguration(UserServiceInterface userService) {
  8. this.userService = userService;
  9. }
  10.  
  11. @Autowired
  12. public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
  13. auth
  14. .userDetailsService(userService)
  15. .passwordEncoder(passwordEncoder());
  16. }
  17.  
  18. private PasswordEncoder passwordEncoder() {
  19. return new BCryptPasswordEncoder();
  20. }
  21. }
  22.  
  23. @Configuration
  24. @EnableAuthorizationServer
  25. class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
  26. private final AuthenticationManager authenticationManager;
  27.  
  28. @Autowired
  29. public AuthorizationServerConfiguration(AuthenticationManager authenticationManager) {
  30. this.authenticationManager = authenticationManager;
  31. }
  32.  
  33. @Override
  34. public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
  35. endpoints.authenticationManager(authenticationManager);
  36. }
  37.  
  38. @Override
  39. public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
  40. clients
  41. .inMemory()
  42. .withClient("html5")
  43. .secret("password")
  44. .authorizedGrantTypes("password")
  45. .scopes("openid");
  46. }
  47. }
  48.  
  49. curl html5:password@localhost:8080/oauth/token -d grant_type=password -d username=user -d password=pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement