Class ResourceServerClientConfiguration
java.lang.Object
com.irurueta.authserver.bff.infrastructure.resourceserver.ResourceServerClientConfiguration
@Configuration(proxyBeanMethods=false)
@EnableConfigurationProperties(ResourceServerProperties.class)
public class ResourceServerClientConfiguration
extends Object
Builds the client of the resource server: the
RestClient that carries the access token of the signed-in
user, and the DocumentsApi generated from the resource server's contract on top of it. The
OAuth2AuthorizedClientManager is the one the web adapter's security configuration declares; this module
only depends on its type.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringRegistration id of the OAuth2 client whose access token is sent to the resource server. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) DocumentsApiresourceServerDocumentsApi(org.springframework.web.client.RestClient resourceServerRestClient, ResourceServerProperties properties) Builds the documents client generated from the resource server's contract, on top of the REST client that carries the user's token (so the generated client's own authentication settings stay unused).(package private) org.springframework.web.client.RestClientresourceServerRestClient(org.springframework.web.client.RestClient.Builder builder, org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager manager) Builds the REST client of the resource server.
-
Field Details
-
REGISTRATION_ID
Registration id of the OAuth2 client whose access token is sent to the resource server.- See Also:
-
-
Constructor Details
-
ResourceServerClientConfiguration
public ResourceServerClientConfiguration()
-
-
Method Details
-
resourceServerRestClient
@Bean org.springframework.web.client.RestClient resourceServerRestClient(org.springframework.web.client.RestClient.Builder builder, org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager manager) Builds the REST client of the resource server. Its interceptor asks the authorized client manager for the access token of the user of the current request (renewing it with the refresh token when it expired) and sets it as the bearer token of the outgoing request; a call whose session has no token is never sent. When the token cannot be obtained or renewed it throws anOAuth2AuthorizationException, whichRestDocumentGatewayreports asDocumentsUnauthorizedException, answered 401 so the SPA signs in again.- Parameters:
builder- the builder of REST clients, the one test slices bind a mock server to.manager- the manager of the authorized clients of the session.- Returns:
- the REST client of the resource server.
-
resourceServerDocumentsApi
@Bean DocumentsApi resourceServerDocumentsApi(org.springframework.web.client.RestClient resourceServerRestClient, ResourceServerProperties properties) Builds the documents client generated from the resource server's contract, on top of the REST client that carries the user's token (so the generated client's own authentication settings stay unused).- Parameters:
resourceServerRestClient- the REST client of the resource server.properties- where the resource server is.- Returns:
- the generated documents client.
-