optionalAuthenticate
Authenticates a request by checking credentials supplied in the request and extracts a value representing the authenticated principal, or None if no credentials were supplied.
Signature
def optionalAuthenticate[T](auth: ⇒ Future[Authentication[T]])(implicit executor: ExecutionContext): Directive1[Option[T]]
def optionalAuthenticate[T](auth: ContextAuthenticator[T])(implicit executor: ExecutionContext): Directive1[Option[T]]
The signature shown is simplified, the real signature uses magnets. [1]
[1] | See The Magnet Pattern for an explanation of magnet-based overloading. |
Description
The optionalAuthenticate
directive is similar to the authenticate
directive but always extracts an Option
value instead of rejecting the request if no credentials could be found.