Class SecurityDirectives
- Direct Known Subclasses:
WebSocketDirectives
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents HTTP Basic or OAuth2 authentication credentials supplied with a request.static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> RouteauthenticateBasic(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, Optional<T>> authenticator, Function<T, Route> inner) Wraps the inner route with Http Basic authentication support using a givenAuthenticator[T].<T> RouteauthenticateBasicAsync(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<Optional<T>>> authenticator, Function<T, Route> inner) Wraps the inner route with Http Basic authentication support.<T> RouteauthenticateBasicAsyncOptional(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<Optional<T>>> authenticator, Function<Optional<T>, Route> inner) Wraps the inner route with Http Basic authentication support.<T> RouteauthenticateBasicOptional(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, Optional<T>> authenticator, Function<Optional<T>, Route> inner) Wraps the inner route with Http Basic authentication support using a givenAuthenticator[T].<T> RouteauthenticateBasicPF(String realm, scala.PartialFunction<Optional<SecurityDirectives.ProvidedCredentials>, T> authenticator, Function<T, Route> inner) Wraps the inner route with Http Basic authentication support.<T> RouteauthenticateBasicPFAsync(String realm, scala.PartialFunction<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<T>> authenticator, Function<T, Route> inner) Wraps the inner route with Http Basic authentication support.<T> RouteauthenticateOAuth2(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, Optional<T>> authenticator, Function<T, Route> inner) A directive that wraps the inner route with OAuth2 Bearer Token authentication support.<T> RouteauthenticateOAuth2Async(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<Optional<T>>> authenticator, Function<T, Route> inner) A directive that wraps the inner route with OAuth2 Bearer Token authentication support.<T> RouteauthenticateOAuth2AsyncOptional(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<Optional<T>>> authenticator, Function<Optional<T>, Route> inner) A directive that wraps the inner route with OAuth2 Bearer Token authentication support.<T> RouteauthenticateOAuth2Optional(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, Optional<T>> authenticator, Function<Optional<T>, Route> inner) A directive that wraps the inner route with OAuth2 Bearer Token authentication support.<C extends HttpCredentials,T>
RouteauthenticateOrRejectWithChallenge(Class<C> c, Function<Optional<C>, CompletionStage<scala.util.Either<HttpChallenge, T>>> authenticator, Function<T, Route> inner) Lifts an authenticator function into a directive.<T> RouteauthenticateOrRejectWithChallenge(Function<Optional<HttpCredentials>, CompletionStage<scala.util.Either<HttpChallenge, T>>> authenticator, Function<T, Route> inner) Lifts an authenticator function into a directive.Applies the given authorization check to the request.authorizeAsync(Supplier<CompletionStage<Object>> check, Supplier<Route> inner) Applies the given authorization check to the request.authorizeAsyncWithRequestContext(org.apache.pekko.japi.function.Function<RequestContext, CompletionStage<Object>> check, Supplier<Route> inner) authorizeWithRequestContext(org.apache.pekko.japi.function.Function<RequestContext, Object> check, Supplier<Route> inner) Applies the given authorization check to the request.Extracts the potentially presentHttpCredentialsprovided with the request'spekko.http.javadsl.model.headers.Authorizationheader.Methods inherited from class org.apache.pekko.http.javadsl.server.directives.SchemeDirectives
extractScheme, schemeMethods inherited from class org.apache.pekko.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, routeMethods inherited from class org.apache.pekko.http.javadsl.server.directives.RespondWithDirectives
respondWithDefaultHeader, respondWithDefaultHeaders, respondWithHeader, respondWithHeadersMethods inherited from class org.apache.pekko.http.javadsl.server.directives.RangeDirectives
withRangeSupportMethods inherited from class org.apache.pekko.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, redirectToTrailingSlashIfMissingMethods inherited from class org.apache.pekko.http.javadsl.server.directives.ParameterDirectives
parameter, parameter, parameterList, parameterList, parameterList, parameterMap, parameterMultiMap, parameterOptional, parameterOptional, parameterOrDefault, parameterRequiredValueMethods inherited from class org.apache.pekko.http.javadsl.server.directives.MiscDirectives
extractClientIP, rejectEmptyResponse, requestEntityEmpty, requestEntityPresent, selectPreferredLanguage, validate, withoutSizeLimit, withSizeLimitMethods inherited from class org.apache.pekko.http.javadsl.server.directives.MethodDirectives
delete, extractMethod, get, head, method, options, overrideMethodWithParameter, patch, post, putMethods inherited from class org.apache.pekko.http.javadsl.server.directives.MarshallingDirectives
completeWith, entity, handleWith, requestMethods inherited from class org.apache.pekko.http.javadsl.server.directives.HostDirectives
extractHost, host, host, host, hostMethods inherited from class org.apache.pekko.http.javadsl.server.directives.AttributeDirectives
attribute, optionalAttributeMethods inherited from class org.apache.pekko.http.javadsl.server.directives.HeaderDirectives
checkSameOrigin, headerValue, headerValueByName, headerValueByType, headerValuePF, optionalHeaderValue, optionalHeaderValueByName, optionalHeaderValueByType, optionalHeaderValuePFMethods inherited from class org.apache.pekko.http.javadsl.server.directives.FutureDirectives
completeOrRecoverWith, onComplete, onComplete, onCompleteWithBreaker, onSuccess, onSuccessMethods inherited from class org.apache.pekko.http.javadsl.server.directives.FormFieldDirectives
formField, formField, formFieldList, formFieldList, formFieldList, formFieldMap, formFieldMultiMap, formFieldOptional, formFieldOptionalMethods inherited from class org.apache.pekko.http.javadsl.server.directives.FileUploadDirectives
fileUpload, fileUploadAll, storeUploadedFile, storeUploadedFilesMethods inherited from class org.apache.pekko.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, listDirectoryContentsMethods inherited from class org.apache.pekko.http.javadsl.server.directives.ExecutionDirectives
handleExceptions, handleRejectionsMethods inherited from class org.apache.pekko.http.javadsl.server.directives.DebuggingDirectives
logRequest, logRequest, logRequest, logRequestResult, logRequestResultOptional, logResult, logResult, logResultMethods inherited from class org.apache.pekko.http.javadsl.server.directives.CookieDirectives
cookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, optionalCookie, setCookie, setCookieMethods inherited from class org.apache.pekko.http.javadsl.server.directives.CodingDirectives
decodeRequest, decodeRequestWith, decodeRequestWith, encodeResponse, encodeResponseWith, requestEncodedWith, responseEncodingAccepted, withPrecompressedMediaTypeSupportMethods inherited from class org.apache.pekko.http.javadsl.server.directives.CacheConditionDirectives
conditional, conditional, conditional, conditionalMethods inherited from class org.apache.pekko.http.javadsl.server.directives.BasicDirectives
cancelRejection, cancelRejections, cancelRejections, extract, extractActorSystem, extractDataBytes, extractEntity, extractExecutionContext, extractLog, extractMatchedPath, extractMaterializer, extractParserSettings, extractRequest, extractRequestContext, extractRequestEntity, extractSettings, extractStrictEntity, extractStrictEntity, extractStrictEntity, extractStrictEntity, extractUnmatchedPath, extractUri, mapInnerRoute, mapRejections, mapRequest, mapRequestContext, mapResponse, mapResponseEntity, mapResponseHeaders, mapRouteResult, mapRouteResultFuture, mapRouteResultPF, mapRouteResultWith, mapRouteResultWithPF, mapSettings, mapUnmatchedPath, pass, provide, recoverRejections, recoverRejectionsWith, toStrictEntity, toStrictEntity, toStrictEntity, toStrictEntity, withExecutionContext, withLog, withMaterializer, withSettings
-
Constructor Details
-
SecurityDirectives
public SecurityDirectives()
-
-
Method Details
-
extractCredentials
Extracts the potentially presentHttpCredentialsprovided with the request'spekko.http.javadsl.model.headers.Authorizationheader.- Parameters:
inner- (undocumented)- Returns:
- (undocumented)
-
authenticateBasic
public <T> Route authenticateBasic(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, Optional<T>> authenticator, 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(String realm, scala.PartialFunction<Optional<SecurityDirectives.ProvidedCredentials>, T> authenticator, 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(String realm, scala.PartialFunction<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<T>> authenticator, 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(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, Optional<T>> authenticator, Function<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(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<Optional<T>>> authenticator, 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(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<Optional<T>>> authenticator, Function<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(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, Optional<T>> authenticator, 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(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, Optional<T>> authenticator, Function<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(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<Optional<T>>> authenticator, 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(String realm, Function<Optional<SecurityDirectives.ProvidedCredentials>, CompletionStage<Optional<T>>> authenticator, Function<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(Function<Optional<HttpCredentials>, CompletionStage<scala.util.Either<HttpChallenge, T>>> authenticator, Function<T, Route> inner) Lifts an authenticator function into a directive. The authenticator function gets passed in credentials from thepekko.http.javadsl.model.headers.Authorizationheader 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 anpekko.http.javadsl.server.AuthenticationFailedRejectionthat contains this challenge to be added to the response.- Parameters:
authenticator- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
authenticateOrRejectWithChallenge
public <C extends HttpCredentials,T> Route authenticateOrRejectWithChallenge(Class<C> c, Function<Optional<C>, CompletionStage<scala.util.Either<HttpChallenge, T>>> authenticator, Function<T, Route> inner) Lifts an authenticator function into a directive. Same asauthenticateOrRejectWithChallengebut only applies the authenticator function with a certain type of credentials.- Parameters:
c- (undocumented)authenticator- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
authorize
Applies the given authorization check to the request. If the check fails the route is rejected with anpekko.http.javadsl.server.AuthorizationFailedRejection.- Parameters:
check- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
authorizeWithRequestContext
public Route authorizeWithRequestContext(org.apache.pekko.japi.function.Function<RequestContext, Object> check, Supplier<Route> inner) Applies the given authorization check to the request. If the check fails the route is rejected with anpekko.http.javadsl.server.AuthorizationFailedRejection.- Parameters:
check- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
authorizeAsync
Applies the given authorization check to the request. If the check fails the route is rejected with anpekko.http.javadsl.server.AuthorizationFailedRejection.- Parameters:
check- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-
authorizeAsyncWithRequestContext
public Route authorizeAsyncWithRequestContext(org.apache.pekko.japi.function.Function<RequestContext, CompletionStage<Object>> check, Supplier<Route> inner) Asynchronous version ofauthorize(java.util.function.Supplier<java.lang.Object>,java.util.function.Supplier<org.apache.pekko.http.javadsl.server.Route>). If theCompletionStagefails or is completed withfalseauthorization fails and the route is rejected with anpekko.http.javadsl.server.AuthorizationFailedRejection.- Parameters:
check- (undocumented)inner- (undocumented)- Returns:
- (undocumented)
-