我的配置是
@Configuration
@EnableWebSecurity(debug = false)
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SaveNewOidcUserService saveNewOidcUserService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.logout()
.clearAuthentication(true)
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID")
.logoutUrl("/logout")
.logoutSuccessUrl("/")
.permitAll()
.and()
.oauth2Login()
.userInfoEndpoint()
.oidcUserService(saveNewOidcUserService);
}
}
版本是:
spring-security-oauth2-client 5.3.2.RELEASE
spring-boot-starter-security 2.3.0.RELEASE
我通过谷歌登录到我的应用程序,并在注销我的应用程序,我看到在firefox控制台日志,有GET到登录页面,所以如果我仍然登录谷歌,我的安全应用程序的内容显示(因为自动登录),但应要求通过谷歌登录与屏幕选择帐户等。如果我注销了google就可以正常使用。
如何强制注销后不自动登录?
在添加了以下内容后,我解决了这个问题
.exceptionHandling()
.defaultAuthenticationEntryPointFor(
customAuthEP(),
new AntPathRequestMatcher("/**")
)