Skip to content

Commit

Permalink
Fix HTTP client default on runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraBeatris committed Mar 30, 2024
1 parent 1d074a2 commit 16fbd85
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/oidc/provider_configuration/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule ShinAuth.OIDC.ProviderConfiguration.Client do
alias ShinAuth.OIDC.ProviderConfiguration.Metadata

def fetch_discovery_metadata(discovery_endpoint, config \\ default_config()) do
http_client = Keyword.get(config, :http_client)
http_client = get_http_client(config)

discovery_endpoint
|> http_client.get()
Expand Down Expand Up @@ -48,7 +48,7 @@ defmodule ShinAuth.OIDC.ProviderConfiguration.Client do
config \\ default_config()
)
when is_binary(authorization_endpoint) do
http_client = Keyword.get(config, :http_client)
http_client = get_http_client(config)

response =
authorization_endpoint
Expand Down Expand Up @@ -84,7 +84,7 @@ defmodule ShinAuth.OIDC.ProviderConfiguration.Client do
config \\ default_config()
)
when is_binary(token_endpoint) do
http_client = Keyword.get(config, :http_client)
http_client = get_http_client(config)

response =
token_endpoint
Expand Down Expand Up @@ -122,7 +122,7 @@ defmodule ShinAuth.OIDC.ProviderConfiguration.Client do
config \\ default_config()
)
when is_binary(jwks_uri) do
http_client = Keyword.get(config, :http_client)
http_client = get_http_client(config)

response =
jwks_uri
Expand Down Expand Up @@ -172,4 +172,8 @@ defmodule ShinAuth.OIDC.ProviderConfiguration.Client do
end

defp default_config, do: Application.get_env(:shin_auth, :provider_configuration_fetcher)

defp get_http_client(config) do
Keyword.get(config, :http_client, HTTPoison)
end
end

0 comments on commit 16fbd85

Please sign in to comment.