-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
530 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
[ | ||
inputs: ["conformance/**/*.{ex,exs}"] | ||
inputs: [ | ||
"lib/**/*.ex", | ||
"test/**/*.exs", | ||
"conformance/**/*.{ex,exs}", | ||
".formatter.exs", | ||
"mix.exs" | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
erlang 26.0.2 | ||
rebar 3.22.1 | ||
elixir 1.15.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
defmodule Oidcc do | ||
@moduledoc "foo" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
defmodule Oidcc.ProviderConfiguration do | ||
@moduledoc """ | ||
Tooling to load and parse Openid Configuration | ||
""" | ||
|
||
import Record, only: [defrecordp: 3, extract: 2] | ||
|
||
defrecordp :configuration, | ||
:oidcc_provider_configuration, | ||
extract(:oidcc_provider_configuration, | ||
from: "include/oidcc_provider_configuration.hrl" | ||
) | ||
|
||
defstruct extract(:oidcc_provider_configuration, | ||
from: "include/oidcc_provider_configuration.hrl" | ||
) | ||
|
||
@typedoc """ | ||
Configuration Struct | ||
For details on the fields see: | ||
* https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata | ||
* https://datatracker.ietf.org/doc/html/draft-jones-oauth-discovery-01#section-4.1 | ||
""" | ||
@type t() :: %__MODULE__{ | ||
issuer: :uri_string.uri_string(), | ||
authorization_endpoint: :uri_string.uri_string(), | ||
token_endpoint: :uri_string.uri_string() | :undefined, | ||
userinfo_endpoint: :uri_string.uri_string() | :undefined, | ||
jwks_uri: :uri_string.uri_string() | :undefined, | ||
registration_endpoint: :uri_string.uri_string() | :undefined, | ||
scopes_supported: [String.t()] | :undefined, | ||
response_types_supported: [String.t()], | ||
response_modes_supported: [String.t()], | ||
grant_types_supported: [String.t()], | ||
acr_values_supported: [String.t()] | :undefined, | ||
subject_types_supported: [:pairwise | :public], | ||
id_token_signing_alg_values_supported: [String.t()], | ||
id_token_encryption_alg_values_supported: [String.t()] | :undefined, | ||
id_token_encryption_enc_values_supported: [String.t()] | :undefined, | ||
userinfo_signing_alg_values_supported: [String.t()] | :undefined, | ||
userinfo_encryption_alg_values_supported: [String.t()] | :undefined, | ||
userinfo_encryption_enc_values_supported: [String.t()] | :undefined, | ||
request_object_signing_alg_values_supported: [String.t()] | :undefined, | ||
request_object_encryption_alg_values_supported: [String.t()] | :undefined, | ||
request_object_encryption_enc_values_supported: [String.t()] | :undefined, | ||
token_endpoint_auth_methods_supported: [String.t()], | ||
token_endpoint_auth_signing_alg_values_supported: [String.t()] | :undefined, | ||
display_values_supported: [String.t()] | :undefined, | ||
claim_types_supported: [:normal | :aggregated | :distributed], | ||
claims_supported: [String.t()] | :undefined, | ||
service_documentation: :uri_string.uri_string() | :undefined, | ||
claims_locales_supported: [String.t()] | :undefined, | ||
ui_locales_supported: [String.t()] | :undefined, | ||
claims_parameter_supported: boolean(), | ||
request_parameter_supported: boolean(), | ||
request_uri_parameter_supported: boolean(), | ||
require_request_uri_registration: boolean(), | ||
op_policy_uri: :uri_string.uri_string() | :undefined, | ||
op_tos_uri: :uri_string.uri_string() | :undefined, | ||
revocation_endpoint: :uri_string.uri_string() | :undefined, | ||
revocation_endpoint_auth_methods_supported: [String.t()], | ||
revocation_endpoint_auth_signing_alg_values_supported: [String.t()] | :undefined, | ||
introspection_endpoint: :uri_string.uri_string() | :undefined, | ||
introspection_endpoint_auth_methods_supported: [String.t()], | ||
introspection_endpoint_auth_signing_alg_values_supported: [String.t()] | :undefined, | ||
code_challenge_methods_supported: [String.t()] | :undefined, | ||
extra_fields: %{String.t() => term()} | ||
} | ||
|
||
@doc false | ||
@spec record_to_struct(record :: :oidcc_provider_configuration.configuration()) :: t() | ||
def record_to_struct(record), do: struct!(__MODULE__, configuration(record)) | ||
|
||
@doc """ | ||
Load OpenID Configuration | ||
## Examples | ||
iex> {:ok, { | ||
...> %ProviderConfiguration{issuer: "https://accounts.google.com"}, | ||
...> _expiry | ||
...> }} = Oidcc.ProviderConfiguration.load_configuration("https://accounts.google.com") | ||
""" | ||
@spec load_configuration( | ||
issuer :: :uri_string.uri_string(), | ||
opts :: :oidcc_provider_configuration.opts() | ||
) :: | ||
{:ok, {configuration :: t(), expiry :: pos_integer()}} | ||
| {:error, :oidcc_provider_configuration.error()} | ||
def load_configuration(issuer, opts \\ %{}) do | ||
with {:ok, {configuration, expiry}} <- | ||
:oidcc_provider_configuration.load_configuration(issuer, opts) do | ||
{:ok, {record_to_struct(configuration), expiry}} | ||
end | ||
end | ||
end |
Oops, something went wrong.