ApiKeyAuth

interface ApiKeyAuth

Exposes functionality for a user to manage API keys under their control.

Properties

Link copied to clipboard
abstract val app: App

The App that this instance in associated with.

Link copied to clipboard
abstract val user: User

The User that this instance in associated with.

Functions

Link copied to clipboard
abstract suspend fun create(name: String): ApiKey

Creates a user API key that can be used to authenticate as the user. The value of the key must be persisted at this time as this is the only time it is visible. The key is enabled when created. It can be disabled by calling the disable method.

Link copied to clipboard
abstract suspend fun delete(id: BsonObjectId)

Deletes a specific API key created by the user. Returns silently if no key is deleted.

Link copied to clipboard
abstract suspend fun disable(id: BsonObjectId)

Deletes a specific API key created by the user. The function would complete normally if the provided key does not exist.

Link copied to clipboard
abstract suspend fun enable(id: BsonObjectId)

Enables a specific API key created by the user.

Link copied to clipboard
abstract suspend fun fetch(id: BsonObjectId): ApiKey?

Fetches a specific user API key associated with the user.

Link copied to clipboard
abstract suspend fun fetchAll(): List<ApiKey>

Fetches all API keys associated with the user. Returns an empty list if no key is found.