Class AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository
java.lang.Object
org.springframework.security.oauth2.client.web.server.AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository
- All Implemented Interfaces:
ServerOAuth2AuthorizedClientRepository
public final class AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository
extends Object
implements ServerOAuth2AuthorizedClientRepository
An implementation of an
ServerOAuth2AuthorizedClientRepository
that delegates
to the provided ServerOAuth2AuthorizedClientRepository
if the current
Principal
is authenticated, otherwise, to the default (or provided)
ServerOAuth2AuthorizedClientRepository
if the current request is
unauthenticated (or anonymous). The default
ReactiveOAuth2AuthorizedClientRepository
is
WebSessionServerOAuth2AuthorizedClientRepository
.-
Constructor Summary
ConstructorDescriptionAuthenticatedPrincipalServerOAuth2AuthorizedClientRepository
(ReactiveOAuth2AuthorizedClientService authorizedClientService) Creates an instance -
Method Summary
Modifier and TypeMethodDescription<T extends OAuth2AuthorizedClient>
reactor.core.publisher.Mono<T>loadAuthorizedClient
(String clientRegistrationId, Authentication principal, org.springframework.web.server.ServerWebExchange exchange) Returns theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-UserAuthentication
(Resource Owner) ornull
if not available.reactor.core.publisher.Mono<Void>
removeAuthorizedClient
(String clientRegistrationId, Authentication principal, org.springframework.web.server.ServerWebExchange exchange) Removes theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-UserAuthentication
(Resource Owner).reactor.core.publisher.Mono<Void>
saveAuthorizedClient
(OAuth2AuthorizedClient authorizedClient, Authentication principal, org.springframework.web.server.ServerWebExchange exchange) Saves theOAuth2AuthorizedClient
associating it to the provided End-UserAuthentication
(Resource Owner).void
setAnonymousAuthorizedClientRepository
(ServerOAuth2AuthorizedClientRepository anonymousAuthorizedClientRepository) Sets theServerOAuth2AuthorizedClientRepository
used for requests that are unauthenticated (or anonymous).
-
Constructor Details
-
AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository
public AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository(ReactiveOAuth2AuthorizedClientService authorizedClientService) Creates an instance- Parameters:
authorizedClientService
- the authorized client service
-
-
Method Details
-
setAnonymousAuthorizedClientRepository
public void setAnonymousAuthorizedClientRepository(ServerOAuth2AuthorizedClientRepository anonymousAuthorizedClientRepository) Sets theServerOAuth2AuthorizedClientRepository
used for requests that are unauthenticated (or anonymous). The default isWebSessionServerOAuth2AuthorizedClientRepository
.- Parameters:
anonymousAuthorizedClientRepository
- the repository used for requests that are unauthenticated (or anonymous)
-
loadAuthorizedClient
public <T extends OAuth2AuthorizedClient> reactor.core.publisher.Mono<T> loadAuthorizedClient(String clientRegistrationId, Authentication principal, org.springframework.web.server.ServerWebExchange exchange) Description copied from interface:ServerOAuth2AuthorizedClientRepository
Returns theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-UserAuthentication
(Resource Owner) ornull
if not available.- Specified by:
loadAuthorizedClient
in interfaceServerOAuth2AuthorizedClientRepository
- Type Parameters:
T
- a type of OAuth2AuthorizedClient- Parameters:
clientRegistrationId
- the identifier for the client's registrationprincipal
- the End-UserAuthentication
(Resource Owner)exchange
- theServerWebExchange
- Returns:
- the
OAuth2AuthorizedClient
ornull
if not available
-
saveAuthorizedClient
public reactor.core.publisher.Mono<Void> saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal, org.springframework.web.server.ServerWebExchange exchange) Description copied from interface:ServerOAuth2AuthorizedClientRepository
Saves theOAuth2AuthorizedClient
associating it to the provided End-UserAuthentication
(Resource Owner).- Specified by:
saveAuthorizedClient
in interfaceServerOAuth2AuthorizedClientRepository
- Parameters:
authorizedClient
- the authorized clientprincipal
- the End-UserAuthentication
(Resource Owner)exchange
- theServerWebExchange
-
removeAuthorizedClient
public reactor.core.publisher.Mono<Void> removeAuthorizedClient(String clientRegistrationId, Authentication principal, org.springframework.web.server.ServerWebExchange exchange) Description copied from interface:ServerOAuth2AuthorizedClientRepository
Removes theOAuth2AuthorizedClient
associated to the provided client registration identifier and End-UserAuthentication
(Resource Owner).- Specified by:
removeAuthorizedClient
in interfaceServerOAuth2AuthorizedClientRepository
- Parameters:
clientRegistrationId
- the identifier for the client's registrationprincipal
- the End-UserAuthentication
(Resource Owner)exchange
- theServerWebExchange
-