mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-06 00:47:52 +00:00
e175db8e62
* feat(auth): add SSO-only authentication mode Let administrators disable interactive local password login when SSO is configured, with backend enforcement, activation safeguards, and host CLI recovery. Closes #1709 * fix: resolve CI failures in auth mode PR - Add useLicense mock to SSOSection test to prevent crash from AuthenticationModePanel rendering without LicenseProvider - Remove username from authMode console.log calls that CodeQL flags as clear-text logging of sensitive information * fix(auth): keep SSO-only on named disableSso and fail-closed login Named provider disable no longer reverts authentication_mode. Login initializes localLoginEnabled false so a status fetch failure cannot reveal the password form. Center a single OIDC provider button on the login card. * fix(auth): move SSO-only authentication mode from Admiral to Community tier Security-hardening features belong on the Community tier per the existing Community rebalance. The reporter of #1709 noted that disabling local password login after configuring SSO is a basic security measure, not an enterprise governance feature. LDAP provider configuration remains Admiral-gated via requireTierForSsoProvider. * fix(ui): keep SSO Active badge and ON toggle in sync Provider cards mounted before config fetch finished with enabled:false, so a saved Active provider showed OFF until the local draft was resynced. Drive both the badge and TogglePill from the synced local config. * feat(auth): auto-redirect to sole OIDC provider under SSO-only When authentication mode is SSO only and exactly one OIDC provider is enabled (no LDAP), skip the login chooser and send the browser to that provider's authorize URL. Returning sso_error stays on the login page so the failure message remains visible. * fix(ui): move oidcAutoRedirectUrl out of Login for fast refresh Exporting the helper alongside the Login component tripped react-refresh/only-export-components and failed Frontend lint CI. Keep Login as a component-only module and colocate the helper with its unit tests under lib/.
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
/**
|
|
* SSO-only single-OIDC auto-redirect decision matrix.
|
|
*
|
|
* Under SSO-only with exactly one OIDC provider (and no LDAP), Login should
|
|
* send the browser to that provider's authorize URL. Local+SSO mode, LDAP,
|
|
* multiple OIDC providers, and a returning sso_error must not auto-redirect.
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
import { oidcAutoRedirectUrl } from './oidcAutoRedirect';
|
|
|
|
const github = { provider: 'oidc_github', type: 'oidc' };
|
|
const google = { provider: 'oidc_google', type: 'oidc' };
|
|
const ldap = { provider: 'ldap', type: 'ldap' };
|
|
|
|
describe('oidcAutoRedirectUrl', () => {
|
|
it('returns the authorize URL for SSO-only with a single OIDC provider', () => {
|
|
expect(
|
|
oidcAutoRedirectUrl({
|
|
localLoginEnabled: false,
|
|
providers: [github],
|
|
hadSsoError: false,
|
|
}),
|
|
).toBe('/api/auth/sso/oidc/oidc_github/authorize');
|
|
});
|
|
|
|
it('returns null when local password login is still enabled', () => {
|
|
expect(
|
|
oidcAutoRedirectUrl({
|
|
localLoginEnabled: true,
|
|
providers: [github],
|
|
hadSsoError: false,
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it('returns null when more than one OIDC provider is configured', () => {
|
|
expect(
|
|
oidcAutoRedirectUrl({
|
|
localLoginEnabled: false,
|
|
providers: [github, google],
|
|
hadSsoError: false,
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it('returns null when LDAP is present alongside a single OIDC provider', () => {
|
|
expect(
|
|
oidcAutoRedirectUrl({
|
|
localLoginEnabled: false,
|
|
providers: [github, ldap],
|
|
hadSsoError: false,
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it('returns null for LDAP-only SSO-only (no authorization endpoint)', () => {
|
|
expect(
|
|
oidcAutoRedirectUrl({
|
|
localLoginEnabled: false,
|
|
providers: [ldap],
|
|
hadSsoError: false,
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it('returns null after an SSO error so the login page can show the message', () => {
|
|
expect(
|
|
oidcAutoRedirectUrl({
|
|
localLoginEnabled: false,
|
|
providers: [github],
|
|
hadSsoError: true,
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
|
|
it('returns null when no providers are configured', () => {
|
|
expect(
|
|
oidcAutoRedirectUrl({
|
|
localLoginEnabled: false,
|
|
providers: [],
|
|
hadSsoError: false,
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
});
|