https://kotlinlang.org logo
Title
t

Timur Atakishiev

07/20/2020, 7:21 AM
Hi all, is it any role management in ktor? Something like in Spring @hasRole or @preauthorized?
n

nschulzke

07/20/2020, 3:01 PM
I do not believe so (this could have changed in a recent release), but it's not too difficult to bootstrap one. I ended up writing a custom route selector that returns
RouteSelectorEvaluation.Constant
if the user has the role and
RouteSelectorEvaluation.Failed
otherwise. You could do a similar thing with interception. See: https://ktor.io/servers/features/routing.html The Interception heading particularly talks about verifying admin privileges.