Package com.irurueta.authserver.serviceclient.infrastructure.resourceserver
package com.irurueta.authserver.serviceclient.infrastructure.resourceserver
Resource-server adapter of the service client: the documents gateways over a REST client generated from the
resource server's contract, and the OAuth2 client that obtains the access token they send (client credentials grant,
or token exchange on behalf of a user), authenticated with a secret, a signed assertion or a client certificate and
optionally DPoP-bound.
-
ClassDescriptionHow the service client authenticates at the token endpoint (
service-client.auth.method).Lists the documents through a generated client and translates every failure into aDocumentAccessException, so no HTTP, OAuth2 or JSON type escapes through the ports.Maps the documents the resource server answers onto the domain.Builds the documents client generated from the resource server's contract on top of a REST client that sends the access token of an authorized client (so the generated client's own authentication settings stay unused).Sends the access token of an authorized client asAuthorization: DPoP <token>together with aDPoPproof that binds the request and the token, when the token is DPoP-bound.Creates the DPoP proofs (RFC 9449) of the service client.The OAuth2 client of the service client: its registrations, the authorized client manager that caches the access tokens and renews them shortly before they expire, and the documents client that sends them.Builds the documents client of a user: its requests carry the access token that the authorization server issues in exchange for the user's own token.Builds the principals the authorized client manager caches tokens under.Resolves the key that signs theprivate_key_jwtassertion: the unencrypted PKCS#8 PEM RSA private key ofServiceClientKeyProperties, with its public half derived from it and theRS256algorithm.Creates the interceptors that put the access token on the calls to the resource server: Spring Security'sOAuth2ClientHttpRequestInterceptor(bearer), or the DPoP one whenservice-client.auth.dpopis on.Where the resource server is.Documents of the resource server read with the service client's own token (client credentials grant).Documents of the resource server read on behalf of a user: the user's access token is exchanged (RFC 8693) for one of the service client, which names the user as subject and the client as actor.Settings of the service client at the authorization server (service-client.auth.*).Private key with which theprivate_key_jwtassertion is signed (service-client.auth.key.*): an unencrypted RSA key in PKCS#8 PEM, given inline (the CLI profiles read it from theSERVICE_CLIENT_PRIVATE_KEYenvironment variable) or as the path of a file.Builds the OAuth2 client registrations of the service client from its settings: one for the client credentials grant and one for the token exchange grant, which share the client's identity and authentication.Gives the access token the service client uses, for the CLI that is asked to print it.Builds the HTTP request factory that presents the client certificate: the one of the SSL bundle named byservice-client.auth.ssl-bundle.The user a token exchange acts for: the principal is the user's access token, which is what Spring Security's token exchange provider reads as the subject token, and the name is what the authorized clients are cached under.Builds the clients of the token endpoint for the two grants, set up for the configured authentication method: the default forclient_secret_basic; the signed assertion forprivate_key_jwt; a REST client over the SSL bundle (so the client certificate is presented) for the mutual TLS methods; plus a DPoP proof header when DPoP is enabled.