Fix OIDC error matching to catch token and verify failures (#1427)

The phoenix process crashes with 'String.chars not implemented for ...`
when the `fetch_tokens` or `verify` function fails in `openid_connect`.
This is due to a change in the error response tuple that wasn't
reflected in the error matches in `auth_controller.exs`.

Fixes #1426
This commit is contained in:
Jamil
2023-02-15 10:40:01 -08:00
committed by GitHub
parent 4819013e50
commit e3ba585043
2 changed files with 6 additions and 13 deletions

View File

@@ -85,21 +85,14 @@ defmodule FzHttpWeb.AuthController do
|> redirect(to: ~p"/")
end
else
{:error, reason} ->
msg = "OpenIDConnect Error: #{reason}"
Logger.warn(msg)
# Error verifying state, claims or fetching tokens
{:error, error} ->
msg = "An OpenIDConnect error occurred. Details: #{inspect(error)}"
Logger.error(msg)
conn
|> put_flash(:error, msg)
|> redirect(to: ~p"/")
# Error verifying claims or fetching tokens
{:error, action, reason} ->
Logger.warn("OpenIDConnect Error during #{action}: #{inspect(reason)}")
conn
|> put_flash(:error, "Failed when performing this action: #{action}")
|> redirect(to: ~p"/")
end
end

View File

@@ -218,7 +218,7 @@ defmodule FzHttpWeb.AuthControllerTest do
})
assert Phoenix.Flash.get(test_conn.assigns.flash, :error) ==
"OpenIDConnect Error: Cannot verify state"
"An OpenIDConnect error occurred. Details: \"Cannot verify state\""
end
@tag max_age: 0
@@ -226,7 +226,7 @@ defmodule FzHttpWeb.AuthControllerTest do
test_conn = get(conn, ~p"/auth/oidc/google/callback", @params)
assert Phoenix.Flash.get(test_conn.assigns.flash, :error) ==
"OpenIDConnect Error: Cannot verify state"
"An OpenIDConnect error occurred. Details: \"Cannot verify state\""
end
end