Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- @EnableAuthorizationServer
- public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
- @Autowired
- private AuthenticationManager authenticationManager;
- @Autowired
- private UserService userDetailsService;
- @Autowired
- private PasswordEncoder passwordEncoder;
- @Autowired
- private DataSource dataSource;
- @Bean
- public TokenStore tokenStore() {
- return new JdbcTokenStore(dataSource);
- }
- @Bean
- public OAuth2AccessDeniedHandler oauthAccessDeniedHandler() {
- return new OAuth2AccessDeniedHandler();
- }
- @Override
- public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
- security.allowFormAuthenticationForClients().tokenKeyAccess("permitAll()").checkTokenAccess("isAuthenticated()").passwordEncoder(passwordEncoder);
- }
- @Override
- public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
- clients.withClientDetails(new JdbcClientDetailsService(dataSource));
- }
- @Override
- public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
- endpoints.tokenStore(tokenStore()).authenticationManager(authenticationManager).userDetailsService(userDetailsService);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement