2016-05-05 3 views
0

У меня проблема с конфигурацией Spring Security.Spring Security - несколько зарегистрированных пользователей

Когда я вхожу в систему на одном компьютере в качестве пользователя1, а затем я буду регистрироваться как пользователь2 на другом компьютере, первый компьютер после обновления видит все как пользователь2.

Другими словами, одновременное использование двух сеансов с разными пользователями невозможно.

Конфигурация:

@Configuration 
@EnableWebSecurity 
public class SecurityConfiguration extends WebSecurityConfigurerAdapter { 

    @Autowired 
    public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception { 
     auth.inMemoryAuthentication().withUser("user1").password("user1").roles("USER"); 
     auth.inMemoryAuthentication().withUser("user2").password("user2").roles("USER"); 
    } 

    @Override 
    protected void configure(HttpSecurity http) throws Exception { 
     CharacterEncodingFilter filter = new CharacterEncodingFilter(); 
     filter.setEncoding("UTF-8"); 
     filter.setForceEncoding(true); 
     http.addFilterBefore(filter,CsrfFilter.class); 

     http.csrf().disable(); 

     http.authorizeRequests() 
       .antMatchers("/", "/login").permitAll() 
       .antMatchers("https://stackoverflow.com/questions/**").access("hasRole('USER')") 
       .and().formLogin().loginPage("/login").defaultSuccessUrl("/questions") 
       .usernameParameter("ssoId").passwordParameter("password"); 
    } 

Spring Security Версия: 4.0.1.RELEASE

Весна версия: 4.1.6.RELEASE

Логин запрос в контроллере:

@RequestMapping(value = { "/", "/login" }, method = RequestMethod.GET) 
public String homePage() { 
    return "login"; 
} 

ответ

0

@Autowired p public void configureGlobalSecurity (AuthenticationManagerBuilder auth) выбрасывает исключение { auth.inMemoryAuthentication(). withUser ("user1"). password ("user1"). role ("USER"); auth.inMemoryAuthentication(). WithUser ("user2"). Password ("user2"). Role ("USER"); }

При том, что вы говорите, что пользователь 2 на сессии

@Autowired общественного недействительными configureGlobalSecurity (AuthenticationManagerBuilder авторизация) бросает исключение { auth.inMemoryAuthentication(). WithUser (GetUser()) .password (GetPassword()) роли ("USER"). }