Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/29159-login-no-sign-in-method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@object-ui/auth': patch
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
'@object-ui/console': patch
---

fix(auth): the sign-in card says no sign-in method is available instead of showing SSO-only copy when email+password is off and nothing else is advertised

Clause-②: yes (widening)
Metadata-protocol: none

With email+password sign-in turned off (`PUT /api/settings/auth {"email_password_enabled": false}`) and no SSO, the sign-in page read "Sign in with your organization's single sign-on" with no SSO button, plus a "Use a password instead" link to a form the server refuses (`EMAIL_PASSWORD_DISABLED`). Nobody could tell why there was no way in.

- **`@object-ui/auth`:** `LoginForm` reads SSO enforcement only from the server's `features.ssoEnforced`; `emailPassword.enabled: false` now means the password door is shut, not that an identity provider stands in front of it. When the server also advertises no SSO, no social or OIDC provider and no phone sign-in, the card shows "No sign-in method is available. Contact your administrator." with nothing to click and no sign-up link. The SSO line is drawn only under declared enforcement or when SSO is on, and the "Use a password instead" link only while the form it opens holds a method the server accepts (email+password, the SSO button or phone sign-in). New optional label `LoginFormLabels.noSignInMethodText`.
- **`@object-ui/i18n`:** `auth.login.noSignInMethodText` in all ten locale packs.
- **`@object-ui/app-shell`, `@object-ui/console`:** both sign-in pages pass the translated label.

Unchanged: an SSO-enforced deployment keeps its SSO-only view and break-glass link, and a failed `/auth/config` read still falls back to the password form.

