I wrote a custom authenticator, but the routes seem to be getting called without authentication anyways. Any ideas from the routing and the authentication pipeline snippets?
There’s not anything special about the AccountSessionAuthenticationProvider beside it extending from
io.ktor.auth.AuthenticationProvider
and it having the two configuration options on it
Copy code
val authenticate: suspend (SessionToken) -> Principal? = provider.authenticate
val loginRedirectProvider: (ApplicationCall.() -> Url)? = provider.loginRedirectProvider
bdawg.io
09/19/2018, 5:59 PM
Here’s the full implementation if it really does help
Copy code
class AccountSessionAuthenticationProvider(name: String?) : AuthenticationProvider(name) {
internal var loginRedirectProvider: (ApplicationCall.() -> Url)? = null
private set
internal var authenticate: suspend (SessionToken) -> Principal? = { null }
private set
fun redirectToLogin(provider: ApplicationCall.() -> Url) {
loginRedirectProvider = provider
}
fun validate(validate: suspend (SessionToken) -> Principal?) {
authenticate = validate
}
}
bdawg.io
09/19/2018, 6:02 PM
my account session authentication is pretty close to the BasicAuthenticationProvider in ktor-auth, the difference being credentials are fetched from a cookie on the ApplicationCall instead of the