Class ClientCredentialsHttpClientFilter
java.lang.Object
io.micronaut.security.oauth2.client.clientcredentials.propagation.ClientCredentialsHttpClientFilter
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,io.micronaut.http.filter.HttpClientFilter
,io.micronaut.http.filter.HttpFilter
@Filter("/**")
public class ClientCredentialsHttpClientFilter
extends Object
implements io.micronaut.http.filter.HttpClientFilter
An
HttpClientFilter
to add an access token to outgoing request thanks to a Client Credentials request.- Since:
- 2.2.0
- Author:
- Sergio del Amo
-
Field Summary
Modifier and TypeFieldDescriptionprotected final io.micronaut.context.BeanContext
protected final Map<String,
ClientCredentialsClient> protected final Map<String,
ClientCredentialsTokenPropagator> protected final List<OauthClientConfiguration>
protected final io.micronaut.http.util.OutgoingHttpRequestProcessor
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionClientCredentialsHttpClientFilter
(io.micronaut.http.util.OutgoingHttpRequestProcessor outgoingHttpRequestProcessor, Stream<OauthClientConfiguration> oauthClientConfigurationStream, ClientCredentialsTokenPropagator defaultTokenPropagator, io.micronaut.context.BeanContext beanContext) -
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<? extends io.micronaut.http.HttpResponse<?>>
doFilter
(io.micronaut.http.MutableHttpRequest<?> request, io.micronaut.http.filter.ClientFilterChain chain) protected Optional<ClientCredentialsClient>
getClient
(@NonNull OauthClientConfiguration oauthClient) protected Optional<OauthClientConfiguration>
getClientConfiguration
(io.micronaut.http.HttpRequest<?> request) protected @Nullable String
getScope
(@NonNull OauthClientConfiguration oauthClient) protected ClientCredentialsTokenPropagator
getTokenHandler
(@NonNull OauthClientConfiguration oauthClient) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.http.filter.HttpClientFilter
doFilter
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Field Details
-
outgoingHttpRequestProcessor
protected final io.micronaut.http.util.OutgoingHttpRequestProcessor outgoingHttpRequestProcessor -
oauthClientConfigurationCollection
-
beanContext
protected final io.micronaut.context.BeanContext beanContext -
clientCredentialsClientsByName
-
clientCredentialsTokenHandlerByName
-
-
Constructor Details
-
ClientCredentialsHttpClientFilter
public ClientCredentialsHttpClientFilter(io.micronaut.http.util.OutgoingHttpRequestProcessor outgoingHttpRequestProcessor, Stream<OauthClientConfiguration> oauthClientConfigurationStream, ClientCredentialsTokenPropagator defaultTokenPropagator, io.micronaut.context.BeanContext beanContext) - Parameters:
outgoingHttpRequestProcessor
- Utility to decide whether to process the requestoauthClientConfigurationStream
- OAuth 2.0 Clients configuration streamdefaultTokenPropagator
- The default token propagatorbeanContext
- Bean Context
-
-
Method Details
-
doFilter
public org.reactivestreams.Publisher<? extends io.micronaut.http.HttpResponse<?>> doFilter(io.micronaut.http.MutableHttpRequest<?> request, io.micronaut.http.filter.ClientFilterChain chain) - Specified by:
doFilter
in interfaceio.micronaut.http.filter.HttpClientFilter
-
getScope
@Nullable protected @Nullable String getScope(@NonNull @NonNull OauthClientConfiguration oauthClient) - Parameters:
oauthClient
- OAuth 2.0 Client configuration- Returns:
- The desired scope for client credentials grant or null if no scope should be specified
-
getClient
protected Optional<ClientCredentialsClient> getClient(@NonNull @NonNull OauthClientConfiguration oauthClient) - Parameters:
oauthClient
- OAuth 2.0 Client configuration- Returns:
- The Client credentials client for the OAuth 2.0 Client.
-
getTokenHandler
protected ClientCredentialsTokenPropagator getTokenHandler(@NonNull @NonNull OauthClientConfiguration oauthClient) - Parameters:
oauthClient
- OAuth 2.0 Client configuration- Returns:
- The Client credentials token propagator for the OAuth 2.0 Client.
-
getClientConfiguration
protected Optional<OauthClientConfiguration> getClientConfiguration(io.micronaut.http.HttpRequest<?> request) - Parameters:
request
- Http Request- Returns:
- An OAuth 2.0 Client configuration which has client credentials configuration set and should process the request
-