- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我找到了有关 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 中注销并尝试再次登录时,用户必须再次输入用户名和密码,因为服务器中的身份验证已过期。
抱歉我的英语不好,提前致谢!
最佳答案
如果您阅读博客 https://spring.io/blog/2015/02/03/sso-with-oauth2-angular-js-and-spring-security-part-v这实际上解释了实现与您正在做的相同类型的安全性的方式(实际上,您只是实现了几乎相同的东西的 jwt 版本。如果您想要博客的实际代码,请使用相同 repo 的 oauth2-vanilla 版本)...到最后,明确指出“这是一个众所周知的棘手问题”(如博客中所写)。同一系列博客实际上有一个新版本可以解决您的问题 https://github.com/dsyer/spring-security-angular/tree/master/double .在此您可以看到如何在 spring-session 和实际存储您的 session 的 redis 服务器的帮助下实现注销。一切顺利!如有任何疑问,请随时联系
关于java - 如何从 Oauth2 SSO 服务器注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29959255/
我是一名优秀的程序员,十分优秀!