feat: add oidc cycle breaker
This commit is contained in:
parent
92e6f07572
commit
25f3b19f50
7 changed files with 74 additions and 34 deletions
|
|
@ -21,7 +21,7 @@ defmodule MvWeb.AuthController do
|
|||
if Config.oidc_only?() do
|
||||
conn
|
||||
|> put_flash(:error, gettext("Only sign-in via Single Sign-On (SSO) is allowed."))
|
||||
|> redirect(to: ~p"/sign-in")
|
||||
|> redirect(to: sign_in_path_after_oidc_failure())
|
||||
else
|
||||
success_continue(conn, {:password, :sign_in}, user, token)
|
||||
end
|
||||
|
|
@ -149,7 +149,7 @@ defmodule MvWeb.AuthController do
|
|||
_ ->
|
||||
conn
|
||||
|> put_flash(:error, gettext("Unable to authenticate with OIDC. Please try again."))
|
||||
|> redirect(to: ~p"/sign-in")
|
||||
|> redirect(to: sign_in_path_after_oidc_failure())
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ defmodule MvWeb.AuthController do
|
|||
:error,
|
||||
gettext("The authentication server is currently unavailable. Please try again later.")
|
||||
)
|
||||
|> redirect(to: ~p"/sign-in")
|
||||
|> redirect(to: sign_in_path_after_oidc_failure())
|
||||
end
|
||||
|
||||
# Handle Assent invalid response errors (configuration or malformed responses)
|
||||
|
|
@ -176,7 +176,7 @@ defmodule MvWeb.AuthController do
|
|||
:error,
|
||||
gettext("Authentication configuration error. Please contact the administrator.")
|
||||
)
|
||||
|> redirect(to: ~p"/sign-in")
|
||||
|> redirect(to: sign_in_path_after_oidc_failure())
|
||||
end
|
||||
|
||||
# Catch-all clause for any other error types
|
||||
|
|
@ -186,7 +186,7 @@ defmodule MvWeb.AuthController do
|
|||
|
||||
conn
|
||||
|> put_flash(:error, gettext("Unable to authenticate with OIDC. Please try again."))
|
||||
|> redirect(to: ~p"/sign-in")
|
||||
|> redirect(to: sign_in_path_after_oidc_failure())
|
||||
end
|
||||
|
||||
# Handle generic AuthenticationFailed errors
|
||||
|
|
@ -226,10 +226,14 @@ defmodule MvWeb.AuthController do
|
|||
|
||||
conn
|
||||
|> put_flash(:error, error_message)
|
||||
|> redirect(to: ~p"/sign-in")
|
||||
|> redirect(to: sign_in_path_after_oidc_failure())
|
||||
end
|
||||
end
|
||||
|
||||
# Path used when redirecting to sign-in after an OIDC failure. The query param tells
|
||||
# OidcOnlySignInRedirect to show the sign-in page instead of redirecting back to OIDC (avoids loop).
|
||||
defp sign_in_path_after_oidc_failure, do: "/sign-in?oidc_failed=1"
|
||||
|
||||
# Extract meaningful error message from Ash errors
|
||||
defp extract_meaningful_error_message(errors) do
|
||||
# Look for specific error messages in InvalidAttribute errors
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue