Created
December 22, 2017 18:22
-
-
Save darbyluv2code/58471ed04bc5c65aa22054889b385a7b to your computer and use it in GitHub Desktop.
updates from Spring Security 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.luv2code.springsecurity.demo.config; | |
| import org.springframework.context.annotation.Configuration; | |
| import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | |
| import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | |
| import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |
| import org.springframework.security.core.userdetails.User; | |
| import org.springframework.security.core.userdetails.User.UserBuilder; | |
| @Configuration | |
| @EnableWebSecurity | |
| public class DemoSecurityConfig extends WebSecurityConfigurerAdapter { | |
| @Override | |
| protected void configure(AuthenticationManagerBuilder auth) throws Exception { | |
| UserBuilder users = User.withDefaultPasswordEncoder(); | |
| auth.inMemoryAuthentication() | |
| .withUser(users.username("john").password("test123").roles("EMPLOYEE")) | |
| .withUser(users.username("mary").password("test123").roles("MANAGER")) | |
| .withUser(users.username("susan").password("test123").roles("ADMIN")); | |
| } | |
| /* | |
| @Bean | |
| public static NoOpPasswordEncoder passwordEncoder() { | |
| return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance(); | |
| } | |
| */ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment