basic

Installs the basic Authentication provider. You can use basic authentication for logging in users and protecting specific routes. To learn how to configure it, see Basic authentication.

Report a problem


fun AuthenticationConfig.basic(name: String? = null, description: String? = null, configure: BasicAuthenticationProvider.Config.() -> Unit)(source)

Installs the basic Authentication provider with description. You can use basic authentication for logging in users and protecting specific routes. To learn how to configure it, see Basic authentication.

Report a problem


Creates a typed Basic authentication scheme with a principal type P.

data class User(val name: String)

val userAuth = basic<User>("user-auth") {
validate { credentials -> findUser(credentials.name, credentials.password) }
}

routing {
authenticateWith(userAuth) {
get("/me") { call.respondText(call.principal.name) }
}
}

Report a problem

Parameters

name

name that identifies the Basic authentication scheme.

configure

configures Basic authentication for this scheme.