I suggest to use session auth instead with require...
# ktor
c
I suggest to use session auth instead with required challenge mode
Copy code
application.install(Sessions) {
    cookie<TestSession>("S") // use cookie S to keep session
}
application.install(Authentication) {
    // setup auth provider to take session by type
    session<TestSession>("S") {
        challenge = SessionAuthChallenge.Ignore // Ignore, Unauthorized or Redirect
        validate { UserIdPrincipal(it.name) } 
    }
}

route("/user") {
    authenticate("S") {
        get("profile") {
            call.respondText("Profile for ${call.principal<UserIdPrincipal>()?.name}.")
        }
    }
}
// cc @Deactivated User @AdrianTodt @octylFractal @bdawg.io @Nikky
­čĹŹ 1