attempting to migrate to Ktor 2: any idea what hap...
# ktor
p
attempting to migrate to Ktor 2: any idea what happened to
Authentication.ChallengePhase
?
i see:
Copy code
internal object ChallengeHook : Hook<suspend (ApplicationCall) -> Unit> {
    internal val ChallengePhase: PipelinePhase = PipelinePhase("Challenge")
but it's
internal
😞
r
yeah I also had the same issue when implementing role system, haven't solved it so far 😞
😞 1
p
PipelinePhase
isn't a data class either... so assuming just redeclaring an instance won't compare equally the internal one?
r
Copy code
PipelinePhase("Challenge")
creating my own instance of it might actually work, but I have no idea how to test it. the interceptor triggers and there is no excption being thrown
it would also be sufficient when the interceptor fires after the authentication in general, doesnt have to be the Challenge phase, does it?
a
@Rustam Siniukov
r
@Peter Can you share your use case, please?
@Ron S for role based auth you can use
AuthenticationChecked
hook
r
Thanks @Rustam Siniukov I think I got it to work. Here's my snippet @Peter
Copy code
fun Route.authorization(build: Route.() -> Unit): Route {
    val route = createChild(CustomSelector())
    val plugin = createRouteScopedPlugin("CustomAuthorization") {
        on(AuthenticationChecked) { call ->
            val principal = call.authentication.principal
            // custom logic
        }
    }
    route.install(plugin)
    route.build()
    return route
}
👍 1
p
my use case is also a RBAC feature/plugin... thanks for the example @Ron S - i'll take a look soon, traveling today