Skip to content

console: surface OIDC sign-in failures on the login page#36193

Open
leedqin wants to merge 1 commit intoMaterializeInc:mainfrom
leedqin:console-improve-oidc-errors
Open

console: surface OIDC sign-in failures on the login page#36193
leedqin wants to merge 1 commit intoMaterializeInc:mainfrom
leedqin:console-improve-oidc-errors

Conversation

@leedqin
Copy link
Copy Markdown
Contributor

@leedqin leedqin commented Apr 21, 2026

Motivation

Addressing SSO Feedback to show better error messages in the console if there are SSO failures and not have a confusing user experience. Fixes CNS-53

Description

  • Added OIDC error messages to the console showing the errors when sign in failed/ surface environmentd warnings up in the console

Verification

When the sign in failed and if the user is not part of the organization
image

When OIDC might not be configured properly
image

@leedqin leedqin requested review from a team as code owners April 21, 2026 20:44
@leedqin leedqin requested a review from SangJunBak April 21, 2026 20:44
@leedqin leedqin added the A-CONSOLE Area: Console label Apr 21, 2026
* Add `OidcCallback` route component so IdP callback errors render
  instead of an indefinite loading spinner.
* Add `AuthError::OidcFailed` carrying the sanitized `OidcError::Display`
  in the 401 body, so environmentd token rejections can be surfaced to
  the user without leaking internal config.
* Wire the 401 interceptor to post a one-shot `{reason, detail}` message
  to `sessionStorage`; the login page renders it as an `Alert`
@leedqin leedqin force-pushed the console-improve-oidc-errors branch from 53dd542 to ecb9e14 Compare April 21, 2026 20:50
FailedToUpdateSession,
#[error("invalid credentials")]
InvalidCredentials,
/// Payload is `OidcError`'s sanitized `Display` (no expected-values leaks).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think similar to the pgwire tests in src/environmentd/tests/auth.rs, we should have tests asserting the details for the http errors.

Comment on lines +15 to +19
const hasBearer = (input: Parameters<typeof fetch>[0]): boolean =>
input instanceof Request &&
(input.headers.get("Authorization")?.startsWith("Bearer ") ?? false);

/** Reads the sanitized `OidcError::Display` environmentd returns for OIDC 401s. */
Copy link
Copy Markdown
Contributor

@SangJunBak SangJunBak Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a hacky way to differentiate login errors from session expiration. Rather than use local storage, can we encode the error message into the URL (like a search param) then on the login page, just show the error there?

export const OidcCallback = () => {
const auth = useAuth();

if (!auth.error) return <LoadingScreen />;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should unify the error behavior with errors from the Materialize side and just redirect to the login page with the error message.

Comment on lines +24 to +26
export const LOGIN_REASON_MESSAGES: Record<LoginReason, string> = {
auth_rejected: `Sign-in was rejected.${AUTH_REJECTED_SUFFIX}`,
session_expired: "Your previous session ended. Please sign in again.",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just not print an error for session expiration because we don't know definitively that a 401 with no detail is the session expiring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CONSOLE Area: Console

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants