Class ClientCredentialsHeaderTokenPropagator
java.lang.Object
io.micronaut.security.oauth2.client.clientcredentials.propagation.ClientCredentialsHeaderTokenPropagator
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,ClientCredentialsTokenPropagator
- Direct Known Subclasses:
DefaultClientCredentialsTokenPropagator
@Internal
@EachBean(OauthClientConfiguration.class)
@Requires(condition=ClientCredentialsEnabled.class) @Requires(condition=ClientCredentialsHeaderPropagatorEnabled.class)
public class ClientCredentialsHeaderTokenPropagator
extends Object
implements ClientCredentialsTokenPropagator
Propagates a token obtained via client credentials based off of a header.
- Since:
- 2.2.0
- Author:
- Sergio del Amo
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ClientCredentialsHeaderTokenPropagatorConfiguration
static final String
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionClientCredentialsHeaderTokenPropagator
(ClientCredentialsHeaderTokenPropagatorConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionextractTokenFromAuthorization
(String authorization) findToken
(@NonNull io.micronaut.http.HttpRequest<?> request) Search for a JWT token in a HTTP request.protected String
headerValue
(String token) void
writeToken
(@NonNull io.micronaut.http.MutableHttpRequest<?> request, @NonNull String token) Writes the token to the request.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Field Details
-
SPACE
- See Also:
-
configuration
-
-
Constructor Details
-
ClientCredentialsHeaderTokenPropagator
public ClientCredentialsHeaderTokenPropagator(ClientCredentialsHeaderTokenPropagatorConfiguration configuration) - Parameters:
configuration
- The token propagator configuration
-
-
Method Details
-
writeToken
public void writeToken(@NonNull @NonNull io.micronaut.http.MutableHttpRequest<?> request, @NonNull @NonNull String token) Writes the token to the request.- Specified by:
writeToken
in interfaceClientCredentialsTokenPropagator
- Parameters:
request
- TheMutableHttpRequest
instancetoken
- A token ( e.g. JWT token, basic auth token...)
-
findToken
Search for a JWT token in a HTTP request.- Specified by:
findToken
in interfaceClientCredentialsTokenPropagator
- Parameters:
request
- The request to look for the token in- Returns:
- if the JWT token is found it is returned, empty if not
-
headerValue
- Parameters:
token
- the token being written- Returns:
- the value which will be written to an HTTP Header
-
extractTokenFromAuthorization
- Parameters:
authorization
- Authorization header value- Returns:
- If prefix is 'Bearer' for 'Bearer XXX' it returns 'XXX'
-
getConfiguration
- Returns:
- The HttpHeaderTokenPropagator Configuration
-