【发布时间】:2015-07-09 15:43:28
【问题描述】:
我找到了关于 SSO https://github.com/dsyer/spring-security-angular/tree/master/oauth2 配置的教程
oauth2-authserver
@Configuration
@Order(-10)
protected static class LoginConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationManager authenticationManager;
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.formLogin().loginPage("/login").permitAll()
.and()
.requestMatchers().antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access")
.and()
.authorizeRequests().anyRequest().authenticated()
.and().sessionManagement();
// @formatter:on
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.parentAuthenticationManager(authenticationManager);
}
}
oauth2-ui
@Override
public void configure(HttpSecurity http) throws Exception {
http.logout().and().antMatcher("/**").authorizeRequests()
.antMatchers("/index.html", "/home.html", "/", "/login").permitAll()
.anyRequest().authenticated().and().csrf()
.csrfTokenRepository(csrfTokenRepository()).and()
.addFilterAfter(csrfHeaderFilter(), CsrfFilter.class);
}
我的 authserver 只需要一次登录验证,所以当用户已经通过身份验证并重定向到 oauth2-ui 应用程序时,服务器中的身份验证登录已过期。 所以当 oauth2-ui 中的用户注销并再次尝试登录时,用户必须再次输入用户名和密码,因为服务器中的身份验证已过期。
对不起,我的英语不好,提前谢谢!
【问题讨论】:
标签: java single-sign-on spring-security-oauth2 spring-cloud