A personal API token's row. The token itself is never stored.
Fields:
name– what the owner called it, so they can tell two aparttoken_hash– SHA-256 of the full token; the lookup keyhint– the first characters after the prefix, shown in lists so a token in a CI secret can be matched to its row without revealing ittoken_version– the owner'susers.token_versionat creation; a later password or email change leaves this behind and the token stops workingexpires_at– nil for a token that does not expire.auth.api_token_max_dayscan end a token sooner;Gamend.Accounts.ApiTokens.expires_at/1has the effective datelast_used_at– bumped at most once a minute
Summary
Functions
A new token's name and lifetime. user_id, token_hash, hint and
token_version are set by Gamend.Accounts.ApiTokens.create/2, never cast.
The lifetimes a token may be created with, in days; nil never expires. With
auth.api_token_max_days set, the choices stop at the cap (which is itself
one) and nil is gone.
auth.api_token_max_days, or nil when a token may live forever.
Types
@type t() :: %Gamend.Accounts.ApiToken{ __meta__: term(), expires_at: DateTime.t() | nil, expires_in_days: term(), hint: String.t() | nil, id: String.t() | nil, inserted_at: DateTime.t() | nil, last_used_at: DateTime.t() | nil, name: String.t() | nil, token_hash: binary() | nil, token_version: integer(), updated_at: DateTime.t() | nil, user: term(), user_id: String.t() | nil }
A personal API token's row.
Functions
@spec changeset(t(), map()) :: Ecto.Changeset.t()
A new token's name and lifetime. user_id, token_hash, hint and
token_version are set by Gamend.Accounts.ApiTokens.create/2, never cast.
@spec expiry_choices() :: [pos_integer() | nil]
The lifetimes a token may be created with, in days; nil never expires. With
auth.api_token_max_days set, the choices stop at the cap (which is itself
one) and nil is gone.
@spec max_days() :: pos_integer() | nil
auth.api_token_max_days, or nil when a token may live forever.