Search in sources :

Example 1 with OidcClientInitiatedLogoutSuccessHandler

use of org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler in project urlaubsverwaltung by synyx.

the class OidcSecurityConfiguration method oidcClientInitiatedLogoutSuccessHandler.

@Bean
OidcClientInitiatedLogoutSuccessHandler oidcClientInitiatedLogoutSuccessHandler(ClientRegistrationRepository clientRegistrationRepository) {
    OidcClientInitiatedLogoutSuccessHandler oidcClientInitiatedLogoutSuccessHandler = new OidcClientInitiatedLogoutSuccessHandler(clientRegistrationRepository);
    oidcClientInitiatedLogoutSuccessHandler.setPostLogoutRedirectUri("{baseUrl}");
    return oidcClientInitiatedLogoutSuccessHandler;
}
Also used : OidcClientInitiatedLogoutSuccessHandler(org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler) Bean(org.springframework.context.annotation.Bean)

Example 2 with OidcClientInitiatedLogoutSuccessHandler

use of org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler in project okta-spring-boot by okta.

the class OktaOAuth2AutoConfig method oidcLogoutSuccessHandler.

@Bean
@ConditionalOnProperty(name = "okta.oauth2.post-logout-redirect-uri")
OidcClientInitiatedLogoutSuccessHandler oidcLogoutSuccessHandler(OktaOAuth2Properties oktaOAuth2Properties, ClientRegistrationRepository clientRegistrationRepository) {
    OidcClientInitiatedLogoutSuccessHandler successHandler = new OidcClientInitiatedLogoutSuccessHandler(clientRegistrationRepository);
    String logoutUri = oktaOAuth2Properties.getPostLogoutRedirectUri();
    successHandler.setPostLogoutRedirectUri((logoutUri.startsWith("/") ? "{baseUrl}" : "") + logoutUri);
    return successHandler;
}
Also used : OidcClientInitiatedLogoutSuccessHandler(org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 3 with OidcClientInitiatedLogoutSuccessHandler

use of org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler in project appsso-starter-java by sample-accelerators.

the class WebSecurityConfig method oidcLogoutSuccessHandler.

// see: https://docs.spring.io/spring-security/reference/servlet/oauth2/login/advanced.html#oauth2login-advanced-oidc-logout
private LogoutSuccessHandler oidcLogoutSuccessHandler() {
    OidcClientInitiatedLogoutSuccessHandler oidcLogoutSuccessHandler = new OidcClientInitiatedLogoutSuccessHandler(this.clientRegistrationRepository);
    // Sets the location that the End-User's User Agent will be redirected to
    // after the logout has been performed at the Provider
    oidcLogoutSuccessHandler.setPostLogoutRedirectUri("{baseUrl}");
    return oidcLogoutSuccessHandler;
}
Also used : OidcClientInitiatedLogoutSuccessHandler(org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler)

Example 4 with OidcClientInitiatedLogoutSuccessHandler

use of org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler in project dhis2-core by dhis2.

the class DhisOidcLogoutSuccessHandler method init.

@PostConstruct
public void init() {
    String logoutUri = dhisConfigurationProvider.getProperty(OIDC_LOGOUT_REDIRECT_URL);
    this.handler = new OidcClientInitiatedLogoutSuccessHandler(dhisOidcProviderRepository);
    this.handler.setPostLogoutRedirectUri(logoutUri);
}
Also used : OidcClientInitiatedLogoutSuccessHandler(org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler) PostConstruct(javax.annotation.PostConstruct)

Example 5 with OidcClientInitiatedLogoutSuccessHandler

use of org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler in project spring-security by spring-projects.

the class OidcClientInitiatedLogoutSuccessHandlerTests method logoutWhenClientRegistrationHasNoEndSessionEndpointThenDefaults.

@Test
public void logoutWhenClientRegistrationHasNoEndSessionEndpointThenDefaults() throws Exception {
    ClientRegistration registration = TestClientRegistrations.clientRegistration().build();
    ClientRegistrationRepository repository = new InMemoryClientRegistrationRepository(registration);
    OidcClientInitiatedLogoutSuccessHandler handler = new OidcClientInitiatedLogoutSuccessHandler(repository);
    OAuth2AuthenticationToken token = new OAuth2AuthenticationToken(TestOidcUsers.create(), AuthorityUtils.NO_AUTHORITIES, registration.getRegistrationId());
    this.request.setUserPrincipal(token);
    handler.setDefaultTargetUrl("https://default");
    handler.onLogoutSuccess(this.request, this.response, token);
    assertThat(this.response.getRedirectedUrl()).isEqualTo("https://default");
}
Also used : ClientRegistration(org.springframework.security.oauth2.client.registration.ClientRegistration) OAuth2AuthenticationToken(org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken) InMemoryClientRegistrationRepository(org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository) ClientRegistrationRepository(org.springframework.security.oauth2.client.registration.ClientRegistrationRepository) InMemoryClientRegistrationRepository(org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository) Test(org.junit.jupiter.api.Test)

Aggregations

OidcClientInitiatedLogoutSuccessHandler (org.springframework.security.oauth2.client.oidc.web.logout.OidcClientInitiatedLogoutSuccessHandler)4 Bean (org.springframework.context.annotation.Bean)2 PostConstruct (javax.annotation.PostConstruct)1 Test (org.junit.jupiter.api.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)1 OAuth2AuthenticationToken (org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken)1 ClientRegistration (org.springframework.security.oauth2.client.registration.ClientRegistration)1 ClientRegistrationRepository (org.springframework.security.oauth2.client.registration.ClientRegistrationRepository)1 InMemoryClientRegistrationRepository (org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository)1