You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/migration/servlet/oauth2.adoc
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ fun jwtDecoder(): JwtDecoder {
83
83
84
84
Spring Security does not support processing `<saml2:Response>` payloads over GET as this is not supported by the SAML 2.0 spec.
85
85
86
-
To better comply with this, `Saml2AuthenticationTokenConverter`, `OpenSaml4AuthenticationTokenConverter`, and `OpenSaml5AuthenticationTokenConverter` will not process GET requests by default as of Spring Security 8.
86
+
To better comply with this, `Saml2AuthenticationTokenConverter` and `OpenSaml5AuthenticationTokenConverter` will not process GET requests by default as of Spring Security 8.
87
87
To prepare for this, the property `shouldConvertGetRequests` is available.
88
88
To use it, publish your own converter like so:
89
89
@@ -114,7 +114,7 @@ fun authenticationConverter(val registrations: RelyingPartyRegistrationRepositor
114
114
----
115
115
======
116
116
117
-
If you must continue using `Saml2AuthenticationTokenConverter`, `OpenSaml4AuthenticationTokenConverter`, or `OpenSaml5AuthenticationTokenConverter` to process GET requests, you can call `setShouldConvertGetRequests` to `true.`
117
+
If you must continue using `Saml2AuthenticationTokenConverter` or `OpenSaml5AuthenticationTokenConverter` to process GET requests, you can call `setShouldConvertGetRequests` to `true.`
118
118
119
119
== Provide an AuthenticationConverter to BearerTokenAuthenticationFilter
To verify SAML 2.0 Responses, Spring Security uses xref:servlet/saml2/login/overview.adoc#servlet-saml2login-authentication-saml2authenticationtokenconverter[`Saml2AuthenticationTokenConverter`] to populate the `Authentication` request and xref:servlet/saml2/login/overview.adoc#servlet-saml2login-architecture[`OpenSaml4AuthenticationProvider`] to authenticate it.
4
+
To verify SAML 2.0 Responses, Spring Security uses xref:servlet/saml2/login/overview.adoc#servlet-saml2login-authentication-saml2authenticationtokenconverter[`Saml2AuthenticationTokenConverter`] to populate the `Authentication` request and xref:servlet/saml2/login/overview.adoc#servlet-saml2login-architecture[`OpenSaml5AuthenticationProvider`] to authenticate it.
5
5
6
6
You can configure this in a number of ways including:
7
7
@@ -123,76 +123,7 @@ fun securityFilters(val http: HttpSecurity, val converter: AuthenticationConvert
123
123
== Setting a Clock Skew
124
124
125
125
It's not uncommon for the asserting and relying parties to have system clocks that aren't perfectly synchronized.
126
-
For that reason, you can configure ``OpenSaml4AuthenticationProvider``'s default assertion validator with some tolerance:
127
-
128
-
[tabs]
129
-
======
130
-
Java::
131
-
+
132
-
[source,java,role="primary"]
133
-
----
134
-
@Configuration
135
-
@EnableWebSecurity
136
-
public class SecurityConfig {
137
-
138
-
@Bean
139
-
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
140
-
OpenSaml4AuthenticationProvider authenticationProvider = new OpenSaml4AuthenticationProvider();
If you are using xref:servlet/saml2/opensaml.adoc[OpenSAML 5], then we have a simpler way, using `OpenSaml5AuthenticationProvider.AssertionValidator`:
126
+
For that reason, you can configure `OpenSaml5AuthenticationProvider.AssertionValidator` as follows:
196
127
197
128
[tabs]
198
129
======
@@ -381,86 +312,8 @@ open class MyUserDetailsResponseAuthenticationConverter(val delegate: ResponseAu
381
312
If your `UserDetailsService` returns a value that also implements `AuthenticatedPrincipal`, then you don't need a custom authentication implementation.
382
313
====
383
314
384
-
Or, if you are using OpenSaml 4, then you can achieve something similar as follows:
385
-
386
-
[tabs]
387
-
======
388
-
Java::
389
-
+
390
-
[source,java,role="primary"]
391
-
----
392
-
@Configuration
393
-
@EnableWebSecurity
394
-
public class SecurityConfig {
395
-
@Autowired
396
-
UserDetailsService userDetailsService;
397
-
398
-
@Bean
399
-
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
400
-
OpenSaml4AuthenticationProvider authenticationProvider = new OpenSaml4AuthenticationProvider();
<1> First, call the default converter, which extracts attributes and authorities from the response
459
-
<2> Second, call the xref:servlet/authentication/passwords/user-details-service.adoc#servlet-authentication-userdetailsservice[`UserDetailsService`] using the relevant information
460
-
<3> Third, return a custom authentication that includes the user details
461
-
462
315
[NOTE]
463
-
It's not required to call ``OpenSaml4AuthenticationProvider``'s default authentication converter.
316
+
It's not required to call ``OpenSaml5AuthenticationProvider``'s default authentication converter.
464
317
It returns a `Saml2AuthenticatedPrincipal` containing the attributes it extracted from ``AttributeStatement``s as well as the single `ROLE_USER` authority.
465
318
466
319
=== Configuring the Principal Name
@@ -538,28 +391,10 @@ fun authenticationConverter(): ResponseAuthenticationConverter {
`OpenSaml4AuthenticationProvider` validates the `Issuer` and `Destination` values right after decrypting the `Response`.
394
+
`OpenSaml5AuthenticationProvider` validates the `Issuer` and `Destination` values right after decrypting the `Response`.
542
395
You can customize the validation by extending the default validator concatenating with your own response validator, or you can replace it entirely with yours.
543
396
544
397
For example, you can throw a custom exception with any additional information available in the `Response` object, like so:
545
-
[source,java]
546
-
----
547
-
OpenSaml4AuthenticationProvider provider = new OpenSaml4AuthenticationProvider();
throw new CustomSaml2AuthenticationException(result, inResponseTo);
556
-
}
557
-
return result;
558
-
});
559
-
----
560
-
561
-
When using `OpenSaml5AuthenticationProvider`, you can do the same with less boilerplate:
562
-
563
398
[source,java]
564
399
----
565
400
OpenSaml5AuthenticationProvider provider = new OpenSaml5AuthenticationProvider();
@@ -583,74 +418,17 @@ OpenSAML performs `Asssertion#InResponseTo` validation in its `BearerSubjectConf
583
418
====
584
419
585
420
== Performing Additional Assertion Validation
586
-
`OpenSaml4AuthenticationProvider` performs minimal validation on SAML 2.0 Assertions.
421
+
`OpenSaml5AuthenticationProvider` performs minimal validation on SAML 2.0 Assertions.
587
422
After verifying the signature, it will:
588
423
589
424
1. Validate `<AudienceRestriction>` and `<DelegationRestriction>` conditions
590
425
2. Validate ``<SubjectConfirmation>``s, expect for any IP address information
591
426
592
-
To perform additional validation, you can configure your own assertion validator that delegates to ``OpenSaml4AuthenticationProvider``'s default and then performs its own.
427
+
To perform additional validation, you can configure your own assertion validator that delegates to ``OpenSaml5AuthenticationProvider``'s default and then performs its own.
While recommended, it's not necessary to call ``OpenSaml4AuthenticationProvider``'s default assertion validator.
650
-
A circumstance where you would skip it would be if you don't need it to check the `<AudienceRestriction>` or the `<SubjectConfirmation>` since you are doing those yourself.
651
-
652
-
If you are using xref:servlet/saml2/opensaml.adoc[OpenSAML 5], then we have a simpler way using `OpenSaml5AuthenticationProvider.AssertionValidator`:
Spring Security decrypts `<saml2:EncryptedAssertion>`, `<saml2:EncryptedAttribute>`, and `<saml2:EncryptedID>` elements automatically by using the decryption xref:servlet/saml2/login/overview.adoc#servlet-saml2login-rpr-credentials[`Saml2X509Credential` instances] registered in the xref:servlet/saml2/login/overview.adoc#servlet-saml2login-relyingpartyregistration[`RelyingPartyRegistration`].
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/servlet/saml2/login/overview.adoc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ This filter calls its configured `AuthenticationConverter` to create a `Saml2Aut
49
49
This converter additionally resolves the <<servlet-saml2login-relyingpartyregistration, `RelyingPartyRegistration`>> and supplies it to `Saml2AuthenticationToken`.
50
50
51
51
image:{icondir}/number_2.png[] Next, the filter passes the token to its configured xref:servlet/authentication/architecture.adoc#servlet-authentication-providermanager[`AuthenticationManager`].
52
-
By default, it uses the <<servlet-saml2login-architecture,`OpenSaml4AuthenticationProvider`>>.
52
+
By default, it uses the <<servlet-saml2login-architecture,`OpenSaml5AuthenticationProvider`>>.
53
53
54
54
image:{icondir}/number_3.png[] If authentication fails, then _Failure_.
0 commit comments