I'm updating an plugin for authorization I made fo...
# ktor
j
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
@Rustam Siniukov
r
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
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
yes, it’s called
AuthenticationChecked
👍 1