19 lines
484 B
Kotlin
19 lines
484 B
Kotlin
package be.vandewalleh.auth
|
|
|
|
import be.vandewalleh.kodein
|
|
import io.ktor.application.*
|
|
import io.ktor.auth.*
|
|
import io.ktor.auth.jwt.*
|
|
import org.kodein.di.generic.instance
|
|
|
|
fun Application.authenticationModule() {
|
|
install(Authentication) {
|
|
jwt {
|
|
val simpleJwt by kodein.instance<SimpleJWT>()
|
|
verifier(simpleJwt.verifier)
|
|
validate {
|
|
UserIdPrincipal(it.payload.getClaim("name").asString())
|
|
}
|
|
}
|
|
}
|
|
} |