View Source Boruta.Oauth.Request (Boruta ssi core v0.1.0-beta.1)
Build an oauth request struct from given input.
Note: Input must have the shape or be a
%Plug.Conn{}
request.
Summary
Functions
Create request struct from an OAuth authorize request.
Create request struct from an OAuth introspect request.
See Boruta.Oauth.Request.Authorize.pushed_request/1
.
Create request struct from an OAuth revoke request.
Create request struct from an OAuth token request.
Functions
@spec authorize_request( conn :: Plug.Conn.t() | %{body_params: map()}, resource_owner :: struct() ) :: {:error, %Boruta.Oauth.Error{ error: :invalid_request, error_description: String.t(), format: nil, redirect_uri: nil, state: term(), status: :bad_request }} | {:ok, oauth_request :: %Boruta.Oauth.CodeRequest{ authorization_details: term(), client_id: term(), code_challenge: term(), code_challenge_method: term(), grant_type: term(), nonce: term(), prompt: term(), redirect_uri: term(), resource_owner: term(), response_type: term(), response_types: term(), scope: term(), state: term() } | %Boruta.Oauth.TokenRequest{ client_id: term(), grant_type: term(), nonce: term(), prompt: term(), redirect_uri: term(), resource_owner: term(), response_types: term(), scope: term(), state: term() } | %Boruta.Oauth.HybridRequest{ authorization_details: term(), client_id: term(), code_challenge: term(), code_challenge_method: term(), grant_type: term(), nonce: term(), prompt: term(), redirect_uri: term(), resource_owner: term(), response_mode: term(), response_types: term(), scope: term(), state: term() }}
Create request 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"
},
},
%User{...}
)
{:ok, %TokenRequest{...}}
@spec introspect_request( conn :: Plug.Conn.t() | %{optional(:req_headers) => list(), body_params: map()} ) :: {:error, %Boruta.Oauth.Error{ error: :invalid_request, error_description: String.t(), format: nil, redirect_uri: nil, state: term(), status: :bad_request }} | {:ok, request :: %Boruta.Oauth.IntrospectRequest{ client_authentication: term(), client_id: term(), token: term() }}
Create request struct from an OAuth introspect request.
Examples
iex>introspect_request(%{
body_params: %{
"token" => "token",
"client_id" => "client_id",
"client_secret" => "client_secret",
}
})
{:ok, %IntrospectRequest{...}}
@spec pushed_request(conn :: Plug.Conn.t() | %{body_params: map()}) :: {:ok, oauth_request :: %Boruta.Oauth.AuthorizationRequest{ client_authentication: term(), client_id: term(), code_challenge: term(), code_challenge_method: term(), expires_at: term(), id: term(), redirect_uri: term(), response_type: term(), scope: term(), state: term() }} | {:error, %Boruta.Oauth.Error{ error: :invalid_request, error_description: String.t(), format: nil, redirect_uri: nil, state: term(), status: :bad_request }}
See Boruta.Oauth.Request.Authorize.pushed_request/1
.
@spec revoke_request( conn :: Plug.Conn.t() | %{optional(:req_headers) => list(), body_params: map()} ) :: {:error, %Boruta.Oauth.Error{ error: :invalid_request, error_description: String.t(), format: nil, redirect_uri: nil, state: term(), status: :bad_request }} | {:ok, request :: %Boruta.Oauth.RevokeRequest{ client_authentication: term(), client_id: term(), token: term(), token_type_hint: term() }}
Create request struct from an OAuth revoke request.
Examples
iex>revoke_request(%{
body_params: %{
"token" => "token",
"client_id" => "client_id",
"client_secret" => "client_secret",
}
})
{:ok, %RevokeRequest{...}}
@spec token_request( conn :: Plug.Conn.t() | %{optional(:req_headers) => list(), body_params: map()} ) :: {:error, %Boruta.Oauth.Error{ error: :invalid_request, error_description: String.t(), format: nil, redirect_uri: nil, state: term(), status: :bad_request }} | {:ok, oauth_request :: %Boruta.Oauth.AuthorizationCodeRequest{ client_authentication: term(), client_id: term(), code: term(), code_verifier: term(), dpop: term(), grant_type: term(), redirect_uri: term() } | %Boruta.Oauth.ClientCredentialsRequest{ client_authentication: term(), client_id: term(), dpop: term(), grant_type: term(), scope: term() } | %Boruta.Oauth.AuthorizationCodeRequest{ client_authentication: term(), client_id: term(), code: term(), code_verifier: term(), dpop: term(), grant_type: term(), redirect_uri: term() } | %Boruta.Oauth.PreauthorizedCodeRequest{ client_id: term(), grant_type: term(), prompt: term(), redirect_uri: term(), resource_owner: term(), response_type: term(), scope: term(), state: term() } | %Boruta.Oauth.TokenRequest{ client_id: term(), grant_type: term(), nonce: term(), prompt: term(), redirect_uri: term(), resource_owner: term(), response_types: term(), scope: term(), state: term() } | %Boruta.Oauth.PasswordRequest{ client_authentication: term(), client_id: term(), grant_type: term(), password: term(), scope: term(), username: term() }}
Create request 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{...}}