Principal
See Security — Core concepts for an overview.
Principal
Marker interface for the authenticated entity, requiring a stable reference.
- Declaration
interface Principal {
val ref: PrincipalRef
}
data class PrincipalRef(val type: String, val id: String) {
override fun toString(): String = "$type:$id" // e.g. "user:abc123"
}
Request.principal
Returns the Principal attached to the request via AuthenticationFilter
(or withPrincipal()), or null when no principal is attached.
- Declaration
val Request.principal: Principal?
Request.hasPrincipal
True when a principal is attached to the request.
- Declaration
val Request.hasPrincipal: Boolean
Request.withPrincipal
Returns a copy of the request with the given principal attached. Primarily intended for testing
handlers that depend on an authenticated principal — in production code the principal is set by
AuthenticationFilter.
- Declaration
fun Request.withPrincipal(principal: Principal): Request