trait SecurityDirectives extends AnyRef
Provides directives for securing an inner route using the standard Http authentication headers `WWW-Authenticate` and Authorization. Most prominently, HTTP Basic authentication and OAuth 2.0 Authorization Framework as defined in RFC 2617 and RFC 6750 respectively.
- Source
- SecurityDirectives.scala
- Grouped
- Alphabetic
- By Inheritance
- SecurityDirectives
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Type Members
- type AsyncAuthenticator[T] = (Credentials) => Future[Option[T]]
- type AsyncAuthenticatorPF[T] = PartialFunction[Credentials, Future[T]]
- type AuthenticationResult[+T] = Either[HttpChallenge, T]
The result of an HTTP authentication attempt is either the user object or an HttpChallenge to present to the browser.
- type Authenticator[T] = (Credentials) => Option[T]
- type AuthenticatorPF[T] = PartialFunction[Credentials, T]
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from SecurityDirectives toany2stringadd[SecurityDirectives] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (SecurityDirectives, B)
- Implicit
- This member is added by an implicit conversion from SecurityDirectives toArrowAssoc[SecurityDirectives] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def authenticateBasic[T](realm: String, authenticator: Authenticator[T]): AuthenticationDirective[T]
Wraps the inner route with Http Basic authentication support using a given
Authenticator[T]
.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. - def authenticateBasicAsync[T](realm: String, authenticator: AsyncAuthenticator[T]): AuthenticationDirective[T]
Wraps the inner route with Http Basic authentication support.
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.
- def authenticateBasicPF[T](realm: String, authenticator: AuthenticatorPF[T]): AuthenticationDirective[T]
A directive that wraps the inner route with Http Basic authentication support.
A directive that 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.
- def authenticateBasicPFAsync[T](realm: String, authenticator: AsyncAuthenticatorPF[T]): AuthenticationDirective[T]
A directive that wraps the inner route with Http Basic authentication support.
A directive that 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.
- def authenticateOAuth2[T](realm: String, authenticator: Authenticator[T]): AuthenticationDirective[T]
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
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.
- def authenticateOAuth2Async[T](realm: String, authenticator: AsyncAuthenticator[T]): AuthenticationDirective[T]
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
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.
- def authenticateOAuth2PF[T](realm: String, authenticator: AuthenticatorPF[T]): AuthenticationDirective[T]
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
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.
- def authenticateOAuth2PFAsync[T](realm: String, authenticator: AsyncAuthenticatorPF[T]): AuthenticationDirective[T]
A directive that wraps the inner route with OAuth2 Bearer Token authentication support.
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.
- def authenticateOrRejectWithChallenge[C <: HttpCredentials, T](authenticator: (Option[C]) => Future[AuthenticationResult[T]])(implicit arg0: ClassTag[C]): AuthenticationDirective[T]
Lifts an authenticator function into a directive.
Lifts an authenticator function into a directive. Same as
authenticateOrRejectWithChallenge
but only applies the authenticator function with a certain type of credentials. - def authenticateOrRejectWithChallenge[T](authenticator: (Option[HttpCredentials]) => Future[AuthenticationResult[T]]): AuthenticationDirective[T]
Lifts an authenticator function into a directive.
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 returnsLeft(challenge)
the request is rejected with an AuthenticationFailedRejection that contains this challenge to be added to the response. - def authorize(check: (RequestContext) => Boolean): Directive0
Applies the given authorization check to the request.
Applies the given authorization check to the request. If the check fails the route is rejected with an AuthorizationFailedRejection.
- def authorize(check: => Boolean): Directive0
Applies the given authorization check to the request.
Applies the given authorization check to the request. If the check fails the route is rejected with an AuthorizationFailedRejection.
- def authorizeAsync(check: (RequestContext) => Future[Boolean]): Directive0
Asynchronous version of authorize.
Asynchronous version of authorize. If the Future fails or is completed with
false
authorization fails and the route is rejected with an AuthorizationFailedRejection. - def authorizeAsync(check: => Future[Boolean]): Directive0
Asynchronous version of authorize.
Asynchronous version of authorize. If the Future fails or is completed with
false
authorization fails and the route is rejected with an AuthorizationFailedRejection. - def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def ensuring(cond: (SecurityDirectives) => Boolean, msg: => Any): SecurityDirectives
- Implicit
- This member is added by an implicit conversion from SecurityDirectives toEnsuring[SecurityDirectives] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (SecurityDirectives) => Boolean): SecurityDirectives
- Implicit
- This member is added by an implicit conversion from SecurityDirectives toEnsuring[SecurityDirectives] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): SecurityDirectives
- Implicit
- This member is added by an implicit conversion from SecurityDirectives toEnsuring[SecurityDirectives] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): SecurityDirectives
- Implicit
- This member is added by an implicit conversion from SecurityDirectives toEnsuring[SecurityDirectives] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def extractCredentials: Directive1[Option[HttpCredentials]]
Extracts the potentially present HttpCredentials provided with the request's Authorization header.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from SecurityDirectives toStringFormat[SecurityDirectives] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)
instead ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- def →[B](y: B): (SecurityDirectives, B)
- Implicit
- This member is added by an implicit conversion from SecurityDirectives toArrowAssoc[SecurityDirectives] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.