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

Joris PZ

02/04/2022, 9:00 AM
I'm updating an plugin for authorization I made for Ktor 1.6 to the new 2.0.0 Plugin concept, but I am running into an issue I don't understand. Say I want plugin
Foo
to run after the existing
Authentication
plugin. When I try
Copy code
val Foo = createApplicationPlugin("Foo") {
    after(Authentication) {

    }
}
the line starting with
after
generates a compiler error:
Copy code
Type mismatch.
Required: io.ktor.server.application.Plugin<*, *, PluginInstance>
Found: io.ktor.server.auth.Authentication.Plugin
The supertype of
io.ktor.server.auth.Authentication.Plugin
is
ApplicationPlugin<Application, Configuration, Authentication>
. Now I am not strong on generics, but I guess this is indeed not a subtype of the required
io.ktor.server.application.Plugin<*, *, PluginInstance>
(Is this the same issue as you talk about here, @hhariri?) Is there any way to make my plugin run after the Authentication plugin?
a

Aleksei Tirman [JB]

02/04/2022, 9:16 AM
@Rustam Siniukov
r

Rustam Siniukov

02/21/2022, 3:46 PM
Oh, really sorry, but I haven’t seen this mention. We are reworking new plugins API and we will drop
after
/`before` blocks. Instead of them we will introduce hooks.
Authentication
plugin will provide a hook that you can use to run after it.
j

Joris PZ

02/22/2022, 7:09 AM
Ah great, thanks for the reply! I'll sit tight for now and wait for this to come out.
Hi @Rustam Siniukov, congrats on shipping 2.0! I have been looking in the documentation for the hook you mentioned, but no luck so far. Has it been implemented?
r

Rustam Siniukov

04/11/2022, 5:16 PM
yes, it’s called
AuthenticationChecked
👍 1
12 Views