我有一个与 OKTA 集成的 spring 安全应用程序。应用程序登录由 OKTA 完成。作为 OKTA 用户,我有 OKTA Hub 和 OKTA 发言。要注销应用程序,我需要调用两个 url,一个是 Hub,另一个是 Spoke。 OKTA 发言 URL 是 https://abc-apps-dev.defghi.jkl/login/signout?fromURI=http://localhost:9080 和 OKTA hub https://apps-dev.abcdef.gov/login /signout?fromURI=http://localhost:9080 URL 是。我正在使用 spring security 来注销。
我的spring Security注销密码是
@Configuration
static class WebConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
// allow antonymous access to the root page
.antMatchers("/").permitAll()
// all other requests
.anyRequest().authenticated()
// set logout URL
.and()
.logout()
.logoutSuccessHandler(new LogoutSuccessHandler() {
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
String url = "https://abc-apps-dev.defghi.jkl/login/signout?fromURI=http://localhost:9080";
response.sendRedirect(url);
}
})
.logoutSuccessUrl("/")
// enable OAuth2/OIDC
.and().oauth2Client()
.and().oauth2Login();
}
}
LogoutSuccessHandler 方法我可以调用一个 URL,如何在第一个 URL 之后调用第二个 URL。
我尝试使用
` @Configuration
static class WebConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
// allow antonymous access to the root page
.antMatchers("/").permitAll()
// all other requests
.anyRequest().authenticated()
// set logout URL
.and()
.logout()
.logoutUrl("URL-1")
.logoutUrl("URL-2")
.logoutSuccessUrl("/")
// enable OAuth2/OIDC
.and().oauth2Client()
.and().oauth2Login();
}
}`