Packages
boruta
3.0.0-beta.4
3.0.0-beta.4
3.0.0-beta.3
3.0.0-beta.2
3.0.0-beta.1
2.3.6
2.3.5
2.3.4
2.3.3
2.3.2
2.3.1
2.3.0
2.2.2
2.2.1
2.2.0
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.1
2.0.0
2.0.0-rc.1
2.0.0-rc.0
1.2.1
1.2.0
1.1.0
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-rc.3
1.0.0-rc.2
1.0.0-rc.1
1.0.0-rc.0
0.2.1
0.2.0
0.1.1
0.1.0
0.1.0-rc.5
0.1.0-rc.4
0.1.0-rc.3
0.1.0-rc.2
0.1.0-rc.1
Core of an OAuth/OpenID Connect provider enabling authorization in your applications.
Current section
Files
Jump to
Current section
Files
lib/boruta/adapters/ecto/schemas/authorization_request.ex
defmodule Boruta.Ecto.AuthorizationRequest do
@moduledoc """
Ecto Adapter Request Schema
"""
use Ecto.Schema
import Ecto.Changeset
@type t :: %__MODULE__{
id: String.t(),
client_id: String.t(),
client_authentication: map(),
response_type: String.t(),
redirect_uri: String.t(),
scope: String.t(),
state: String.t(),
code_challenge: String.t(),
code_challenge_method: String.t(),
expires_at: integer(),
inserted_at: DateTime.t(),
updated_at: DateTime.t()
}
@primary_key {:id, Ecto.UUID, autogenerate: true}
@foreign_key_type :binary_id
@timestamps_opts type: :utc_datetime
schema "authorization_requests" do
field :client_id, :string
field :client_authentication, :map
field :response_type, :string
field :redirect_uri, :string
field :scope, :string
field :state, :string
field :code_challenge, :string
field :code_challenge_method, :string
field :expires_at, :integer
timestamps()
end
def create_changeset(request, attrs, client) do
request
|> cast(attrs, [
:client_id,
:client_authentication,
:response_type,
:redirect_uri,
:scope,
:state,
:code_challenge,
:code_challenge_method,
:expires_at
])
|> put_time_to_live(client)
end
defp put_time_to_live(changeset, client) do
expires_at = :os.system_time(:seconds) + client.authorization_request_ttl
change(changeset, %{expires_at: expires_at})
end
end