Created
February 9, 2018 22:17
-
-
Save bandrzejczak/d8a22b4a3d9a6204dd9425b7588769dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def bearerToken: Directive1[Option[String]] = | |
for { | |
authBearerHeader <- optionalHeaderValueByType(classOf[Authorization]).map(extractBearerToken) | |
xAuthCookie <- optionalCookie("X-Authorization-Token").map(_.map(_.value)) | |
} yield authBearerHeader.orElse(xAuthCookie) | |
private def extractBearerToken(authHeader: Option[Authorization]): Option[String] = | |
authHeader.collect { | |
case Authorization(OAuth2BearerToken(token)) => token | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment