ExOauth2Provider v0.4.0 ExOauth2Provider.OauthAccessGrants View Source

The boundary for the OauthAccessGrants system.

Link to this section Summary

Link to this section Functions

Link to this function create_grant(resource_owner, application, attrs) View Source
create_grant(
  Ecto.Schema.t(),
  ExOauth2Provider.OauthApplications.OauthApplication.t(),
  map()
) ::
  {:ok, ExOauth2Provider.OauthAccessGrants.OauthAccessGrant.t()}
  | {:error, term()}

Creates an access grant.

Examples

iex> create_grant(resource_owner, application, attrs)
{:ok, %OauthAccessGrant{}}

iex> create_grant(resource_owner, application, attrs)
{:error, %Ecto.Changeset{}}
Link to this function filter_expired(data) View Source
filter_expired(Ecto.Schema.t()) :: Ecto.Schema.t() | nil

Filter expired data.

Examples

iex> filter_expired(%Data{expires_in: 7200, inserted_at: ~N[2017-04-04 19:21:22.292762], ...}}
%Data{}

iex> filter_expired(%Data{expires_in: 10, inserted_at: ~N[2017-04-04 19:21:22.292762], ...}}
nil
Link to this function filter_revoked(data) View Source
filter_revoked(Ecto.Schema.t()) :: Ecto.Schema.t() | nil

Filter revoked data.

Examples

iex> filter_revoked(%Data{revoked_at: nil, ...}}
%Data{}

iex> filter_revoked(%Data{revoked_at: ~N[2017-04-04 19:21:22.292762], ...}}
nil
Link to this function get_active_grant_for(application, token) View Source
get_active_grant_for(
  ExOauth2Provider.OauthApplications.OauthApplication.t(),
  binary()
) :: ExOauth2Provider.OauthAccessGrants.OauthAccessGrant.t() | nil

Gets a single access grant registered with an application.

Examples

iex> get_active_grant_for(application, "jE9dk")
%OauthAccessGrant{}

iex> get_active_grant_for(application, "jE9dk")
** nil
Link to this function is_expired?(arg1) View Source
is_expired?(Ecto.Schema.t() | nil) :: boolean()

Checks if data has expired.

Examples

iex> is_expired?(%Data{expires_in: 7200, inserted_at: ~N[2017-04-04 19:21:22.292762], ...}}
false

iex> is_expired?(%Data{expires_in: 10, inserted_at: ~N[2017-04-04 19:21:22.292762], ...}}
true

iex> is_expired?(%Data{expires_in: nil}}
false
Link to this function is_revoked?(arg1) View Source
is_revoked?(Ecto.Schema.t()) :: boolean()

Checks if data has been revoked.

Examples

iex> is_revoked?(%Data{revoked_at: nil, ...}}
false

iex> is_revoked?(%Data{revoked_at: ~N[2017-04-04 19:21:22.292762], ...}}
true
Link to this function parse_default_scope_string(server_scopes) View Source
parse_default_scope_string(binary() | nil) :: binary()
Link to this function put_scopes(changeset, default_server_scopes) View Source

Revoke data.

Examples

iex> revoke(data)
{:ok, %Data{revoked_at: ~N[2017-04-04 19:21:22.292762], ...}}

iex> revoke(invalid_data)
{:error, %Ecto.Changeset{}}

Same as revoke/1 but raises error.

Link to this function validate_scopes(changeset) View Source
validate_scopes(Ecto.Changeset.t()) :: Ecto.Changeset.t()
Link to this function validate_scopes(changeset, server_scopes) View Source