ExOauth2Provider v0.2.1 ExOauth2Provider.OauthAccessGrants View Source

The boundary for the OauthAccessGrants system.

Link to this section Summary

Functions

Filter expired data

Filter revoked data

Gets a single access grant registered with an application

Checks if data has expired

Checks if data has been revoked

Revoke data

Link to this section Functions

Link to this function create_grant(resource_owner, application, attrs) View Source

Creates an access grant.

Examples

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

iex> create_grant(resource_owner, application, attrs)
{:error, %Ecto.Changeset{}}

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

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_grant_for(application, token) View Source

Gets a single access grant registered with an application.

Examples

iex> get_grant_for("c341a5c7b331ef076eb4954668d54f590e0009e06b81b100191aa22c93044f3d", "jE9dk")
%OauthAccessGrant{}

iex> get_grant_for("75d72f326a69444a9287ea264617058dbbfe754d7071b8eef8294cbf4e7e0fdc", "jE9dk")
** nil

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

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 put_scopes(changeset, 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{}}
Link to this function validate_scopes(changeset) View Source
Link to this function validate_scopes(changeset, server_scopes) View Source