We are mirgating to Ktor 2.0 and have a RoleAuthor...
# ktor
d
We are mirgating to Ktor 2.0 and have a RoleAuthorization Feature (now Pluging) that is registered on the pipeline after the
Authentication.Feature.AuthenticatePhase
phase. However, this phase does not exist anymore. According to the documentation there is a
CheckAuthentication
phase. Is there a specific constant that identifies this phase so I can register our plugin after this specific phase?
r
Please use
AuthenticationChecked
hook for that. You can use it in the new API with
on(AuthenticationChecked) { ...
or manually call
AuthenticationChecked.install(pipeline) { ... }
if you don’t want to migrate your plugin yet
d
Thanks, I will try this! :)
d
@Rustam Siniukov Ok, I'm going for the
AuthenticationChecked.install(...)
approach, because I'm working on a configuration call upon a route. However, I do wonder: in the
install
context, how do I indicate the pipeline is finished (i.e. should abort all ) when all that I have is the
ApplcationCall
? Is there some way to obtain the
PipelineContext
?
Or would
call.isHandled
achieve the same
?
It seems it does....
r
what do you try to achieve?
d
We have created a plugin for RoleAuthorization. During configuration you can provide it with a predicate containing the authorization logic when given a Role. Then you can configure on each route a
forRole
command, limiting that route to the given role. This method will configure a check on the pipeline with the before mentioned predicate and the given role.