What to do: nothing. A host that does not pass `noSignInMethodText` gets the English default.
4 changes: 4 additions & 0 deletions ui/apps/console/src/pages/auth/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ function LoginFormCard({
}),
usePasswordText: t('auth.login.usePasswordText', { defaultValue: 'Use a password instead' }),
backToSsoText: t('auth.login.backToSsoText', { defaultValue: 'Back to single sign-on' }),
// Drawn in place of the form when the server offers no sign-in method.
noSignInMethodText: t('auth.login.noSignInMethodText', {
defaultValue: 'No sign-in method is available. Contact your administrator.',
}),
}}
/>
);
Expand Down
1 change: 1 addition & 0 deletions ui/packages/app-shell/src/console/auth/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export function LoginPage() {
ssoOnlyDescription: t('auth.login.ssoOnlyDescription'),
usePasswordText: t('auth.login.usePasswordText'),
backToSsoText: t('auth.login.backToSsoText'),
noSignInMethodText: t('auth.login.noSignInMethodText'),
}}
/>
);
Expand Down
96 changes: 73 additions & 23 deletions ui/packages/auth/src/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ export interface LoginFormLabels {
usePasswordSignInText?: string;
/** Description shown above the form in SSO-only mode (defaults to "Sign in with your organization's single sign-on"). */
ssoOnlyDescription?: string;
/**
* Shown in place of the form when the server offers no way to sign in:
* email+password sign-in is off and it advertises no SSO, no social or OIDC
* provider and no phone sign-in (defaults to "No sign-in method is
* available. Contact your administrator.").
*/
noSignInMethodText?: string;
/** Accessible name of the password field's reveal toggle while the password is hidden (defaults to "Show password"). */
showPasswordText?: string;
/** Accessible name of the password field's reveal toggle while the password is shown (defaults to "Hide password"). */
Expand Down Expand Up @@ -246,10 +253,16 @@ export function LoginForm({
const [ssoEnabled, setSsoEnabled] = useState(false);
// SSO-only ("enforced") mode: the server locks the team login to the IdP.
// Hide the local password form + sign-up; show the federated button(s) plus
// an understated break-glass link. `emailPassword.enabled === false` is a
// belt-and-suspenders fallback for older servers that signal the lock that
// way. Defaults to false (a failed config fetch never hides the form).
// an understated break-glass link. Only the server's own declaration,
// `features.ssoEnforced`, turns it on: it keeps `emailPassword.enabled` true
// for break-glass, so `enabled === false` means the password door is shut,
// not that an IdP is in front of it. Defaults to false (a failed config
// fetch never hides the form).
const [ssoEnforced, setSsoEnforced] = useState(false);
// The server turned email+password sign-in off (`emailPassword.enabled ===
// false`) and refuses that form. Defaults to false: a failed config fetch
// still shows the password form (break-glass beats lock-out).
const [passwordSignInOff, setPasswordSignInOff] = useState(false);
// Break-glass: reveal the password form for the env owner / local admin even
// under enforced mode (e.g. during an IdP outage).
const [showPasswordFallback, setShowPasswordFallback] = useState(false);
Expand All @@ -274,10 +287,12 @@ export function LoginForm({
setSsoEnabled(config?.features?.sso === true);
setPhoneOtpEnabled(config?.features?.phoneNumberOtp === true);
setPhonePasswordEnabled(config?.features?.phoneNumber === true);
setSsoEnforced(
config?.features?.ssoEnforced === true ||
config?.emailPassword?.enabled === false,
);
setSsoEnforced(config?.features?.ssoEnforced === true);
setPasswordSignInOff(config?.emailPassword?.enabled === false);
// Read here as well as from `SocialSignInButtons`' callback, so the
// no-method state below is decided with the config, never painted
// before the provider list lands.
setHasSocialProviders((config?.socialProviders ?? []).some((p) => p.enabled));
})
.catch(() => {
// SSO is an enhancement, not required — leave the buttons/form hidden
Expand All @@ -291,9 +306,19 @@ export function LoginForm({
};
}, [getAuthConfig]);

// Under enforced mode the password form is collapsed until the user opts into
// the break-glass path; otherwise it's always shown.
const passwordFormVisible = !ssoEnforced || showPasswordFallback;
// Under enforced mode, and when the server has turned the password door off,
// the password form is collapsed until the user opts into the break-glass
// path; otherwise it's always shown.
const passwordFormCollapsed = ssoEnforced || passwordSignInOff;
const passwordFormVisible = !passwordFormCollapsed || showPasswordFallback;
// The break-glass link reveals the password form, so it is offered only
// while that form holds a door the server accepts: email+password itself, the
// SSO button (routes the entered email), or phone+password sign-in.
const breakGlassOffered = !passwordSignInOff || ssoEnabled || phonePasswordEnabled;
// Nothing the server advertises lets anyone in: say so, instead of SSO copy
// with no SSO affordance and a password link the server refuses.
const noSignInMethod =
passwordSignInOff && !ssoEnabled && !hasSocialProviders && !phonePasswordEnabled && !phoneOtpEnabled;

const l = {
emailLabel: labels.emailLabel ?? 'Email',
Expand All @@ -312,6 +337,8 @@ export function LoginForm({
backToSsoText: labels.backToSsoText ?? 'Back to single sign-on',
ssoOnlyDescription:
labels.ssoOnlyDescription ?? "Sign in with your organization's single sign-on",
noSignInMethodText:
labels.noSignInMethodText ?? 'No sign-in method is available. Contact your administrator.',
phoneLabel: labels.phoneLabel ?? 'Phone number',
phonePlaceholder: labels.phonePlaceholder ?? '+1 555 000 0000',
otpCodeLabel: labels.otpCodeLabel ?? 'Verification code',
Expand Down Expand Up @@ -424,8 +451,13 @@ export function LoginForm({
}
};

// The SSO-only view: enforced mode with the break-glass form still closed.
const ssoOnlyView = ssoEnforced && !showPasswordFallback;
// The collapsed view: enforced mode, or the password door shut, with the
// break-glass form still closed.
const ssoOnlyView = passwordFormCollapsed && !showPasswordFallback;
// Its SSO copy is drawn only when single sign-on is what the server offers:
// its own enforcement declaration, or the SSO button. Never while the
// server answers `features.sso: false` with no enforcement.
const ssoOnlyCopy = ssoOnlyView && !noSignInMethod && (ssoEnforced || ssoEnabled);

return (
// `sm:max-w-[400px]`, not a fixed `sm:w-[400px]`: identical wherever the
Expand All @@ -437,7 +469,7 @@ export function LoginForm({
}`}
>
{hideHeader ? (
ssoOnlyView ? (
ssoOnlyCopy ? (
<p className="text-[13px] leading-relaxed text-muted-foreground">{l.ssoOnlyDescription}</p>
) : null
) : (
Expand All @@ -448,7 +480,13 @@ export function LoginForm({
// known yet, and the password form's copy would greet an SSO-only
// deployment (objectui#12682).
description={
configPending ? undefined : ssoOnlyView ? l.ssoOnlyDescription : description
configPending || noSignInMethod
? undefined
: ssoOnlyView
? ssoOnlyCopy
? l.ssoOnlyDescription
: undefined
: description
}
/>
)}
Expand All @@ -460,6 +498,16 @@ export function LoginForm({
<div className="flex justify-center py-10" role="status" aria-live="polite" data-testid="login-config-loading">
<AuthSpinner />
</div>
) : noSignInMethod ? (
/* No door the server accepts: a plain statement, and nothing to
click that the server would refuse. */
<p
role="status"
data-testid="login-no-sign-in-method"
className="py-6 text-center text-sm leading-relaxed text-muted-foreground"
>
{l.noSignInMethodText}
</p>
) : (
<>
{/* Unset labels stay `undefined` here, so the component's own English
Expand Down Expand Up @@ -653,7 +701,7 @@ export function LoginForm({

{/* Break-glass form was opened under enforced mode — let the user
collapse back to the SSO-only view. */}
{ssoEnforced && showPasswordFallback && (
{passwordFormCollapsed && showPasswordFallback && (
<button
type="button"
onClick={() => setShowPasswordFallback(false)}
Expand All @@ -670,20 +718,22 @@ export function LoginForm({
link to the password form for the env owner / local admin. */
<div className="space-y-4">
{error && <AuthErrorBanner message={error} />}
<button
type="button"
onClick={() => setShowPasswordFallback(true)}
className={`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline ${AUTH_TOUCH_TARGET_CLASS}`}
>
{l.usePasswordText}
</button>
{breakGlassOffered && (
<button
type="button"
onClick={() => setShowPasswordFallback(true)}
className={`w-full text-center text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-primary hover:underline ${AUTH_TOUCH_TARGET_CLASS}`}
>
{l.usePasswordText}
</button>
)}
</div>
)}
</>
)}
</div>

{registerUrl && !ssoEnforced && (
{registerUrl && !passwordFormCollapsed && (
<p className="px-8 text-center text-[13px] text-muted-foreground">
{l.noAccountText}{' '}
<LinkComp href={registerUrl} className={AUTH_LINK_CLASS}>
Expand Down
6 changes: 4 additions & 2 deletions ui/packages/auth/src/__tests__/LoginForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ describe('LoginForm — SSO-only (enforced) mode', () => {
expect(screen.queryByText('Sign up')).toBeNull();
});

it('treats emailPassword.enabled === false as enforced (belt-and-suspenders)', async () => {
it('does not read emailPassword.enabled === false as enforcement: with no other door it says none exists', async () => {
// The full matrix lives in noSignInMethod-29159.test.tsx.
renderLogin(createMockClient({ emailPassword: { enabled: false } }));

await screen.findByRole('button', BREAK_GLASS);
await screen.findByTestId('login-no-sign-in-method');
expect(screen.queryByRole('button', BREAK_GLASS)).toBeNull();
expect(screen.queryByLabelText('Email')).toBeNull();
});

Expand Down
Loading
Loading