diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/logout/OidcClientInitiatedLogoutSuccessHandler.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/logout/OidcClientInitiatedLogoutSuccessHandler.java index 23200be957..928ddd2da0 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/logout/OidcClientInitiatedLogoutSuccessHandler.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/logout/OidcClientInitiatedLogoutSuccessHandler.java @@ -137,18 +137,6 @@ public final class OidcClientInitiatedLogoutSuccessHandler extends SimpleUrlLogo // @formatter:on } - /** - * Set the post logout redirect uri to use - * @param postLogoutRedirectUri - A valid URL to which the OP should redirect after - * logging out the user - * @deprecated {@link #setPostLogoutRedirectUri(String)} - */ - @Deprecated - public void setPostLogoutRedirectUri(URI postLogoutRedirectUri) { - Assert.notNull(postLogoutRedirectUri, "postLogoutRedirectUri cannot be null"); - this.postLogoutRedirectUri = postLogoutRedirectUri.toASCIIString(); - } - /** * Set the post logout redirect uri template. * diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandler.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandler.java index e4c38b5401..3c48fd3ce8 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandler.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,18 +153,6 @@ public class OidcClientInitiatedServerLogoutSuccessHandler implements ServerLogo // @formatter:on } - /** - * Set the post logout redirect uri to use - * @param postLogoutRedirectUri - A valid URL to which the OP should redirect after - * logging out the user - * @deprecated {@link #setPostLogoutRedirectUri(String)} - */ - @Deprecated - public void setPostLogoutRedirectUri(URI postLogoutRedirectUri) { - Assert.notNull(postLogoutRedirectUri, "postLogoutRedirectUri cannot be empty"); - this.postLogoutRedirectUri = postLogoutRedirectUri.toASCIIString(); - } - /** * Set the post logout redirect uri template. * diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/logout/OidcClientInitiatedLogoutSuccessHandlerTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/logout/OidcClientInitiatedLogoutSuccessHandlerTests.java index 9a8e348ba6..196ec10bb3 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/logout/OidcClientInitiatedLogoutSuccessHandlerTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/logout/OidcClientInitiatedLogoutSuccessHandlerTests.java @@ -17,7 +17,6 @@ package org.springframework.security.oauth2.client.oidc.web.logout; import java.io.IOException; -import java.net.URI; import java.util.Collections; import jakarta.servlet.ServletException; @@ -111,17 +110,6 @@ public class OidcClientInitiatedLogoutSuccessHandlerTests { assertThat(this.response.getRedirectedUrl()).isEqualTo("https://default"); } - @Test - public void logoutWhenUsingPostLogoutRedirectUriThenIncludesItInRedirect() throws IOException, ServletException { - OAuth2AuthenticationToken token = new OAuth2AuthenticationToken(TestOidcUsers.create(), - AuthorityUtils.NO_AUTHORITIES, this.registration.getRegistrationId()); - this.handler.setPostLogoutRedirectUri(URI.create("https://postlogout?encodedparam=value")); - this.request.setUserPrincipal(token); - this.handler.onLogoutSuccess(this.request, this.response, token); - assertThat(this.response.getRedirectedUrl()).isEqualTo("https://endpoint?" + "id_token_hint=id-token&" - + "post_logout_redirect_uri=https://postlogout?encodedparam%3Dvalue"); - } - @Test public void logoutWhenUsingPostLogoutBaseUrlRedirectUriTemplateThenBuildsItForRedirect() throws IOException, ServletException { @@ -196,11 +184,6 @@ public class OidcClientInitiatedLogoutSuccessHandlerTests { + "post_logout_redirect_uri=https://rp.example.org/context?forwardUrl%3Dsecured%253Fparam%253Dtrue"); } - @Test - public void setPostLogoutRedirectUriWhenGivenNullThenThrowsException() { - assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setPostLogoutRedirectUri((URI) null)); - } - @Test public void setPostLogoutRedirectUriTemplateWhenGivenNullThenThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setPostLogoutRedirectUri((String) null)); diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandlerTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandlerTests.java index 86d02be698..300a815caf 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandlerTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/oidc/web/server/logout/OidcClientInitiatedServerLogoutSuccessHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,18 +122,6 @@ public class OidcClientInitiatedServerLogoutSuccessHandlerTests { assertThat(redirectedUrl(this.exchange)).isEqualTo("https://default"); } - @Test - public void logoutWhenUsingPostLogoutRedirectUriThenIncludesItInRedirect() { - OAuth2AuthenticationToken token = new OAuth2AuthenticationToken(TestOidcUsers.create(), - AuthorityUtils.NO_AUTHORITIES, this.registration.getRegistrationId()); - given(this.exchange.getPrincipal()).willReturn(Mono.just(token)); - WebFilterExchange f = new WebFilterExchange(this.exchange, this.chain); - this.handler.setPostLogoutRedirectUri(URI.create("https://postlogout?encodedparam=value")); - this.handler.onLogoutSuccess(f, token).block(); - assertThat(redirectedUrl(this.exchange)).isEqualTo("https://endpoint?" + "id_token_hint=id-token&" - + "post_logout_redirect_uri=https://postlogout?encodedparam%3Dvalue"); - } - @Test public void logoutWhenUsingPostLogoutBaseUrlRedirectUriTemplateThenBuildsItForRedirect() throws IOException, ServletException { @@ -206,11 +194,6 @@ public class OidcClientInitiatedServerLogoutSuccessHandlerTests { this.registration.getRegistrationId())); } - @Test - public void setPostLogoutRedirectUriWhenGivenNullThenThrowsException() { - assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setPostLogoutRedirectUri((URI) null)); - } - @Test public void setPostLogoutRedirectUriTemplateWhenGivenNullThenThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setPostLogoutRedirectUri((String) null));