public abstract class SecurityDirectives extends SchemeDirectives
Modifier and Type | Class and Description |
---|---|
static class |
SecurityDirectives.ProvidedCredentials
Represents HTTP Basic or OAuth2 authentication credentials supplied with a request.
|
static class |
SecurityDirectives.ProvidedCredentials$ |
Constructor and Description |
---|
SecurityDirectives() |
Modifier and Type | Method and Description |
---|---|
<T> Route |
authenticateBasic(java.lang.String realm,
java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.Optional<T>> authenticator,
java.util.function.Function<T,Route> inner)
Wraps the inner route with Http Basic authentication support using a given
Authenticator[T] . |
<T> Route |
authenticateBasicAsync(java.lang.String realm,
java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<java.util.Optional<T>>> authenticator,
java.util.function.Function<T,Route> inner)
Wraps the inner route with Http Basic authentication support.
|
<T> Route |
authenticateBasicAsyncOptional(java.lang.String realm,
java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<java.util.Optional<T>>> authenticator,
java.util.function.Function<java.util.Optional<T>,Route> inner)
Wraps the inner route with Http Basic authentication support.
|
<T> Route |
authenticateBasicOptional(java.lang.String realm,
java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.Optional<T>> authenticator,
java.util.function.Function<java.util.Optional<T>,Route> inner)
Wraps the inner route with Http Basic authentication support using a given
Authenticator[T] . |
<T> Route |
authenticateBasicPF(java.lang.String realm,
scala.PartialFunction<java.util.Optional<SecurityDirectives.ProvidedCredentials>,T> authenticator,
java.util.function.Function<T,Route> inner)
Wraps the inner route with Http Basic authentication support.
|
<T> Route |
authenticateBasicPFAsync(java.lang.String realm,
scala.PartialFunction<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<T>> authenticator,
java.util.function.Function<T,Route> inner)
Wraps the inner route with Http Basic authentication support.
|
<T> Route |
authenticateOAuth2(java.lang.String realm,
java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.Optional<T>> authenticator,
java.util.function.Function<T,Route> inner)
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
|
<T> Route |
authenticateOAuth2Async(java.lang.String realm,
java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<java.util.Optional<T>>> authenticator,
java.util.function.Function<T,Route> inner)
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
|
<T> Route |
authenticateOAuth2AsyncOptional(java.lang.String realm,
java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<java.util.Optional<T>>> authenticator,
java.util.function.Function<java.util.Optional<T>,Route> inner)
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
|
<T> Route |
authenticateOAuth2Optional(java.lang.String realm,
java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.Optional<T>> authenticator,
java.util.function.Function<java.util.Optional<T>,Route> inner)
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
|
<C extends HttpCredentials,T> |
authenticateOrRejectWithChallenge(java.lang.Class<C> c,
java.util.function.Function<java.util.Optional<C>,java.util.concurrent.CompletionStage<scala.util.Either<HttpChallenge,T>>> authenticator,
java.util.function.Function<T,Route> inner)
Lifts an authenticator function into a directive.
|
<T> Route |
authenticateOrRejectWithChallenge(java.util.function.Function<java.util.Optional<HttpCredentials>,java.util.concurrent.CompletionStage<scala.util.Either<HttpChallenge,T>>> authenticator,
java.util.function.Function<T,Route> inner)
Lifts an authenticator function into a directive.
|
Route |
authorize(java.util.function.Supplier<java.lang.Object> check,
java.util.function.Supplier<Route> inner)
Applies the given authorization check to the request.
|
Route |
authorizeAsync(java.util.function.Supplier<java.util.concurrent.CompletionStage<java.lang.Object>> check,
java.util.function.Supplier<Route> inner)
Applies the given authorization check to the request.
|
Route |
authorizeAsyncWithRequestContext(org.apache.pekko.japi.function.Function<RequestContext,java.util.concurrent.CompletionStage<java.lang.Object>> check,
java.util.function.Supplier<Route> inner)
Asynchronous version of
authorize . |
Route |
authorizeWithRequestContext(org.apache.pekko.japi.function.Function<RequestContext,java.lang.Object> check,
java.util.function.Supplier<Route> inner)
Applies the given authorization check to the request.
|
Route |
extractCredentials(java.util.function.Function<java.util.Optional<HttpCredentials>,Route> inner)
Extracts the potentially present
HttpCredentials provided with the request's pekko.http.javadsl.model.headers.Authorization header. |
extractScheme, scheme
complete, complete, complete, complete, complete, complete, complete, complete, complete, complete, complete, complete, complete, complete, complete, complete, completeOK, completeOKWithFuture, completeOKWithFuture, completeOKWithFuture, completeOKWithFutureString, completeOKWithFutureString, completeWithFuture, completeWithFuture, completeWithFuture, completeWithFutureResponse, completeWithFutureStatus, completeWithFutureStatus, concat, concat, failWith, handle, handleSync, redirect, reject, reject, reject, route, route
respondWithDefaultHeader, respondWithDefaultHeaders, respondWithHeader, respondWithHeaders
withRangeSupport
ignoreTrailingSlash, path, path, path, path, path, path, pathEnd, pathEndOrSingleSlash, pathPrefix, pathPrefix, pathPrefix, pathPrefix, pathPrefix, pathPrefix, pathPrefixTest, pathPrefixTest, pathPrefixTest, pathPrefixTest, pathSingleSlash, pathSuffix, pathSuffix, pathSuffix, pathSuffix, pathSuffixTest, pathSuffixTest, pathSuffixTest, pathSuffixTest, rawPathPrefix, rawPathPrefix, rawPathPrefix, rawPathPrefix, rawPathPrefixTest, rawPathPrefixTest, rawPathPrefixTest, rawPathPrefixTest, redirectToNoTrailingSlashIfPresent, redirectToTrailingSlashIfMissing
parameter, parameter, parameterList, parameterList, parameterList, parameterMap, parameterMultiMap, parameterOptional, parameterOptional, parameterOrDefault, parameterRequiredValue
extractClientIP, rejectEmptyResponse, requestEntityEmpty, requestEntityPresent, selectPreferredLanguage, validate, withoutSizeLimit, withSizeLimit
delete, extractMethod, get, head, method, options, overrideMethodWithParameter, patch, post, put
completeWith, entity, handleWith, request
extractHost, host, host, host, host
attribute, optionalAttribute
checkSameOrigin, headerValue, headerValueByName, headerValueByType, headerValuePF, optionalHeaderValue, optionalHeaderValueByName, optionalHeaderValueByType, optionalHeaderValuePF
completeOrRecoverWith, onComplete, onComplete, onCompleteWithBreaker, onSuccess, onSuccess
formField, formField, formFieldList, formFieldList, formFieldList, formFieldMap, formFieldMultiMap, formFieldOptional, formFieldOptional
fileUpload, fileUploadAll, storeUploadedFile, storeUploadedFiles
defaultContentTypeResolver, defaultDirectoryRenderer, getFromBrowseableDirectories, getFromBrowseableDirectories, getFromBrowseableDirectories, getFromBrowseableDirectories, getFromBrowseableDirectories, getFromBrowseableDirectory, getFromBrowseableDirectory, getFromBrowseableDirectory, getFromBrowseableDirectory, getFromDirectory, getFromDirectory, getFromFile, getFromFile, getFromFile, getFromFile, getFromFile, getFromResource, getFromResource, getFromResource, getFromResource, getFromResourceDirectory, getFromResourceDirectory, getFromResourceDirectory, getFromResourceDirectory, listDirectoryContents, listDirectoryContents, listDirectoryContents, listDirectoryContents
handleExceptions, handleRejections
logRequest, logRequest, logRequest, logRequestResult, logRequestResultOptional, logResult, logResult, logResult
cookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, optionalCookie, setCookie, setCookie
decodeRequest, decodeRequestWith, decodeRequestWith, encodeResponse, encodeResponseWith, requestEncodedWith, responseEncodingAccepted, withPrecompressedMediaTypeSupport
conditional, conditional, conditional, conditional
cancelRejection, cancelRejections, cancelRejections, extract, extractActorSystem, extractDataBytes, extractEntity, extractExecutionContext, extractLog, extractMatchedPath, extractMaterializer, extractParserSettings, extractRequest, extractRequestContext, extractRequestEntity, extractSettings, extractStrictEntity, extractStrictEntity, extractUnmatchedPath, extractUri, mapInnerRoute, mapRejections, mapRequest, mapRequestContext, mapResponse, mapResponseEntity, mapResponseHeaders, mapRouteResult, mapRouteResultFuture, mapRouteResultPF, mapRouteResultWith, mapRouteResultWithPF, mapSettings, mapUnmatchedPath, pass, provide, recoverRejections, recoverRejectionsWith, toStrictEntity, toStrictEntity, withExecutionContext, withLog, withMaterializer, withSettings
public Route extractCredentials(java.util.function.Function<java.util.Optional<HttpCredentials>,Route> inner)
HttpCredentials
provided with the request's pekko.http.javadsl.model.headers.Authorization
header.inner
- (undocumented)public <T> Route authenticateBasic(java.lang.String realm, java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.Optional<T>> authenticator, java.util.function.Function<T,Route> inner)
Authenticator[T]
.
The given authenticator determines whether the credentials in the request are valid
and, if so, which user object to supply to the inner route.
Authentication is required in this variant, i.e. the request is rejected if [authenticator] returns Optional.empty.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateBasicPF(java.lang.String realm, scala.PartialFunction<java.util.Optional<SecurityDirectives.ProvidedCredentials>,T> authenticator, java.util.function.Function<T,Route> inner)
Authentication is required in this variant, i.e. the request is rejected if [authenticator] returns Optional.empty.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateBasicPFAsync(java.lang.String realm, scala.PartialFunction<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<T>> authenticator, java.util.function.Function<T,Route> inner)
Authentication is required in this variant, i.e. the request is rejected if [authenticator] returns Optional.empty.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateBasicOptional(java.lang.String realm, java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.Optional<T>> authenticator, java.util.function.Function<java.util.Optional<T>,Route> inner)
Authenticator[T]
.
The given authenticator determines whether the credentials in the request are valid
and, if so, which user object to supply to the inner route.
Authentication is optional in this variant.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateBasicAsync(java.lang.String realm, java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<java.util.Optional<T>>> authenticator, java.util.function.Function<T,Route> inner)
Authentication is required in this variant, i.e. the request is rejected if [authenticator] returns Optional.empty.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateBasicAsyncOptional(java.lang.String realm, java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<java.util.Optional<T>>> authenticator, java.util.function.Function<java.util.Optional<T>,Route> inner)
Authentication is optional in this variant.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateOAuth2(java.lang.String realm, java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.Optional<T>> authenticator, java.util.function.Function<T,Route> inner)
Authentication is required in this variant, i.e. the request is rejected if [authenticator] returns Optional.empty.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateOAuth2Optional(java.lang.String realm, java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.Optional<T>> authenticator, java.util.function.Function<java.util.Optional<T>,Route> inner)
Authentication is optional in this variant.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateOAuth2Async(java.lang.String realm, java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<java.util.Optional<T>>> authenticator, java.util.function.Function<T,Route> inner)
Authentication is required in this variant, i.e. the request is rejected if [authenticator] returns Optional.empty.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateOAuth2AsyncOptional(java.lang.String realm, java.util.function.Function<java.util.Optional<SecurityDirectives.ProvidedCredentials>,java.util.concurrent.CompletionStage<java.util.Optional<T>>> authenticator, java.util.function.Function<java.util.Optional<T>,Route> inner)
Authentication is optional in this variant.
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public <T> Route authenticateOrRejectWithChallenge(java.util.function.Function<java.util.Optional<HttpCredentials>,java.util.concurrent.CompletionStage<scala.util.Either<HttpChallenge,T>>> authenticator, java.util.function.Function<T,Route> inner)
pekko.http.javadsl.model.headers.Authorization
header of the request. If the function returns Right(user)
the user object is provided
to the inner route. If the function returns Left(challenge)
the request is rejected with an
pekko.http.javadsl.server.AuthenticationFailedRejection
that contains this challenge to be added to the response.authenticator
- (undocumented)inner
- (undocumented)public <C extends HttpCredentials,T> Route authenticateOrRejectWithChallenge(java.lang.Class<C> c, java.util.function.Function<java.util.Optional<C>,java.util.concurrent.CompletionStage<scala.util.Either<HttpChallenge,T>>> authenticator, java.util.function.Function<T,Route> inner)
authenticateOrRejectWithChallenge
but only applies the authenticator function with a certain type of credentials.c
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)public Route authorize(java.util.function.Supplier<java.lang.Object> check, java.util.function.Supplier<Route> inner)
pekko.http.javadsl.server.AuthorizationFailedRejection
.check
- (undocumented)inner
- (undocumented)public Route authorizeWithRequestContext(org.apache.pekko.japi.function.Function<RequestContext,java.lang.Object> check, java.util.function.Supplier<Route> inner)
pekko.http.javadsl.server.AuthorizationFailedRejection
.check
- (undocumented)inner
- (undocumented)public Route authorizeAsync(java.util.function.Supplier<java.util.concurrent.CompletionStage<java.lang.Object>> check, java.util.function.Supplier<Route> inner)
pekko.http.javadsl.server.AuthorizationFailedRejection
.check
- (undocumented)inner
- (undocumented)public Route authorizeAsyncWithRequestContext(org.apache.pekko.japi.function.Function<RequestContext,java.util.concurrent.CompletionStage<java.lang.Object>> check, java.util.function.Supplier<Route> inner)
authorize
.
If the CompletionStage
fails or is completed with false
authorization fails and the route is rejected with an pekko.http.javadsl.server.AuthorizationFailedRejection
.check
- (undocumented)inner
- (undocumented)