diff --git a/lib/challenge_gov/login_gov.ex b/lib/challenge_gov/login_gov.ex index fcae1af3..5a9907ac 100644 --- a/lib/challenge_gov/login_gov.ex +++ b/lib/challenge_gov/login_gov.ex @@ -6,17 +6,18 @@ defmodule ChallengeGov.LoginGov do use HTTPoison.Base alias ChallengeGov.LoginGov.Token + @proxy_config Application.get_env(:httpoison, :proxy, []) def get_well_known_configuration(idp_authorize_url) do idp_authorize_url |> uri_join("/.well-known/openid-configuration") - |> get() + |> get([], proxy_options()) |> handle_response("Sorry, could not fetch well known configuration") end def get_public_key(jwks_uri) do jwks_uri - |> get() + |> get([], proxy_options()) |> handle_response("Sorry, could not fetch public key") |> case do {:ok, body} -> {:ok, body |> Map.fetch!("keys") |> List.first()} @@ -33,13 +34,13 @@ defmodule ChallengeGov.LoginGov do } token_endpoint - |> post(Poison.encode!(body), [{"Content-Type", "application/json"}]) + |> post(Poison.encode!(body), [{"Content-Type", "application/json"}], proxy_options()) |> handle_response("Sorry, could not exchange code") end def get_user_info(userinfo_endpoint, access_token) do userinfo_endpoint - |> get([{"Authorization", "Bearer " <> access_token}]) + |> get([{"Authorization", "Bearer " <> access_token}], proxy_options()) |> handle_response("Sorry, could not fetch userinfo") end @@ -122,4 +123,13 @@ defmodule ChallengeGov.LoginGov do def process_response_body(body) do Poison.decode!(body) end + + defp proxy_options do + if @proxy_config == [] do + [] + else + @proxy_config + end + end + end