Class SecurityDirectives
- Direct Known Subclasses:
- WebSocketDirectives
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classRepresents HTTP Basic or OAuth2 authentication credentials supplied with a request.static class
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.SchemeDirectivesextractScheme, schemeMethods inherited from class org.apache.pekko.http.javadsl.server.directives.RouteDirectivescomplete, 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.RespondWithDirectivesrespondWithDefaultHeader, respondWithDefaultHeaders, respondWithHeader, respondWithHeadersMethods inherited from class org.apache.pekko.http.javadsl.server.directives.RangeDirectiveswithRangeSupportMethods inherited from class org.apache.pekko.http.javadsl.server.directives.PathDirectivesignoreTrailingSlash, 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.ParameterDirectivesparameter, parameter, parameterList, parameterList, parameterList, parameterMap, parameterMultiMap, parameterOptional, parameterOptional, parameterOrDefault, parameterRequiredValueMethods inherited from class org.apache.pekko.http.javadsl.server.directives.MiscDirectivesextractClientIP, rejectEmptyResponse, requestEntityEmpty, requestEntityPresent, selectPreferredLanguage, validate, withoutSizeLimit, withSizeLimitMethods inherited from class org.apache.pekko.http.javadsl.server.directives.MethodDirectivesdelete, extractMethod, get, head, method, options, overrideMethodWithParameter, patch, post, putMethods inherited from class org.apache.pekko.http.javadsl.server.directives.MarshallingDirectivescompleteWith, entity, handleWith, requestMethods inherited from class org.apache.pekko.http.javadsl.server.directives.HostDirectivesextractHost, host, host, host, hostMethods inherited from class org.apache.pekko.http.javadsl.server.directives.AttributeDirectivesattribute, optionalAttributeMethods inherited from class org.apache.pekko.http.javadsl.server.directives.HeaderDirectivescheckSameOrigin, headerValue, headerValueByName, headerValueByType, headerValuePF, optionalHeaderValue, optionalHeaderValueByName, optionalHeaderValueByType, optionalHeaderValuePFMethods inherited from class org.apache.pekko.http.javadsl.server.directives.FutureDirectivescompleteOrRecoverWith, onComplete, onComplete, onCompleteWithBreaker, onSuccess, onSuccessMethods inherited from class org.apache.pekko.http.javadsl.server.directives.FormFieldDirectivesformField, formField, formFieldList, formFieldList, formFieldList, formFieldMap, formFieldMultiMap, formFieldOptional, formFieldOptionalMethods inherited from class org.apache.pekko.http.javadsl.server.directives.FileUploadDirectivesfileUpload, fileUploadAll, storeUploadedFile, storeUploadedFilesMethods inherited from class org.apache.pekko.http.javadsl.server.directives.FileAndResourceDirectivesdefaultContentTypeResolver, 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.ExecutionDirectiveshandleExceptions, handleRejectionsMethods inherited from class org.apache.pekko.http.javadsl.server.directives.DebuggingDirectiveslogRequest, logRequest, logRequest, logRequestResult, logRequestResultOptional, logResult, logResult, logResultMethods inherited from class org.apache.pekko.http.javadsl.server.directives.CookieDirectivescookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, deleteCookie, optionalCookie, setCookie, setCookieMethods inherited from class org.apache.pekko.http.javadsl.server.directives.CodingDirectivesdecodeRequest, decodeRequestWith, decodeRequestWith, encodeResponse, encodeResponseWith, requestEncodedWith, responseEncodingAccepted, withPrecompressedMediaTypeSupportMethods inherited from class org.apache.pekko.http.javadsl.server.directives.CacheConditionDirectivesconditional, conditional, conditional, conditionalMethods inherited from class org.apache.pekko.http.javadsl.server.directives.BasicDirectivescancelRejection, 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- 
SecurityDirectivespublic SecurityDirectives()
 
- 
- 
Method Details- 
extractCredentialsExtracts the potentially presentHttpCredentialsprovided with the request'spekko.http.javadsl.model.headers.Authorizationheader.- Parameters:
- inner- (undocumented)
- Returns:
- (undocumented)
 
- 
authenticateBasicpublic <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)
 
- 
authenticateBasicPFpublic <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)
 
- 
authenticateBasicPFAsyncpublic <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)
 
- 
authenticateBasicOptionalpublic <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)
 
- 
authenticateBasicAsyncpublic <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)
 
- 
authenticateBasicAsyncOptionalpublic <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)
 
- 
authenticateOAuth2public <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)
 
- 
authenticateOAuth2Optionalpublic <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)
 
- 
authenticateOAuth2Asyncpublic <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)
 
- 
authenticateOAuth2AsyncOptionalpublic <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)
 
- 
authenticateOrRejectWithChallengepublic <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)
 
- 
authenticateOrRejectWithChallengepublic <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)
 
- 
authorizeApplies 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)
 
- 
authorizeWithRequestContextpublic 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)
 
- 
authorizeAsyncApplies 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)
 
- 
authorizeAsyncWithRequestContextpublic 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)
 
 
-