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

David Stibbe

04/17/2022, 3:08 PM
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

Rustam Siniukov

04/18/2022, 8:21 AM
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

David

04/18/2022, 8:25 AM
Thanks, I will try this! :)
d

David Stibbe

04/18/2022, 9:05 AM
@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

Rustam Siniukov

04/19/2022, 11:24 AM
what do you try to achieve?
d

David Stibbe

04/19/2022, 6:33 PM
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.
15 Views