Class SecurityDirectives

    • Constructor Detail

      • SecurityDirectives

        public SecurityDirectives()
    • Method Detail

      • extractCredentials

        public Route extractCredentials​(java.util.function.Function<java.util.Optional<HttpCredentials>,​Route> inner)
        Extracts the potentially present HttpCredentials provided with the request's Authorization 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 given 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.

        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 given 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.

        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 the 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 AuthenticationFailedRejection 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 as authenticateOrRejectWithChallenge 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 an AuthorizationFailedRejection.
        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 an AuthorizationFailedRejection.
        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 an AuthorizationFailedRejection.
        Parameters:
        check - (undocumented)
        inner - (undocumented)
        Returns:
        (undocumented)