daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Jul 15th, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Configuration
  2. @EnableAuthorizationServer
  3. public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
  4.     @Autowired
  5.     private AuthenticationManager authenticationManager;
  6.  
  7.     @Autowired
  8.     private UserService userDetailsService;
  9.  
  10.     @Autowired
  11.     private PasswordEncoder passwordEncoder;
  12.  
  13.     @Autowired
  14.     private DataSource dataSource;
  15.  
  16.     @Bean
  17.     public TokenStore tokenStore() {
  18.         return new JdbcTokenStore(dataSource);
  19.     }
  20.  
  21.     @Bean
  22.     public OAuth2AccessDeniedHandler oauthAccessDeniedHandler() {
  23.         return new OAuth2AccessDeniedHandler();
  24.     }
  25.  
  26.     @Override
  27.     public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
  28.         security.allowFormAuthenticationForClients().tokenKeyAccess("permitAll()").checkTokenAccess("isAuthenticated()").passwordEncoder(passwordEncoder);
  29.     }
  30.  
  31.     @Override
  32.     public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
  33.         clients.withClientDetails(new JdbcClientDetailsService(dataSource));
  34.     }
  35.  
  36.     @Override
  37.     public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
  38.         endpoints.tokenStore(tokenStore()).authenticationManager(authenticationManager).userDetailsService(userDetailsService);
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top