11package org .springframework .webflow .samples .booking .config ;
22
3+ import org .springframework .context .annotation .Bean ;
34import org .springframework .context .annotation .Configuration ;
4- import org .springframework .security .config .annotation .authentication .builders .AuthenticationManagerBuilder ;
55import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
66import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
7- import org .springframework .security .config .annotation .web .configuration .WebSecurityConfigurerAdapter ;
7+ import org .springframework .security .core .userdetails .User ;
8+ import org .springframework .security .provisioning .InMemoryUserDetailsManager ;
9+ import org .springframework .security .web .SecurityFilterChain ;
810import org .springframework .security .web .util .matcher .AntPathRequestMatcher ;
911
1012@ Configuration
1113@ EnableWebSecurity
12- public class SecurityConfig extends WebSecurityConfigurerAdapter {
14+ public class SecurityConfig {
1315
14- @ Override
15- protected void configure (HttpSecurity http ) throws Exception {
16+ @ Bean
17+ public SecurityFilterChain filterChain (HttpSecurity http ) throws Exception {
1618 http
1719 .formLogin ()
1820 .loginPage ("/login" )
@@ -23,15 +25,16 @@ protected void configure(HttpSecurity http) throws Exception {
2325 .logout ()
2426 .logoutRequestMatcher (new AntPathRequestMatcher ("/logout" , "GET" ))
2527 .logoutSuccessUrl ("/logoutSuccess" );
28+ return http .build ();
2629 }
2730
28- @ Override
29- protected void configure ( AuthenticationManagerBuilder auth ) throws Exception {
30- auth . inMemoryAuthentication ()
31- . withUser ("keith" ).password ("{MD5}417c7382b16c395bc25b5da1398cf076" ).roles ("USER" , "SUPERVISOR" ).and ()
32- . withUser ("erwin" ).password ("{MD5}12430911a8af075c6f41c6976af22b09" ).roles ("USER" , "SUPERVISOR" ).and ()
33- . withUser ("jeremy" ).password ("{MD5}57c6cbff0d421449be820763f03139eb" ).roles ("USER" ).and ()
34- . withUser ("scott" ).password ("{MD5}942f2339bf50796de535a384f0d1af3e" ).roles ("USER" );
31+ @ Bean
32+ public InMemoryUserDetailsManager userDetailsService () {
33+ return new InMemoryUserDetailsManager (
34+ User . withUsername ("keith" ).password ("{MD5}417c7382b16c395bc25b5da1398cf076" ).roles ("USER" , "SUPERVISOR" ).build (),
35+ User . withUsername ("erwin" ).password ("{MD5}12430911a8af075c6f41c6976af22b09" ).roles ("USER" , "SUPERVISOR" ).build (),
36+ User . withUsername ("jeremy" ).password ("{MD5}57c6cbff0d421449be820763f03139eb" ).roles ("USER" ).build (),
37+ User . withUsername ("scott" ).password ("{MD5}942f2339bf50796de535a384f0d1af3e" ).roles ("USER" ). build () );
3538 }
3639
3740}
0 commit comments