This is probably more of a generic scala question, but I figured the very
best scala developers are clearly found in the akka mailing list, right? :)
I would like my verifyScopes directive to magically find my parseScopes
function without me having to explicitly pass it as a parameter. If I do
pass it, it works. If I dont it fails with:
[error] found : akka.http.scaladsl.server.StandardRoute
[error] required: Set[models.OAuthScope]
[error] complete("All good")
implicit def parseScopes(scopeStr: String): Set[OAuthScope] =
scopeStr
.split(" ")
.flatMap(scopeFromString)
.toSet
def parseAuthHeaders(parseScopes: String => Set[OAuthScope]) =
authHeaders.tmap {
case (userId, orgId, scopes) =>
AuthHeaders(
userId = UUID.fromString(userId),
orgId = UUID.fromString(orgId),
scopes = parseScopes(scopes)
)
}
def verifyScopes(required: Set[OAuthScope])(implicit parser: String =>
Set[OAuthScope]): Directive1[AuthHeaders] =
parseAuthHeaders(parseScopes).flatMap {
case headers if OAuthScope.hasScopes(required, headers.scopes) =>
provide(headers)
case _ => reject(AuthorizationFailedRejection)
}
val route =
get {
verifyScopes(Set(MyScope)) { headers =>
complete("All good")
}
}
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.