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