Class HttpHeaderTokenPropagator
java.lang.Object
io.micronaut.security.token.propagation.HttpHeaderTokenPropagator
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,TokenPropagator
@Requires(property="micronaut.security.token.propagation.header.enabled",notEquals="false") @Requires(classes=io.micronaut.http.HttpRequest.class)
@Singleton
public class HttpHeaderTokenPropagator
extends Object
implements TokenPropagator
Propagates a token based off of a header.
- Since:
- 1.4.0
- Author:
- James Kleeh
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionHttpHeaderTokenPropagator
(HttpHeaderTokenPropagatorConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionextractTokenFromAuthorization
(String authorization) findToken
(io.micronaut.http.HttpRequest<?> request) Search for a JWT token in a HTTP request.protected String
headerValue
(String token) void
writeToken
(io.micronaut.http.MutableHttpRequest<?> request, 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
-
configuration
-
-
Constructor Details
-
HttpHeaderTokenPropagator
- Parameters:
configuration
- The token propagator configuration
-
-
Method Details
-
writeToken
Writes the token to the request.- Specified by:
writeToken
in interfaceTokenPropagator
- 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 interfaceTokenPropagator
- 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
-