Skip to content

Commit cea4677

Browse files
committed
Add documentation for OpenID Connect 1.0 Logout Endpoint
Closes gh-1069
1 parent 128d439 commit cea4677

File tree

5 files changed

+108
-10
lines changed

5 files changed

+108
-10
lines changed

docs/src/docs/asciidoc/configuration-model.adoc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
7070
In addition to the default protocol endpoints, the OAuth2 authorization server `SecurityFilterChain` `@Bean` is configured with the following OpenID Connect 1.0 protocol endpoints:
7171

7272
* xref:protocol-endpoints.adoc#oidc-provider-configuration-endpoint[OpenID Connect 1.0 Provider Configuration endpoint]
73+
* xref:protocol-endpoints.adoc#oidc-logout-endpoint[OpenID Connect 1.0 Logout endpoint]
7374
* xref:protocol-endpoints.adoc#oidc-user-info-endpoint[OpenID Connect 1.0 UserInfo endpoint]
7475

7576
[NOTE]
@@ -123,8 +124,9 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
123124
.authorizationServerMetadataEndpoint(authorizationServerMetadataEndpoint -> { }) <13>
124125
.oidc(oidc -> oidc
125126
.providerConfigurationEndpoint(providerConfigurationEndpoint -> { }) <14>
126-
.userInfoEndpoint(userInfoEndpoint -> { }) <15>
127-
.clientRegistrationEndpoint(clientRegistrationEndpoint -> { }) <16>
127+
.logoutEndpoint(logoutEndpoint -> { }) <15>
128+
.userInfoEndpoint(userInfoEndpoint -> { }) <16>
129+
.clientRegistrationEndpoint(clientRegistrationEndpoint -> { }) <17>
128130
);
129131
130132
return http.build();
@@ -144,8 +146,9 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
144146
<12> `tokenRevocationEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oauth2-token-revocation-endpoint[OAuth2 Token Revocation endpoint].
145147
<13> `authorizationServerMetadataEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oauth2-authorization-server-metadata-endpoint[OAuth2 Authorization Server Metadata endpoint].
146148
<14> `providerConfigurationEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oidc-provider-configuration-endpoint[OpenID Connect 1.0 Provider Configuration endpoint].
147-
<15> `userInfoEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oidc-user-info-endpoint[OpenID Connect 1.0 UserInfo endpoint].
148-
<16> `clientRegistrationEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oidc-client-registration-endpoint[OpenID Connect 1.0 Client Registration endpoint].
149+
<15> `logoutEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oidc-logout-endpoint[OpenID Connect 1.0 Logout endpoint].
150+
<16> `userInfoEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oidc-user-info-endpoint[OpenID Connect 1.0 UserInfo endpoint].
151+
<17> `clientRegistrationEndpoint()`: The configurer for the xref:protocol-endpoints.adoc#oidc-client-registration-endpoint[OpenID Connect 1.0 Client Registration endpoint].
149152

150153
[[configuring-authorization-server-settings]]
151154
== Configuring Authorization Server Settings
@@ -169,6 +172,7 @@ public final class AuthorizationServerSettings extends AbstractSettings {
169172
.tokenIntrospectionEndpoint("/oauth2/introspect")
170173
.tokenRevocationEndpoint("/oauth2/revoke")
171174
.jwkSetEndpoint("/oauth2/jwks")
175+
.oidcLogoutEndpoint("/connect/logout")
172176
.oidcUserInfoEndpoint("/userinfo")
173177
.oidcClientRegistrationEndpoint("/connect/register");
174178
}
@@ -199,6 +203,7 @@ public AuthorizationServerSettings authorizationServerSettings() {
199203
.tokenIntrospectionEndpoint("/oauth2/v1/introspect")
200204
.tokenRevocationEndpoint("/oauth2/v1/revoke")
201205
.jwkSetEndpoint("/oauth2/v1/jwks")
206+
.oidcLogoutEndpoint("/connect/v1/logout")
202207
.oidcUserInfoEndpoint("/connect/v1/userinfo")
203208
.oidcClientRegistrationEndpoint("/connect/v1/register")
204209
.build();

docs/src/docs/asciidoc/core-model-components.adoc

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ public class RegisteredClient implements Serializable {
6969
private Set<ClientAuthenticationMethod> clientAuthenticationMethods; <7>
7070
private Set<AuthorizationGrantType> authorizationGrantTypes; <8>
7171
private Set<String> redirectUris; <9>
72-
private Set<String> scopes; <10>
73-
private ClientSettings clientSettings; <11>
74-
private TokenSettings tokenSettings; <12>
72+
private Set<String> postLogoutRedirectUris; <10>
73+
private Set<String> scopes; <11>
74+
private ClientSettings clientSettings; <12>
75+
private TokenSettings tokenSettings; <13>
7576
7677
...
7778
@@ -86,9 +87,10 @@ public class RegisteredClient implements Serializable {
8687
<7> `clientAuthenticationMethods`: The authentication method(s) that the client may use. The supported values are `client_secret_basic`, `client_secret_post`, https://datatracker.ietf.org/doc/html/rfc7523[`private_key_jwt`], `client_secret_jwt`, and `none` https://datatracker.ietf.org/doc/html/rfc7636[(public clients)].
8788
<8> `authorizationGrantTypes`: The https://datatracker.ietf.org/doc/html/rfc6749#section-1.3[authorization grant type(s)] that the client can use. The supported values are `authorization_code`, `client_credentials`, `refresh_token`, and `urn:ietf:params:oauth:grant-type:device_code`.
8889
<9> `redirectUris`: The registered https://datatracker.ietf.org/doc/html/rfc6749#section-3.1.2[redirect URI(s)] that the client may use in redirect-based flows – for example, `authorization_code` grant.
89-
<10> `scopes`: The scope(s) that the client is allowed to request.
90-
<11> `clientSettings`: The custom settings for the client – for example, require https://datatracker.ietf.org/doc/html/rfc7636[PKCE], require authorization consent, and others.
91-
<12> `tokenSettings`: The custom settings for the OAuth2 tokens issued to the client – for example, access/refresh token time-to-live, reuse refresh tokens, and others.
90+
<10> `postLogoutRedirectUris`: The post logout redirect URI(s) that the client may use for logout.
91+
<11> `scopes`: The scope(s) that the client is allowed to request.
92+
<12> `clientSettings`: The custom settings for the client – for example, require https://datatracker.ietf.org/doc/html/rfc7636[PKCE], require authorization consent, and others.
93+
<13> `tokenSettings`: The custom settings for the OAuth2 tokens issued to the client – for example, access/refresh token time-to-live, reuse refresh tokens, and others.
9294

9395
[[registered-client-repository]]
9496
== RegisteredClientRepository
@@ -491,3 +493,34 @@ If the `OAuth2TokenGenerator` is not provided as a `@Bean` or is not configured
491493

492494
[TIP]
493495
For an example showing how you can xref:guides/how-to-userinfo.adoc#customize-id-token[customize the ID token], see the guide xref:guides/how-to-userinfo.adoc#how-to-userinfo[How-to: Customize the OpenID Connect 1.0 UserInfo response].
496+
497+
[[session-registry]]
498+
== SessionRegistry
499+
500+
If OpenID Connect 1.0 is enabled, a `SessionRegistry` instance is used to track authenticated sessions.
501+
The `SessionRegistry` is used by the default implementation of `SessionAuthenticationStrategy` associated to the xref:protocol-endpoints.adoc#oauth2-authorization-endpoint[OAuth2 Authorization Endpoint] for registering new authenticated sessions.
502+
503+
[NOTE]
504+
If a `SessionRegistry` `@Bean` is not registered, the default implementation `SessionRegistryImpl` will be used.
505+
506+
[IMPORTANT]
507+
If a `SessionRegistry` `@Bean` is registered and is an instance of `SessionRegistryImpl`, a `HttpSessionEventPublisher` `@Bean` *SHOULD* also be registered as it's responsible for notifying `SessionRegistryImpl` of session lifecycle events, for example, `SessionDestroyedEvent`, to provide the ability to remove the `SessionInformation` instance.
508+
509+
When a logout is requested by an End-User, the xref:protocol-endpoints.adoc#oidc-logout-endpoint[OpenID Connect 1.0 Logout Endpoint] uses the `SessionRegistry` to lookup the `SessionInformation` associated to the authenticated End-User to perform the logout.
510+
511+
If Spring Security's {spring-security-reference-base-url}/servlet/authentication/session-management.html#ns-concurrent-sessions[Concurrent Session Control] feature is being used, it is *RECOMMENDED* to register a `SessionRegistry` `@Bean` to ensure it's shared between Spring Security's Concurrent Session Control and Spring Authorization Server's Logout feature.
512+
513+
The following example shows how to register a `SessionRegistry` `@Bean` and `HttpSessionEventPublisher` `@Bean` (required by `SessionRegistryImpl`):
514+
515+
[source,java]
516+
----
517+
@Bean
518+
public SessionRegistry sessionRegistry() {
519+
return new SessionRegistryImpl();
520+
}
521+
522+
@Bean
523+
public HttpSessionEventPublisher httpSessionEventPublisher() {
524+
return new HttpSessionEventPublisher();
525+
}
526+
----

docs/src/docs/asciidoc/examples/src/main/java/sample/gettingStarted/SecurityConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public RegisteredClientRepository registeredClientRepository() {
119119
.authorizationGrantType(AuthorizationGrantType.DEVICE_CODE)
120120
.redirectUri("http://127.0.0.1:8080/login/oauth2/code/messaging-client-oidc")
121121
.redirectUri("http://127.0.0.1:8080/authorized")
122+
.postLogoutRedirectUri("http://127.0.0.1:8080/index")
122123
.scope(OidcScopes.OPENID)
123124
.scope(OidcScopes.PROFILE)
124125
.scope("message.read")

docs/src/docs/asciidoc/overview.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Spring Authorization Server supports the following features:
6868
* xref:protocol-endpoints.adoc#oauth2-authorization-server-metadata-endpoint[OAuth2 Authorization Server Metadata Endpoint]
6969
* xref:protocol-endpoints.adoc#jwk-set-endpoint[JWK Set Endpoint]
7070
* xref:protocol-endpoints.adoc#oidc-provider-configuration-endpoint[OpenID Connect 1.0 Provider Configuration Endpoint]
71+
* xref:protocol-endpoints.adoc#oidc-logout-endpoint[OpenID Connect 1.0 Logout Endpoint]
7172
* xref:protocol-endpoints.adoc#oidc-user-info-endpoint[OpenID Connect 1.0 UserInfo Endpoint]
7273
* xref:protocol-endpoints.adoc#oidc-client-registration-endpoint[OpenID Connect 1.0 Client Registration Endpoint]
7374
|
@@ -83,6 +84,8 @@ Spring Authorization Server supports the following features:
8384
* JSON Web Key (JWK) (https://tools.ietf.org/html/rfc7517[RFC 7517])
8485
* OpenID Connect Discovery 1.0 (https://openid.net/specs/openid-connect-discovery-1_0.html[spec])
8586
** https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig[Provider Configuration Endpoint]
87+
* OpenID Connect RP-Initiated Logout 1.0 (https://openid.net/specs/openid-connect-rpinitiated-1_0.html[spec])
88+
** https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout[Logout Endpoint]
8689
* OpenID Connect Core 1.0 (https://openid.net/specs/openid-connect-core-1_0.html[spec])
8790
** https://openid.net/specs/openid-connect-core-1_0.html#UserInfo[UserInfo Endpoint]
8891
* OpenID Connect Dynamic Client Registration 1.0 (https://openid.net/specs/openid-connect-registration-1_0.html[spec])

docs/src/docs/asciidoc/protocol-endpoints.adoc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,62 @@ public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity h
433433
`OidcProviderConfigurationEndpointConfigurer` configures the `OidcProviderConfigurationEndpointFilter` and registers it with the OAuth2 authorization server `SecurityFilterChain` `@Bean`.
434434
`OidcProviderConfigurationEndpointFilter` is the `Filter` that returns the https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationResponse[OidcProviderConfiguration response].
435435

436+
[[oidc-logout-endpoint]]
437+
== OpenID Connect 1.0 Logout Endpoint
438+
439+
`OidcLogoutEndpointConfigurer` provides the ability to customize the https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout[OpenID Connect 1.0 Logout endpoint].
440+
It defines extension points that let you customize the pre-processing, main processing, and post-processing logic for RP-Initiated Logout requests.
441+
442+
`OidcLogoutEndpointConfigurer` provides the following configuration options:
443+
444+
[source,java]
445+
----
446+
@Bean
447+
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception {
448+
OAuth2AuthorizationServerConfigurer authorizationServerConfigurer =
449+
new OAuth2AuthorizationServerConfigurer();
450+
http.apply(authorizationServerConfigurer);
451+
452+
authorizationServerConfigurer
453+
.oidc(oidc ->
454+
oidc
455+
.logoutEndpoint(logoutEndpoint ->
456+
logoutEndpoint
457+
.logoutRequestConverter(logoutRequestConverter) <1>
458+
.logoutRequestConverters(logoutRequestConvertersConsumer) <2>
459+
.authenticationProvider(authenticationProvider) <3>
460+
.authenticationProviders(authenticationProvidersConsumer) <4>
461+
.logoutResponseHandler(logoutResponseHandler) <5>
462+
.errorResponseHandler(errorResponseHandler) <6>
463+
)
464+
);
465+
466+
return http.build();
467+
}
468+
----
469+
<1> `logoutRequestConverter()`: Adds an `AuthenticationConverter` (_pre-processor_) used when attempting to extract a https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout[Logout request] from `HttpServletRequest` to an instance of `OidcLogoutAuthenticationToken`.
470+
<2> `logoutRequestConverters()`: Sets the `Consumer` providing access to the `List` of default and (optionally) added ``AuthenticationConverter``'s allowing the ability to add, remove, or customize a specific `AuthenticationConverter`.
471+
<3> `authenticationProvider()`: Adds an `AuthenticationProvider` (_main processor_) used for authenticating the `OidcLogoutAuthenticationToken`.
472+
<4> `authenticationProviders()`: Sets the `Consumer` providing access to the `List` of default and (optionally) added ``AuthenticationProvider``'s allowing the ability to add, remove, or customize a specific `AuthenticationProvider`.
473+
<5> `logoutResponseHandler()`: The `AuthenticationSuccessHandler` (_post-processor_) used for handling an "`authenticated`" `OidcLogoutAuthenticationToken` and performing the logout.
474+
<6> `errorResponseHandler()`: The `AuthenticationFailureHandler` (_post-processor_) used for handling an `OAuth2AuthenticationException` and returning the error response.
475+
476+
`OidcLogoutEndpointConfigurer` configures the `OidcLogoutEndpointFilter` and registers it with the OAuth2 authorization server `SecurityFilterChain` `@Bean`.
477+
`OidcLogoutEndpointFilter` is the `Filter` that processes https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout[RP-Initiated Logout requests] and performs the logout of the End-User.
478+
479+
`OidcLogoutEndpointFilter` is configured with the following defaults:
480+
481+
* `*AuthenticationConverter*` -- An `OidcLogoutAuthenticationConverter`.
482+
* `*AuthenticationManager*` -- An `AuthenticationManager` composed of `OidcLogoutAuthenticationProvider`.
483+
* `*AuthenticationSuccessHandler*` -- An internal implementation that handles an "`authenticated`" `OidcLogoutAuthenticationToken` and performs the logout.
484+
* `*AuthenticationFailureHandler*` -- An internal implementation that uses the `OAuth2Error` associated with the `OAuth2AuthenticationException` and returns the `OAuth2Error` response.
485+
486+
[NOTE]
487+
`OidcLogoutAuthenticationProvider` uses a xref:core-model-components.adoc#session-registry[`SessionRegistry`] to look up the `SessionInformation` instance associated to the End-User requesting to be logged out.
488+
489+
[TIP]
490+
`OidcClientInitiatedLogoutSuccessHandler` is the corresponding configuration in Spring Security’s OAuth2 Client support for configuring {spring-security-reference-base-url}/servlet/oauth2/login/advanced.html#oauth2login-advanced-oidc-logout[OpenID Connect 1.0 RP-Initiated Logout].
491+
436492
[[oidc-user-info-endpoint]]
437493
== OpenID Connect 1.0 UserInfo Endpoint
438494

0 commit comments

Comments
 (0)