I build a webapp with multiple login form (1 for user, 1 for admin). I have a problem when session timeout, In case Im in admin dashboard page, if session timeout I want it go to admin login page. In case Im in user dashboard page, if session timeout, it will go to user login page.
but currently both of them go to user login page (not go to admin login page if the logged in user is admin)
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig {
@Configuration
@Order(2)
public static class ApartmentManagerSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()....and()
.sessionManagement().maximumSessions(1).and().invalidSessionUrl("/userLoginForm");
}
}
@Configuration
@Order(1)
public static class GovernmentStaffSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/gs/**").authorizeRequests()...
.and().sessionManagement().maximumSessions(1).and().invalidSessionUrl("/adminLoginForm");
}
}
}
Configuring the
invalidSessionUrl("/gs/adminLoginForm")should matchantMatcher("/gs/**")to get the admin login pageNote : I have not tried this out .