Boruta.Oauth.Token (Boruta core v1.0.2) View Source
Token schema. Representing both access tokens and codes.
Link to this section Summary
Functions
Determines if a token is expired
Returns an hexadecimal SHA512 hash of given string
Determines if a token is revoked.
Link to this section Types
Specs
t() :: %Boruta.Oauth.Token{
client: Boruta.Oauth.Client.t(),
code_challenge: String.t(),
code_challenge_hash: String.t(),
code_challenge_method: String.t(),
expires_at: integer(),
id: term(),
inserted_at: DateTime.t(),
redirect_uri: String.t(),
refresh_token: String.t(),
resource_owner: Boruta.Oauth.ResourceOwner.t() | nil,
revoked_at: DateTime.t(),
scope: String.t(),
state: String.t(),
sub: String.t(),
type: String.t(),
value: String.t()
}
Link to this section Functions
Specs
expired?(%Boruta.Oauth.Token{
client: term(),
code_challenge: term(),
code_challenge_hash: term(),
code_challenge_method: term(),
expires_at: integer(),
id: term(),
inserted_at: term(),
redirect_uri: term(),
refresh_token: term(),
resource_owner: term(),
revoked_at: term(),
scope: term(),
state: term(),
sub: term(),
type: term(),
value: term()
}) :: :ok | {:error, String.t()}
Determines if a token is expired
Examples
iex> expired?(%Boruta.Oauth.Token{expires_at: 1638316800}) # 1st january 2021
:ok
iex> expired?(%Boruta.Oauth.Token{expires_at: 0}) # 1st january 1970
{:error, "Token expired."}
Specs
Returns an hexadecimal SHA512 hash of given string
Examples
iex> hash("foo")
"F7FBBA6E0636F890E56FBBF3283E524C6FA3204AE298382D624741D0DC6638326E282C41BE5E4254D8820772C5518A2C5A8C0C7F7EDA19594A7EB539453E1ED7"
Specs
Determines if a token is revoked.
Examples
iex> revoked?(%Boruta.Oauth.Token{revoked_at: nil})
:ok
iex> revoked?(%Boruta.Oauth.Token{})
{:error, "Token revoked."}