All Downloads are FREE. Search and download functionalities are using the official Maven repository.

invirt.http4k.security.authentication.Authentication.kt Maven / Gradle / Ivy

There is a newer version: 0.10.11
Show newest version
package invirt.http4k.security.authentication

import invirt.http4k.InvirtRequestContext
import org.http4k.core.Request
import org.http4k.lens.RequestContextKey

private val authenticationContextKey = RequestContextKey.optional>(InvirtRequestContext.requestContexts)

data class Authentication

(val principal: P, val tokens: T) { companion object { internal val current: Authentication<*, *>? get() = authThreadLocal.get() } } internal var Request.authentication: Authentication<*, *>? get() = authenticationContextKey[this] set(auth) { auth?.let { authThreadLocal.set(auth) } ?: authThreadLocal.remove() authenticationContextKey[this] = auth } val Request.principal: Principal? get() = this.authentication?.principal





© 2015 - 2024 Weber Informatics LLC | Privacy Policy