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
Spring Security ships with support for RP- and AP-initiated SAML 2.0 Single Logout.
1056
+
Spring Security does not yet support single logout.
1057
1057
1058
-
Briefly, there are two use cases Spring Security supports:
1059
-
1060
-
* **RP-Initiated** - Your application has an endpoint that, when POSTed to, will logout the user and send a `saml2:LogoutRequest` to the asserting party.
1061
-
Thereafter, the asserting party will send back a `saml2:LogoutResponse` and allow your application to respond
1062
-
* **AP-Initiated** - Your application has an endpoint that will receive a `saml2:LogoutRequest` from the asserting party.
1063
-
Your application will complete its logout at that point and then send a `saml2:LogoutResponse` to the asserting party.
1064
-
1065
-
[NOTE]
1066
-
In the **AP-Initiated** scenario, any local redirection that your application would do post-logout is rendered moot.
1067
-
Once your application sends a `saml2:LogoutResponse`, it no longer has control of the browser.
1068
-
1069
-
=== Minimal Configuration for Single Logout
1070
-
1071
-
To use Spring Security's SAML 2.0 Single Logout feature, you will need the following things:
1072
-
1073
-
* First, the asserting party must support SAML 2.0 Single Logout
1074
-
* Second, the asserting party should be configured to sign and POST `saml2:LogoutRequest` s and `saml2:LogoutResponse` s your application's `/logout/saml2/slo` endpoint
1075
-
* Third, your application must have a PKCS#8 private key and X.509 certificate for signing `saml2:LogoutRequest` s and `saml2:LogoutResponse` s
1076
-
1077
-
==== RP-Initiated Single Logout
1078
-
1079
-
Given those, then for RP-initiated Single Logout, you can begin from the initial minimal example and add the following configuration:
return new OpenSamlLogoutResponseHandler(relyingPartyRegistrationResolver);
1123
-
}
1124
-
----
1125
-
<1> - First, add your signing key to the `RelyingPartyRegistration` instance or to <<servlet-saml2login-rpr-duplicated,multiple instances>>
1126
-
<2> - Second, supply a `LogoutSuccessHandler` for initiating Single Logout, sending a `saml2:LogoutRequest` to the asserting party
1127
-
<3> - Third, supply the `LogoutHandler` s needed to handle the `saml2:LogoutResponse` s sent from the asserting party.
1128
-
1129
-
==== Runtime Expectations for RP-Initiated
1130
-
1131
-
Given the above configuration any logged in user can send a `POST /logout` to your application to perform RP-initiated SLO.
1132
-
Your application will then do the following:
1133
-
1134
-
1. Logout the user and invalidate the session
1135
-
2. Use a `Saml2LogoutRequestResolver` to create, sign, and serialize a `<saml2:LogoutRequest>` based on the <<servlet-saml2login-relyingpartyregistration,`RelyingPartyRegistration`>> associated with the currently logged-in user.
1136
-
3. Send a redirect or post to the asserting party based on the <<servlet-saml2login-relyingpartyregistration,`RelyingPartyRegistration`>>
1137
-
4. Deserialize, verify, and process the `<saml2:LogoutResponse>` sent by the asserting party
1138
-
5. Redirect to any configured successful logout endpoint
1139
-
1140
-
[TIP]
1141
-
If your asserting party does not send `<saml2:LogoutResponse>` s when logout is complete, the asserting party can still send a `POST /saml2/logout` and then there is no need to configure the `Saml2LogoutResponseHandler`.
1142
-
1143
-
==== AP-Initiated Single Logout
1144
-
1145
-
Instead of RP-initiated Single Logout, you can again begin from the initial minimal example and add the following configuration to achieve AP-initiated Single Logout:
OpenSaml4LogoutResponseResolver logoutResponseResolver = new OpenSaml4LogoutResponseResolver(registrationResolver);
1187
-
return new Saml2LogoutResponseSuccessHandler(logoutResponseResolver);
1188
-
}
1189
-
----
1190
-
<1> - First, add your signing key to the `RelyingPartyRegistration` instance or to <<servlet-saml2login-rpr-duplicated,multiple instances>>
1191
-
<2> - Second, supply the `LogoutHandler` needed to handle the `saml2:LogoutRequest` s sent from the asserting party.
1192
-
<3> - Third, supply a `LogoutSuccessHandler` for completing Single Logout, sending a `saml2:LogoutResponse` to the asserting party
1193
-
1194
-
==== Runtime Expectations for AP-Initiated
1195
-
1196
-
Given the above configuration, an asserting party can send a `POST /logout/saml2` to your application that includes a `<saml2:LogoutRequest>`
1197
-
Also, your application can participate in an AP-initated logout when the asserting party sends a `<saml2:LogoutRequest>` to `/logout/saml2/slo`:
1198
-
1199
-
1. Use a `Saml2LogoutRequestHandler` to deserialize, verify, and process the `<saml2:LogoutRequest>` sent by the asserting party
1200
-
2. Logout the user and invalidate the session
1201
-
3. Create, sign, and serialize a `<saml2:LogoutResponse>` based on the <<servlet-saml2login-relyingpartyregistration,`RelyingPartyRegistration`>> associated with the just logged-out user
1202
-
4. Send a redirect or post to the asserting party based on the <<servlet-saml2login-relyingpartyregistration,`RelyingPartyRegistration`>>
1203
-
1204
-
[TIP]
1205
-
If your asserting party does not expect you do send a `<saml2:LogoutResponse>` s when logout is complete, you may not need to configure a `LogoutSuccessHandler`
1206
-
1207
-
[NOTE]
1208
-
In the event that you need to support both logout flows, you can combine the above to configurations.
1209
-
1210
-
=== Configuring Logout Endpoints
1211
-
1212
-
There are three default endpoints that Spring Security's SAML 2.0 Single Logout support exposes:
1213
-
* `/logout` - the endpoint for initiating single logout with an asserting party
1214
-
* `/logout/saml2/slo` - the endpoint for receiving logout requests or responses from an asserting party
1215
-
1216
-
Because the user is already logged in, the `registrationId` is already known.
1217
-
For this reason, `+{registrationId}+` is not part of these URLs by default.
1218
-
1219
-
These URLs are customizable in the DSL.
1220
-
1221
-
For example, if you are migrating your existing relying party over to Spring Security, your asserting party may already be pointing to `GET /SLOService.saml2`.
1222
-
To reduce changes in configuration for the asserting party, you can configure the filter in the DSL like so:
1058
+
Generally speaking, though, you can achieve this by creating and registering a custom `LogoutSuccessHandler` and `RequestMatcher`:
1223
1059
1224
1060
[source,java]
1225
1061
----
1226
-
Saml2LogoutResponseFilter filter = new Saml2LogoutResponseFilter(logoutHandler);
Copy file name to clipboardExpand all lines: saml2/saml2-service-provider/core/src/main/java/org/springframework/security/saml2/core/Saml2ErrorCodes.java
-7Lines changed: 0 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -37,13 +37,6 @@ public interface Saml2ErrorCodes {
0 commit comments