Class SecurityDirectives
- java.lang.Object
-
- akka.http.javadsl.server.directives.BasicDirectives
-
- akka.http.javadsl.server.directives.CacheConditionDirectives
-
- akka.http.javadsl.server.directives.CodingDirectives
-
- akka.http.javadsl.server.directives.CookieDirectives
-
- akka.http.javadsl.server.directives.DebuggingDirectives
-
- akka.http.javadsl.server.directives.ExecutionDirectives
-
- akka.http.javadsl.server.directives.FileAndResourceDirectives
-
- akka.http.javadsl.server.directives.FileUploadDirectives
-
- akka.http.javadsl.server.directives.FormFieldDirectives
-
- akka.http.javadsl.server.directives.FutureDirectives
-
- akka.http.javadsl.server.directives.HeaderDirectives
-
- akka.http.javadsl.server.directives.AttributeDirectives
-
- akka.http.javadsl.server.directives.HostDirectives
-
- akka.http.javadsl.server.directives.MarshallingDirectives
-
- akka.http.javadsl.server.directives.MethodDirectives
-
- akka.http.javadsl.server.directives.MiscDirectives
-
- akka.http.javadsl.server.directives.ParameterDirectives
-
- akka.http.javadsl.server.directives.PathDirectives
-
- akka.http.javadsl.server.directives.RangeDirectives
-
- akka.http.javadsl.server.directives.RespondWithDirectives
-
- akka.http.javadsl.server.directives.RouteDirectives
-
- akka.http.javadsl.server.directives.SchemeDirectives
-
- akka.http.javadsl.server.directives.SecurityDirectives
-
- Direct Known Subclasses:
WebSocketDirectives
public abstract class SecurityDirectives extends SchemeDirectives
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SecurityDirectives.ProvidedCredentials
Represents HTTP Basic or OAuth2 authentication credentials supplied with a request.static class
SecurityDirectives.ProvidedCredentials$
-
Constructor Summary
Constructors Constructor Description SecurityDirectives()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 givenAuthenticator[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 givenAuthenticator[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>
RouteauthenticateOrRejectWithChallenge(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(akka.japi.function.Function<RequestContext,java.util.concurrent.CompletionStage<java.lang.Object>> check, java.util.function.Supplier<Route> inner)
Route
authorizeWithRequestContext(akka.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 presentHttpCredentials
provided with the request'sAuthorization
header.-
Methods inherited from class akka.http.javadsl.server.directives.SchemeDirectives
extractScheme, scheme
-
Methods inherited from class akka.http.javadsl.server.directives.RouteDirectives
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
-
Methods inherited from class akka.http.javadsl.server.directives.RespondWithDirectives
respondWithDefaultHeader, respondWithDefaultHeaders, respondWithHeader, respondWithHeaders
-
Methods inherited from class akka.http.javadsl.server.directives.RangeDirectives
withRangeSupport
-
Methods inherited from class akka.http.javadsl.server.directives.PathDirectives
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
-
Methods inherited from class akka.http.javadsl.server.directives.ParameterDirectives
parameter, parameter, parameterList, parameterList, parameterList, parameterMap, parameterMultiMap, parameterOptional, parameterOptional, parameterOrDefault, parameterRequiredValue
-
Methods inherited from class akka.http.javadsl.server.directives.MiscDirectives
extractClientIP, rejectEmptyResponse, requestEntityEmpty, requestEntityPresent, selectPreferredLanguage, validate, withoutSizeLimit, withSizeLimit
-
Methods inherited from class akka.http.javadsl.server.directives.MethodDirectives
delete, extractMethod, get, head, method, options, overrideMethodWithParameter, patch, post, put
-
Methods inherited from class akka.http.javadsl.server.directives.MarshallingDirectives
completeWith, entity, handleWith, request
-
Methods inherited from class akka.http.javadsl.server.directives.HostDirectives
extractHost, host, host, host, host
-
Methods inherited from class akka.http.javadsl.server.directives.AttributeDirectives
attribute, optionalAttribute
-
Methods inherited from class akka.http.javadsl.server.directives.HeaderDirectives
checkSameOrigin, headerValue, headerValueByName, headerValueByType, headerValuePF, optionalHeaderValue, optionalHeaderValueByName, optionalHeaderValueByType, optionalHeaderValuePF
-
Methods inherited from class akka.http.javadsl.server.directives.FutureDirectives
completeOrRecoverWith, onComplete, onComplete, onCompleteWithBreaker, onSuccess, onSuccess
-
Methods inherited from class akka.http.javadsl.server.directives.FormFieldDirectives
formField, formField, formFieldList, formFieldList, formFieldList, formFieldMap, formFieldMultiMap, formFieldOptional, formFieldOptional
-
Methods inherited from class akka.http.javadsl.server.directives.FileUploadDirectives
fileUpload, fileUploadAll, storeUploadedFile, storeUploadedFiles
-
Methods inherited from class akka.http.javadsl.server.directives.FileAndResourceDirectives
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
-
Methods inherited from class akka.http.javadsl.server.directives.ExecutionDirectives
handleExceptions, handleRejections
-
Methods inherited from class akka.http.javadsl.server.directives.DebuggingDirectives
logRequest, logRequest, logRequest, logRequestResult, logRequestResultOptional, logResult, logResult, logResult
-
Methods inherited from class akka.http.javadsl.server.directives.CookieDirectives
cookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, optionalCookie, setCookie, setCookie
-
Methods inherited from class akka.http.javadsl.server.directives.CodingDirectives
decodeRequest, decodeRequestWith, decodeRequestWith, encodeResponse, encodeResponseWith, requestEncodedWith, responseEncodingAccepted, withPrecompressedMediaTypeSupport
-
Methods inherited from class akka.http.javadsl.server.directives.CacheConditionDirectives
conditional, conditional, conditional, conditional
-
Methods inherited from class akka.http.javadsl.server.directives.BasicDirectives
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
-
-
-
-
Method Detail
-
extractCredentials
public Route extractCredentials(java.util.function.Function<java.util.Optional<HttpCredentials>,Route> inner)
Extracts the potentially presentHttpCredentials
provided with the request'sAuthorization
header.- Parameters:
inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateBasic
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)
Wraps the inner route with Http Basic authentication support using a givenAuthenticator[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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateBasicPF
public <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. 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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateBasicPFAsync
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)
Wraps the inner route with Http Basic authentication support. 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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateBasicOptional
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)
Wraps the inner route with Http Basic authentication support using a givenAuthenticator[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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateBasicAsync
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)
Wraps the inner route with Http Basic authentication support. 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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateBasicAsyncOptional
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)
Wraps the inner route with Http Basic authentication support. 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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateOAuth2
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)
A directive that wraps the inner route with OAuth2 Bearer Token authentication support. 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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateOAuth2Optional
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)
A directive that wraps the inner route with OAuth2 Bearer Token authentication support. 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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateOAuth2Async
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)
A directive that wraps the inner route with OAuth2 Bearer Token authentication support. 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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateOAuth2AsyncOptional
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)
A directive that wraps the inner route with OAuth2 Bearer Token authentication support. 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.
- Parameters:
realm
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateOrRejectWithChallenge
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)
Lifts an authenticator function into a directive. The authenticator function gets passed in credentials from theAuthorization
header of the request. If the function returnsRight(user)
the user object is provided to the inner route. If the function returnsLeft(challenge)
the request is rejected with anAuthenticationFailedRejection
that contains this challenge to be added to the response.- Parameters:
authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authenticateOrRejectWithChallenge
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)
Lifts an authenticator function into a directive. Same asauthenticateOrRejectWithChallenge
but only applies the authenticator function with a certain type of credentials.- Parameters:
c
- (undocumented)authenticator
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authorize
public Route authorize(java.util.function.Supplier<java.lang.Object> check, java.util.function.Supplier<Route> inner)
Applies the given authorization check to the request. If the check fails the route is rejected with anAuthorizationFailedRejection
.- Parameters:
check
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authorizeWithRequestContext
public Route authorizeWithRequestContext(akka.japi.function.Function<RequestContext,java.lang.Object> check, java.util.function.Supplier<Route> inner)
Applies the given authorization check to the request. If the check fails the route is rejected with anAuthorizationFailedRejection
.- Parameters:
check
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authorizeAsync
public 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. If the check fails the route is rejected with anAuthorizationFailedRejection
.- Parameters:
check
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
authorizeAsyncWithRequestContext
public Route authorizeAsyncWithRequestContext(akka.japi.function.Function<RequestContext,java.util.concurrent.CompletionStage<java.lang.Object>> check, java.util.function.Supplier<Route> inner)
Asynchronous version ofauthorize(java.util.function.Supplier<java.lang.Object>,java.util.function.Supplier<akka.http.javadsl.server.Route>)
. If theCompletionStage
fails or is completed withfalse
authorization fails and the route is rejected with anAuthorizationFailedRejection
.- Parameters:
check
- (undocumented)inner
- (undocumented)- Returns:
- (undocumented)
-
-