mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem - Sign-in methods are in Preferences, separate from MFA and recovery settings. - The risk of a single sign-in method (e.g. GitHub, and getting locked out of that account) isn’t clearly communicated. ## Solution - Bring sign-in methods, MFA and recovery codes together on the Security page. If Security is disabled, sign-in methods remain accessible in Preferences. - Highlight the most important next step with a primary button. For example, when MFA is off, “Set up MFA” takes priority over adding a password. - Explain the risk of relying on a single sign-in provider, and make it clear which email address a new password will apply to. - After connecting a sign-in provider, return users to the settings page they can access. Links to password setup open the password dialog directly. | After | | --- | | <img width="1460" height="1426" alt="CleanShot 2026-11-06 at 14 54 23@2x" src="https://github.com/user-attachments/assets/afb82601-1b6f-43be-9e98-a0edb8d529c8" /> | | _The “Sign-in methods” section moved to Account → Security. Note also the new Admonition regarding the risk of a single (GitHub) sign-in method._ | ## Review instructions 1. Open [Security](https://studio-staging-git-dnywh-recovery-security-home-supabase.vercel.app/dashboard/account/security#sign-in-methods). Check sign-in methods appear above MFA and recovery codes. With MFA off, “Set up MFA” should be primary. 2. Open Preferences. Sign-in methods should be absent unless Security is disabled. 3. On a test account, check password setup, email editing and provider linking. [Open password setup directly](https://studio-staging-git-dnywh-recovery-security-home-supabase.vercel.app/dashboard/account/security?securityAction=set-password#sign-in-methods), then cancel and confirm it stays closed.
94 lines
3.6 KiB
TypeScript
94 lines
3.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { evaluateAccountRecovery, type AccountRecoveryInput } from './evaluate-account-recovery'
|
|
|
|
const base: AccountRecoveryInput = {
|
|
identities: [{ provider: 'email' }],
|
|
email: 'person@example.com',
|
|
verifiedFactorCount: 1,
|
|
recoveryCodes: { status: 'available', remaining: 8 },
|
|
features: { recoveryCodesEnabled: true, passwordEnabled: true },
|
|
}
|
|
|
|
const evaluate = (overrides: Partial<AccountRecoveryInput> = {}) =>
|
|
evaluateAccountRecovery({ ...base, ...overrides })
|
|
|
|
describe('evaluateAccountRecovery', () => {
|
|
it('suppresses all findings for SSO identities', () => {
|
|
expect(
|
|
evaluate({ identities: [{ provider: 'sso:provider' }], recoveryCodes: { status: 'missing' } })
|
|
).toEqual([])
|
|
})
|
|
|
|
it('finds missing codes with any verified MFA count and suppresses the factor reminder', () => {
|
|
for (const verifiedFactorCount of [1, 2]) {
|
|
expect(evaluate({ verifiedFactorCount, recoveryCodes: { status: 'missing' } })).toEqual([
|
|
{ id: 'recovery-codes-missing', severity: 'warning', action: 'generate-codes' },
|
|
])
|
|
}
|
|
expect(evaluate({ verifiedFactorCount: 0, recoveryCodes: { status: 'missing' } })).toEqual([])
|
|
})
|
|
|
|
it('finds exhausted codes only with one verified MFA factor', () => {
|
|
expect(evaluate({ recoveryCodes: { status: 'available', remaining: 0 } })).toEqual([
|
|
{
|
|
id: 'recovery-codes-exhausted',
|
|
severity: 'critical',
|
|
action: 'regenerate-codes',
|
|
remainingCodes: 0,
|
|
},
|
|
])
|
|
expect(
|
|
evaluate({ verifiedFactorCount: 2, recoveryCodes: { status: 'available', remaining: 0 } })
|
|
).toEqual([])
|
|
})
|
|
|
|
it('uses the low-code boundary of one through three with one factor', () => {
|
|
for (const remaining of [1, 2, 3]) {
|
|
expect(evaluate({ recoveryCodes: { status: 'available', remaining } })).toEqual([
|
|
{
|
|
id: 'recovery-codes-low',
|
|
severity: 'warning',
|
|
action: 'regenerate-codes',
|
|
remainingCodes: remaining,
|
|
},
|
|
])
|
|
}
|
|
expect(evaluate({ recoveryCodes: { status: 'available', remaining: 4 } })).toEqual([
|
|
{ id: 'single-mfa-factor', severity: 'info', action: 'add-factor' },
|
|
])
|
|
expect(
|
|
evaluate({ verifiedFactorCount: 2, recoveryCodes: { status: 'available', remaining: 2 } })
|
|
).toEqual([])
|
|
})
|
|
|
|
it('waits for known code status before advising on a single MFA factor', () => {
|
|
expect(evaluate({ recoveryCodes: { status: 'unknown' } })).toEqual([])
|
|
expect(
|
|
evaluate({
|
|
recoveryCodes: { status: 'unknown' },
|
|
features: { ...base.features, recoveryCodesEnabled: false },
|
|
})
|
|
).toEqual([{ id: 'single-mfa-factor', severity: 'info', action: 'add-factor' }])
|
|
})
|
|
|
|
it('advises on a single OAuth sign-in independently of MFA findings', () => {
|
|
const identities = [{ provider: 'github' }]
|
|
expect(evaluate({ identities, verifiedFactorCount: 0 })).toEqual([
|
|
{ id: 'single-oauth-identity', severity: 'warning', action: 'set-password' },
|
|
])
|
|
expect(evaluate({ identities: [...identities, { provider: 'google' }] })).toEqual([
|
|
{ id: 'single-mfa-factor', severity: 'info', action: 'add-factor' },
|
|
])
|
|
expect(evaluate({ identities: [{ provider: 'phone' }] })).toEqual([
|
|
{ id: 'single-mfa-factor', severity: 'info', action: 'add-factor' },
|
|
])
|
|
expect(evaluate({ identities, email: undefined })).toEqual([
|
|
{ id: 'single-mfa-factor', severity: 'info', action: 'add-factor' },
|
|
])
|
|
expect(
|
|
evaluate({ identities, features: { ...base.features, passwordEnabled: false } })
|
|
).toEqual([{ id: 'single-mfa-factor', severity: 'info', action: 'add-factor' }])
|
|
})
|
|
})
|