https://kotlinlang.org logo
#ktor
Title
z

zpearce

08/14/2018, 10:45 PM
is there a way to get the currently selected
Route
from the
ApplicationCall
?
z

zpearce

08/15/2018, 3:26 PM
ah, RTFM 😄 thank you
👍 1
😆 1
c

cy

08/15/2018, 4:16 PM
@zpearce what is your usecase? what are you trying to lookup from the currently selected route?
z

zpearce

08/15/2018, 4:17 PM
I'm currently playing around with attaching metadata to routes indicating which jwt scopes are required to access the route. I don't have anything really working yet - still trying to wrap my head around it
c

cy

08/15/2018, 4:18 PM
Perhaps you need to do it similar to already existing auth
Similar to
Route.authenticate()
z

zpearce

08/15/2018, 4:21 PM
the jwt auth implementation gives me a validate function where I can verify the jwt, but it doesn't give me the ability to assign different required scopes to routes.
at first I thought I could write my own extension functions on
Route
(get, post, etc) that take a list of required jwt scopes. That metadata would need to be stored somewhere that is accessible in the
validate
function, where I could compare the scope claim of the incoming jwt against the list of required scopes for the current route
c

cy

08/15/2018, 4:23 PM
How man "scopes" do you have? Can't you simply register multiple JWT authenitcators for every scope ?
z

zpearce

08/15/2018, 4:25 PM
ahh, I think I see what you mean. Different named authenticators (all jwt based) that themselves keep the metadata about required scopes?
c

cy

08/15/2018, 4:25 PM
yes, exactly
however it wouldn't work if you have too many scopes
z

zpearce

08/15/2018, 4:25 PM
right
c

cy

08/15/2018, 4:25 PM
or if the list of scopes is dynamic
z

zpearce

08/15/2018, 4:25 PM
as of now my project doesn't have that many. I'll give that a try and see how I like it. Thanks for the idea
c

cy

08/15/2018, 4:32 PM
It looks like we need some kind markers to be passed with
configurationNames
that need to be available in verifiers. But this requires design, we can think about it
2 Views