CPub.Web.Authorization (CPub v0.3.0) View Source
An OAuth 2.0 Authorization.
An CPub.Web.Authorization.Authorization
includes a code that can be used to
obtain a CPub.Web.Authorization.Token
. The token can be used to access
resources. The Authorization can only be used once and is valid for only 10
minutes after creation.
The CPub.Web.Authorization.Authorization
remains in the database and can be
reused to refresh a token (see https://tools.ietf.org/html/rfc6749#section-6)
until it is explicitly revoked (deleted). On deletion all
CPub.Web.Authorization.Token
s that were created based on the Authorization
are revoked (deleted).
Protected routes have a authorization assigned (see
CPub.Web.Authorization.AuthorizationPlug
).
Link to this section Summary
Functions
Create a new Authorization
for the given user
and scope without
associating a client.
Create a new Authorization
for the given user
, client
and scope
.
Returns true if the Authorization
has expired (has been created more than 10 minutes ago).
Get an authorization by id.
Get an authorization by the code.
Get an authorization by the refresh token.
Mark the authorization code as used.
Returns the number of seconds the Authorization code is valid for after initial creation.
Link to this section Types
Specs
Link to this section Functions
Specs
create(CPub.User.t(), [String.t()]) :: {:ok, t()} | {:error, any()}
Create a new Authorization
for the given user
and scope without
associating a client.
Specs
create(CPub.User.t(), CPub.Web.Authorization.Client.t(), [String.t() | atom()]) :: {:ok, t()} | {:error, any()}
Create a new Authorization
for the given user
, client
and scope
.
Specs
expired?(t()) :: bool()
Returns true if the Authorization
has expired (has been created more than 10 minutes ago).
Specs
Get an authorization by id.
Specs
Get an authorization by the code.
Specs
Get an authorization by the refresh token.
Specs
Mark the authorization code as used.
Specs
valid_for() :: non_neg_integer()
Returns the number of seconds the Authorization code is valid for after initial creation.