Boruta core v0.1.0-rc.5 Boruta.Oauth.Request View Source
Build a business structs from given input.
Note : Input must have the shape or be a %Plug.Conn{}
request.
Link to this section Summary
Functions
Create business struct from an OAuth authorize request.
Create business struct from an OAuth introspect request.
Create business struct from an OAuth token request.
Link to this section Functions
Link to this function
authorize_request(map)
View Sourceauthorize_request(conn :: map()) :: {:error, %Boruta.Oauth.Error{ error: :invalid_request, error_description: String.t(), format: nil, redirect_uri: nil, status: :bad_request }} | {:ok, oauth_request :: %Boruta.Oauth.CodeRequest{ client_id: term(), redirect_uri: term(), resource_owner: term(), scope: term(), state: term() } | %Boruta.Oauth.TokenRequest{ client_id: term(), redirect_uri: term(), resource_owner: term(), scope: term(), state: term() }}
Create business struct from an OAuth authorize request.
Note : resource owner must be provided as current_user assigns.
Examples
iex>authorize_request(%{
query_params: %{
"response_type" => "token",
"client_id" => "client_id",
"redirect_uri" => "redirect_uri"
},
assigns: %{current_user: %User{...}}
})
{:ok, %TokenRequest{...}}
Link to this function
introspect_request(arg1)
View Sourceintrospect_request(conn :: map() | map()) :: {:error, %Boruta.Oauth.Error{ error: :invalid_request, error_description: String.t(), format: nil, redirect_uri: nil, status: :bad_request }} | {:ok, introspect_request :: %Boruta.Oauth.IntrospectRequest{ client_id: term(), client_secret: term(), token: term() }}
Create business struct from an OAuth introspect request.
Examples
iex>introspect_request(%{
body_params: %{
"token" => "token",
"client_id" => "client_id",
"client_secret" => "client_secret",
}
})
{:ok, %IntrospectRequest{...}}
Link to this function
token_request(arg1)
View Sourcetoken_request(conn :: Plug.Conn.t() | map()) :: {:error, %Boruta.Oauth.Error{ error: :invalid_request, error_description: String.t(), format: nil, redirect_uri: nil, status: :bad_request }} | {:ok, oauth_request :: %Boruta.Oauth.AuthorizationCodeRequest{ client_id: term(), code: term(), redirect_uri: term() } | %Boruta.Oauth.ClientCredentialsRequest{ client_id: term(), client_secret: term(), scope: term() } | %Boruta.Oauth.AuthorizationCodeRequest{ client_id: term(), code: term(), redirect_uri: term() } | %Boruta.Oauth.TokenRequest{ client_id: term(), redirect_uri: term(), resource_owner: term(), scope: term(), state: term() } | %Boruta.Oauth.PasswordRequest{ client_id: term(), client_secret: term(), password: term(), scope: term(), username: term() }}
Create business struct from an OAuth token request.
Examples
iex>token_request(%{
body_params: %{
"grant_type" => "client_credentials",
"client_id" => "client_id",
"client_secret" => "client_secret"
}
})
{:ok, %ClientCredentialsRequest{...}}