Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- @EnableWebSecurity
- public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
- private final UserServiceInterface userService;
- @Autowired
- public SecurityConfiguration(UserServiceInterface userService) {
- this.userService = userService;
- }
- @Autowired
- public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
- auth
- .userDetailsService(userService)
- .passwordEncoder(passwordEncoder());
- }
- private PasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
- }
- @Configuration
- @EnableAuthorizationServer
- class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
- private final AuthenticationManager authenticationManager;
- @Autowired
- public AuthorizationServerConfiguration(AuthenticationManager authenticationManager) {
- this.authenticationManager = authenticationManager;
- }
- @Override
- public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
- endpoints.authenticationManager(authenticationManager);
- }
- @Override
- public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
- clients
- .inMemory()
- .withClient("html5")
- .secret("password")
- .authorizedGrantTypes("password")
- .scopes("openid");
- }
- }
- 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