Boruta v0.1.0-rc.1 Boruta.Oauth.Authorization.Base View Source

Base artifacts authorization

Link to this section Summary

Functions

Authorize the access token corresponding to the given params.

Authorize the client corresponding to the given params.

Authorize the code corresponding to the given params.

Authorize the resource owner corresponding to the given params.

Authorize the given scope according to the given client.

Link to this section Functions

Link to this function

access_token(list) View Source
access_token([{:value, String.t()}] | [{:refresh_token, String.t()}]) ::
  {:error,
   %Boruta.Oauth.Error{
     error: :invalid_access_token,
     error_description: String.t(),
     format: nil,
     redirect_uri: nil,
     status: :unauthorized
   }}
  | {:ok,
     %Boruta.Oauth.Token{
       __meta__: term(),
       client: term(),
       client_id: term(),
       expires_at: term(),
       id: term(),
       inserted_at: term(),
       redirect_uri: term(),
       refresh_token: term(),
       resource_owner: term(),
       resource_owner_id: term(),
       scope: term(),
       state: term(),
       type: term(),
       updated_at: term(),
       value: term()
     }}

Authorize the access token corresponding to the given params.

Examples

iex> access_token(value: "value")
{:ok, %Boruta.Oauth.Token{...}}
Link to this function

client(list) View Source
client(
  [id: String.t(), secret: String.t()]
  | [id: String.t(), redirect_uri: String.t()]
) ::
  {:ok,
   %Boruta.Oauth.Client{
     __meta__: term(),
     authorize_scope: term(),
     authorized_scopes: term(),
     id: term(),
     inserted_at: term(),
     redirect_uri: term(),
     secret: term(),
     updated_at: term()
   }}
  | {:error,
     %Boruta.Oauth.Error{
       error: :invalid_client,
       error_description: String.t(),
       format: nil,
       redirect_uri: nil,
       status: :unauthorized
     }}

Authorize the client corresponding to the given params.

Examples

iex> client(id: "id", secret: "secret")
{:ok, %Boruta.Oauth.Client{...}}
Link to this function

code(list) View Source
code(value: String.t(), redirect_uri: String.t()) ::
  {:error,
   %Boruta.Oauth.Error{
     error: :invalid_code,
     error_description: String.t(),
     format: nil,
     redirect_uri: nil,
     status: :bad_request
   }}
  | {:ok,
     %Boruta.Oauth.Token{
       __meta__: term(),
       client: term(),
       client_id: term(),
       expires_at: term(),
       id: term(),
       inserted_at: term(),
       redirect_uri: term(),
       refresh_token: term(),
       resource_owner: term(),
       resource_owner_id: term(),
       scope: term(),
       state: term(),
       type: term(),
       updated_at: term(),
       value: term()
     }}

Authorize the code corresponding to the given params.

Examples

iex> code(value: "value", redirect_uri: "redirect_uri")
{:ok, %Boruta.Oauth.Token{...}}
Link to this function

resource_owner(resource_owner) View Source
resource_owner(
  [{:id, String.t()}]
  | [email: String.t(), password: String.t()]
  | struct()
) ::
  {:error,
   %Boruta.Oauth.Error{
     error: :invalid_resource_owner,
     error_description: String.t(),
     format: nil,
     redirect_uri: nil,
     status: :unauthorized
   }}
  | {:ok, user :: struct()}

Authorize the resource owner corresponding to the given params.

Examples

iex> resource_owner(id: "id")
{:ok, %User{...}}
Link to this function

scope(list) View Source
scope(
  [scope: String.t(), client: Boruta.Oauth.Client.t()]
  | [scope: String.t(), token: Boruta.Oauth.Token.t()]
) :: {:ok, scope :: String.t()} | {:error, Boruta.Oauth.Error.t()}

Authorize the given scope according to the given client.

Examples

iex> scope(scope: "scope", client: %Boruta.Oauth.Client{...})
{:ok, "scope"}