ApiKeyAuthHandler

Server-side handler for AuthType.ApiKey, implementing AuthHandler.

Functions

Link copied to clipboard
context(auth: AuthType.ApiKey, _: Raise<Issue>)
open override fun authenticate(request: Request): Principal

Authenticates the given request by looking up its ApiKeyAuth header, rejecting missing, unknown, revoked, or expired keys, and returns the Principal (the key's owning user) on success.

Link copied to clipboard
context(auth: AuthType.ApiKey)
open override fun authRoutes(): RoutingHttpHandler

Standard authentication routes provided by the handler.

Link copied to clipboard
context(_: Raise<Issue>, auth: AuthType.ApiKey, principal: Principal)
fun createApiKey(request: ApiKeyRequestModel): ApiKeyCreatedModel

Creates a new API key owned by the currently authenticated principal. The raw key is only ever available in the returned ApiKeyCreatedModel; only its salted hash is persisted.

Link copied to clipboard
context(principal: Principal)
fun listApiKeys(): List<ApiKeyInfoModel>

Lists the API keys owned by the currently authenticated principal, excluding the raw key values.

Link copied to clipboard
context(_: Raise<Issue>, principal: Principal)
fun revokeApiKey(keyId: String)

Revokes the API key identified by keyId, provided it is owned by the currently authenticated principal.