Tucker Barbour
06/06/2022, 8:01 PM@Location("/") class index
@Location("/auth/{type?}") class login(val type: String = "")
@Location("/auth/{type}/callback") class callback(val type: String)
val loginProviders = listOf(
OAuthServerSettings.OAuth2ServerSettings(..),
OAuthServerSettings.OAuth2ServerSettings(..)
).associateBy { it.name }
fun Application.module() {
install(Authentication) {
oauth("oauth") {
providerLookup = {
loginProviders[application.locations.resolve<login>(login::class, this).type]
}
urlProvider = { p -> redirectUrl(callback(p.name), false) }
}
}
}
This is the gist with a bunch of other stuff left out. The key is begin able to map the url path to the name of the login provider. This ultimately allows a client to select which oauth provider to use. Any help or guidance would be appreciated.Aleksei Tirman [JB]
06/07/2022, 8:53 AMproviderLookup = {
val resources = application.plugin(Resources)
val resource = resources.resourcesFormat.decodeFromParameters(serializer<login>(), parameters)
loginProviders[resource.type]
}
Tucker Barbour
06/07/2022, 9:33 AM