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 does not yet support single logout.
1051
+
Spring Security ships with support for RP- and AP-initiated SAML 2.0 Single Logout.
1052
1052
1053
-
Generally speaking, though, you can achieve this by creating and registering a custom `LogoutSuccessHandler` and `RequestMatcher`:
1053
+
Briefly, there are two use cases Spring Security supports:
1054
+
1055
+
* **RP-Initiated** - Your application has an endpoint that, when POSTed to, will send a `saml2:LogoutRequest` to the asserting party.
1056
+
Thereafter, the asserting party will send back a `saml2:LogoutResponse` and your application will complete its logout at that point
1057
+
* **AP-Initiated** - Your application has an endpoint that will receive a `saml2:LogoutRequest` from the asserting party.
1058
+
Your application will complete its logout at that point and then send a `saml2:LogoutResponse` to the asserting party.
1059
+
1060
+
=== Minimal Configuration for Single Logout
1061
+
1062
+
To use Spring Security's SAML 2.0 Single Logout feature, you will need the following things:
1063
+
1064
+
* First, the asserting party must support SAML 2.0 Single Logout
1065
+
* Second, the asserting party should be configured to sign and POST `saml2:LogoutRequest` s and `saml2:LogoutResponse` s your application's `/logout` endpoint
1066
+
* Third, your application must have a PKCS#8 private key and X.509 certificate for signing `saml2:LogoutRequest` s and `saml2:LogoutResponse` s
1067
+
1068
+
==== RP-Initiated Single Logout
1069
+
1070
+
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);
1118
+
}
1119
+
----
1120
+
<1> - First, add your signing key to the `RelyingPartyRegistration` instance or to <<servlet-saml2login-rpr-duplicated,multiple instances>>
1121
+
<2> - Second, supply a `Filter` for initiating Single Logout, sending a `saml2:LogoutRequest` to the asserting party
1122
+
<3> - Third, supply the `LogoutHandler` s needed to handle the `saml2:LogoutResponse` s sent from the asserting party.
1123
+
1124
+
==== Runtime Expectations for RP-Initiated
1125
+
1126
+
Given the above configuration any logged in user can send a `POST /saml2/logout` to your application.
1127
+
Your application will then do the following:
1128
+
1129
+
1. 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.
1130
+
2. Send a redirect or post to the asserting party based on the <<servlet-saml2login-relyingpartyregistration,`RelyingPartyRegistration`>>
1131
+
3. Deserialize, verify, and process the `<saml2:LogoutResponse>` sent by the asserting party
1132
+
4. Logout the user and redirect to any configured successful logout endpoint
1133
+
1134
+
[TIP]
1135
+
If your asserting party does not send `<saml2:LogoutResponse>` s when logout is complete, the asserting party can still send a `POST /logout` and then there is no need to configure the `Saml2LogoutResponseHandler`.
1136
+
1137
+
==== AP-Initiated Single Logout
1138
+
1139
+
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:
return new Saml2AssertingPartyInitiatedLogoutSuccessHandler(logoutResponseResolver);
1189
+
}
1190
+
----
1191
+
<1> - First, add your signing key to the `RelyingPartyRegistration` instance or to <<servlet-saml2login-rpr-duplicated,multiple instances>>
1192
+
<2> - Second, supply the `LogoutHandler` needed to handle the `saml2:LogoutRequest` s sent from the asserting party.
1193
+
<3> - Third, supply a `LogoutSuccessHandler` for completing Single Logout, sending a `saml2:LogoutResponse` to the asserting party
1194
+
1195
+
==== Runtime Expectations for AP-Initiated
1196
+
1197
+
Given the above configuration, an asserting party can send a `POST /logout` to your application that includes a `<saml2:LogoutRequest>`
1198
+
Your application will then do the following:
1199
+
1200
+
1. Use a `Saml2LogoutRequestHandler` to deserialize, verify, and process the `<saml2:LogoutRequest>` sent by the asserting party
1201
+
2. Logout the user
1202
+
3. Create, sign, and serialize a `<saml2:LogoutResponse>` based on the <<servlet-saml2login-relyingpartyregistration,`RelyingPartyRegistration`>> associated with the just logged-out user
1203
+
4. Send a redirect or post to the asserting party based on the <<servlet-saml2login-relyingpartyregistration,`RelyingPartyRegistration`>>
1204
+
1205
+
[TIP]
1206
+
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`
1207
+
1208
+
[NOTE]
1209
+
In the event that you need to support both logout flows, you can combine the above to configurations.
1210
+
1211
+
=== Configuring Logout Endpoints
1212
+
1213
+
There are two default endpoints that Spring Security's SAML 2.0 Single Logout support exposes:
1214
+
* `/saml2/logout` - the endpoint for initiating single logout with an asserting party
1215
+
* `/logout` - the endpoint for receiving logout requests and responses from an asserting party
1216
+
1217
+
Because the user is already logged in, the `registrationId` is already known.
1218
+
For this reason, `+{registrationId}+` is not part of these URLs by default.
1219
+
1220
+
The first URL is not customizable at this point since this is not a URL that gets configured with the asserting party.
1221
+
As such the need to customize this endpoint is minimal, though this can be added to the support down the road.
1222
+
1223
+
The second URL is customizable through Spring Security's <<jc-logout,general-purpose logout support>>.
1224
+
1225
+
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`.
1226
+
To reduce changes in configuration for the asserting party, you can configure `logout` in the DSL like so:
0 commit comments