Skip to content

Commit aa31351

Browse files
committed
Polish Documentation
Closes gh-14635
1 parent 3ddf201 commit aa31351

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed

config/src/test/java/org/springframework/security/config/http/Saml2LogoutBeanDefinitionParserTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ public void saml2LogoutRequestWhenNoRegistrationThen400() throws Exception {
287287
.andExpect(status().isBadRequest());
288288
}
289289

290+
// gh-14635
290291
@Test
291292
public void saml2LogoutRequestWhenInvalidSamlRequestThen302Redirect() throws Exception {
292293
this.spring.configLocations(this.xml("Default")).autowire();

docs/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* xref:migration/index.adoc[Migrating to 7]
77
** xref:migration/servlet/index.adoc[Servlet]
88
*** xref:migration/servlet/oauth2.adoc[OAuth 2.0]
9+
*** xref:migration/servlet/saml2.adoc[SAML 2.0]
910
** xref:migration/reactive.adoc[Reactive]
1011
* xref:getting-spring-security.adoc[Getting Spring Security]
1112
* xref:attachment$api/java/index.html[Javadoc]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
= SAML 2.0 Migrations
2+
3+
== Expect `<saml2:LogoutResponse>` When `<saml2:LogoutRequest>` Validation Fails
4+
5+
SAML identity providers expect service providers to return an error `<saml2:LogoutResponse>` if it fails to process the `<saml2:LogoutRequest>`.
6+
7+
Past versions of Spring Security returned a 401 in some cases, breaking the chain of logout requests and responses from each relying party.
8+
9+
In Spring Security 7, this behavior is repaired, and you need do nothing.
10+
11+
However, if this gives you trouble, you can revert back to the old behavior by publishing a `Saml2LogoutRequestResolver` that returns `null` when an error `<saml2:LogoutRequest>` is needed.
12+
You can create a delegate like this one:
13+
14+
[tabs]
15+
======
16+
Java::
17+
+
18+
[source,java,role="primary"]
19+
----
20+
@Bean
21+
Saml2LogoutResponseResolver logoutResponseResolver(RelyingPartyRegistrationRepository registrations) {
22+
OpenSaml5LogoutResponseResolver delegate = new OpenSaml5LogoutResponseResolver(registrations);
23+
return new Saml2LogoutResponseResolver() {
24+
@Override
25+
public void resolve(HttpServletRequest request, Authentication authentication) {
26+
delegate.resolve(request, authentication);
27+
}
28+
29+
@Override
30+
public void resolve(HttpServletRequest request, Authentication authentication, Saml2AuthenticationException error) {
31+
return null;
32+
}
33+
};
34+
}
35+
----
36+
37+
Kotlin::
38+
+
39+
[source,kotlin,role="secondary"]
40+
----
41+
@Bean
42+
fun logoutResponseResolver(registrations: RelyingPartyRegistrationRepository?): Saml2LogoutResponseResolver {
43+
val delegate = OpenSaml5LogoutResponseResolver(registrations)
44+
return object : Saml2LogoutResponseResolver() {
45+
override fun resolve(request: HttpServletRequest?, authentication: Authentication?) {
46+
delegate.resolve(request, authentication)
47+
}
48+
49+
override fun resolve(request: HttpServletRequest?, authentication: Authentication?, error: Saml2AuthenticationException?) {
50+
return null
51+
}
52+
}
53+
}
54+
----
55+
======
56+

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/web/authentication/logout/Saml2LogoutResponseResolver.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public interface Saml2LogoutResponseResolver {
5151
* @param authentication the current user
5252
* @param authenticationException the thrown exception when the logout request was
5353
* processed
54-
* @return a signed and serialized SAML 2.0 Logout Response
54+
* @return a signed and serialized SAML 2.0 Logout Response, or {@code null} if it
55+
* cannot generate a SAML 2.0 Error Logout Response
56+
* @since 7.0
5557
*/
5658
default Saml2LogoutResponse resolve(HttpServletRequest request, Authentication authentication,
5759
Saml2AuthenticationException authenticationException) {

saml2/saml2-service-provider/src/opensaml4Test/java/org/springframework/security/saml2/provider/service/web/authentication/logout/OpenSaml4LogoutResponseResolverTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void resolveWhenCustomParametersConsumerThenUses() {
6565
logoutResponseResolver.setParametersConsumer(parametersConsumer);
6666
MockHttpServletRequest request = new MockHttpServletRequest();
6767
RelyingPartyRegistration registration = TestRelyingPartyRegistrations.relyingPartyRegistration()
68-
.assertingPartyMetadata(
68+
.assertingPartyDetails(
6969
(party) -> party.singleLogoutServiceResponseLocation("https://ap.example.com/logout"))
7070
.build();
7171
Authentication authentication = new TestingAuthenticationToken("user", "password");

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/web/authentication/logout/Saml2LogoutRequestFilterTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void doFilterWhenSamlRequestThenRedirects() throws Exception {
9999
@Test
100100
public void doFilterWhenSamlRequestThenPosts() throws Exception {
101101
RelyingPartyRegistration registration = TestRelyingPartyRegistrations.full()
102-
.assertingPartyMetadata((party) -> party.singleLogoutServiceBinding(Saml2MessageBinding.POST))
102+
.assertingPartyDetails((party) -> party.singleLogoutServiceBinding(Saml2MessageBinding.POST))
103103
.build();
104104
Authentication authentication = new TestingAuthenticationToken("user", "password");
105105
given(this.securityContextHolderStrategy.getContext()).willReturn(new SecurityContextImpl(authentication));

0 commit comments

Comments
 (0)