omkar-tenkale / ktor-role-based-auth

A simple yet powerful role based authorization plugin for ktor server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

io.ktor.server.application.DuplicatePluginException when using an RBAC route

nielsvanharen opened this issue · comments

whenever i add the rbac functions to a route, i get a DuplicatePluginException, when i check the code, it is trying to install the plugin on every request, why is this and how to solve it?

i.e.

fun Route.withAnyRole(roles: Set<Role>, build: suspend PipelineContext<Unit, ApplicationCall>.() -> Unit) {
    install(RoleBasedAuthPlugin) {
        any = roles.toSet()
    }
    handle { build() }
}