Skip to content
Open
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
8 changes: 8 additions & 0 deletions .changeset/reverification-enterprise-sso.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@clerk/ui': minor
'@clerk/clerk-js': patch
'@clerk/shared': patch
'@clerk/localizations': patch
---

Offer enterprise SSO as a first factor in the reverification modal. Users with an `enterprise_sso` factor now get a button per enterprise connection, verify with their identity provider in a popup, and the action that asked for reverification resumes without a page reload. When the popup is blocked the modal falls back to a full-page redirect, and `oauthFlow: 'redirect'` on `useReverification` or the modal props opts into the redirect from the start. `session.prepareFirstFactorVerification` accepts `actionCompleteRedirectUrl` for the `enterprise_sso` strategy.
1 change: 1 addition & 0 deletions packages/clerk-js/src/core/resources/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export class Session extends BaseResource implements SessionResource {
emailAddressId: factor.emailAddressId,
enterpriseConnectionId: factor.enterpriseConnectionId,
redirectUrl: factor.redirectUrl,
actionCompleteRedirectUrl: factor.actionCompleteRedirectUrl,
} as EnterpriseSSOConfig;
break;
default:
Expand Down
31 changes: 11 additions & 20 deletions packages/clerk-js/src/utils/authenticateWithPopup.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { buildAccountsBaseUrl } from '@clerk/shared/buildAccountsBaseUrl';
import { buildPopupCallbackUrls, navigatePopup } from '@clerk/shared/internal/clerk-js/popupCallback';
import type { AuthenticateWithPopupParams, AuthenticateWithRedirectParams } from '@clerk/shared/types';

import type { Clerk } from '../core/clerk';

const POPUP_ALLOWED_PROTOCOLS = ['http:', 'https:'];

export function navigatePopup(popup: { location: { href: string } }, to: URL | string): void {
const url = new URL(to, window.location.href);
if (!POPUP_ALLOWED_PROTOCOLS.includes(url.protocol)) {
throw new Error(`ClerkJS: "${url.protocol}" is not a valid popup navigation protocol.`);
}
popup.location.href = url.href;
}
export { navigatePopup };

export async function _authenticateWithPopup(
client: Clerk,
Expand All @@ -29,8 +22,6 @@ export async function _authenticateWithPopup(
return;
}

const accountPortalHost = buildAccountsBaseUrl(client.frontendApi);

const { redirectUrl } = params;

// We set the force_redirect_url query parameter to ensure that the user is redirected to the correct page even
Expand All @@ -42,10 +33,11 @@ export async function _authenticateWithPopup(
// All URLs are decorated with the dev browser token in development mode since we're moving between AP and the app.
const redirectUrlWithForceRedirectUrl = client.buildUrlWithAuth(r.toString());

const popupRedirectUrlComplete = client.buildUrlWithAuth(`${accountPortalHost}/popup-callback`);
const popupRedirectUrl = client.buildUrlWithAuth(
`${accountPortalHost}/popup-callback?return_url=${encodeURIComponent(redirectUrlWithForceRedirectUrl)}`,
);
const {
accountsOrigin: accountPortalHost,
redirectUrl: popupRedirectUrl,
redirectUrlComplete: popupRedirectUrlComplete,
} = buildPopupCallbackUrls(client.frontendApi, url => client.buildUrlWithAuth(url), redirectUrlWithForceRedirectUrl);

const messageHandler = async (event: MessageEvent) => {
if (event.origin !== accountPortalHost) {
Expand Down Expand Up @@ -111,8 +103,6 @@ export function wrapWithPopupRoutes(
redirectUrl: string;
},
): { redirectCallbackUrl: string; redirectUrl: string } {
const accountPortalHost = buildAccountsBaseUrl(client.frontendApi);

// We set the force_redirect_url query parameter to ensure that the user is redirected to the correct page even
// in situations like a modal transfer flow.
const r = new URL(redirectCallbackUrl);
Expand All @@ -121,9 +111,10 @@ export function wrapWithPopupRoutes(
// All URLs are decorated with the dev browser token in development mode since we're moving between AP and the app.
const redirectUrlWithForceRedirectUrl = client.buildUrlWithAuth(r.toString());

const popupRedirectUrlComplete = client.buildUrlWithAuth(`${accountPortalHost}/popup-callback`);
const popupRedirectUrl = client.buildUrlWithAuth(
`${accountPortalHost}/popup-callback?return_url=${encodeURIComponent(redirectUrlWithForceRedirectUrl)}`,
const { redirectUrl: popupRedirectUrl, redirectUrlComplete: popupRedirectUrlComplete } = buildPopupCallbackUrls(
client.frontendApi,
url => client.buildUrlWithAuth(url),
redirectUrlWithForceRedirectUrl,
);

return { redirectCallbackUrl: popupRedirectUrl, redirectUrl: popupRedirectUrlComplete };
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/ar-SA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,7 @@ export const arSA: LocalizationResource = {
actionText: undefined,
blockButton__backupCode: undefined,
blockButton__emailCode: undefined,
blockButton__enterpriseSSO: undefined,
blockButton__passkey: undefined,
blockButton__password: undefined,
blockButton__phoneCode: undefined,
Expand All @@ -1626,6 +1627,10 @@ export const arSA: LocalizationResource = {
subtitle: undefined,
title: undefined,
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: undefined,
subtitle: undefined,
Expand Down Expand Up @@ -2196,6 +2201,7 @@ export const arSA: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: 'لقد قمت بتسجيل الدخول بالفعل',
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/be-BY.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,7 @@ export const beBY: LocalizationResource = {
actionText: 'Паспрабуйце іншы метад для верыфікацыі.',
blockButton__backupCode: 'Увядзіце код з рэзервовага кода',
blockButton__emailCode: 'Увядзіце код, адправлены на электронную пошту',
blockButton__enterpriseSSO: undefined,
blockButton__passkey: undefined,
blockButton__password: 'Увядзіце пароль',
blockButton__phoneCode: 'Увядзіце код, адправлены на тэлефон',
Expand All @@ -1633,6 +1634,10 @@ export const beBY: LocalizationResource = {
subtitle: 'Калі ласка, праверце вашу электронную пошту для кода.',
title: 'Код з email',
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: 'Няма даступных метадаў для верыфікацыі.',
subtitle: 'Калі ласка, выберыце іншы метад або звярніцеся ў службу падтрымкі.',
Expand Down Expand Up @@ -2207,6 +2212,7 @@ export const beBY: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: 'Вы ўжо ўвайшлі.',
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/bg-BG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,7 @@ export const bgBG: LocalizationResource = {
actionText: "Don't have one of these?",
blockButton__backupCode: 'Use backup code',
blockButton__emailCode: 'Send code to email',
blockButton__enterpriseSSO: undefined,
blockButton__passkey: undefined,
blockButton__password: 'Login with password',
blockButton__phoneCode: 'Send code to phone',
Expand All @@ -1630,6 +1631,10 @@ export const bgBG: LocalizationResource = {
subtitle: "We've sent a code to your email.",
title: 'Email verification',
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: 'Unable to proceed. No available authentication methods.',
subtitle: 'Something went wrong.',
Expand Down Expand Up @@ -2201,6 +2206,7 @@ export const bgBG: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: 'Вече сте влезнали.',
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/bn-IN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,7 @@ export const bnIN: LocalizationResource = {
actionText: 'এর কোনটিই নেই?',
blockButton__backupCode: 'একটি ব্যাকআপ কোড ব্যবহার করুন',
blockButton__emailCode: '{{identifier}}-এ ইমেইল কোড পাঠান',
blockButton__enterpriseSSO: undefined,
blockButton__passkey: 'আপনার পাসকি ব্যবহার করুন',
blockButton__password: 'আপনার পাসওয়ার্ড দিয়ে চালিয়ে যান',
blockButton__phoneCode: '{{identifier}}-এ এসএমএস কোড পাঠান',
Expand All @@ -1637,6 +1638,10 @@ export const bnIN: LocalizationResource = {
subtitle: 'চালিয়ে যেতে আপনার ইমেইলে পাঠানো কোড লিখুন',
title: 'যাচাইকরণ প্রয়োজন',
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: 'যাচাইকরণ চালিয়ে যাওয়া যাচ্ছে না। কোনো উপযুক্ত অথেনটিকেশন ফ্যাক্টর কনফিগার করা নেই',
subtitle: 'একটি ত্রুটি ঘটেছে',
Expand Down Expand Up @@ -2225,6 +2230,7 @@ export const bnIN: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: undefined,
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/ca-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,7 @@ export const caES: LocalizationResource = {
actionText: 'No tens accés a aquest mètode? Prova una altra opció.',
blockButton__backupCode: 'Utilitzar codi de seguretat',
blockButton__emailCode: 'Utilitzar codi de correu electrònic',
blockButton__enterpriseSSO: undefined,
blockButton__passkey: undefined,
blockButton__password: 'Utilitzar contrasenya',
blockButton__phoneCode: 'Utilitzar codi de telèfon',
Expand All @@ -1638,6 +1639,10 @@ export const caES: LocalizationResource = {
subtitle: "Comprova el codi de verificació a la teva bústia d'entrada.",
title: 'Verificació per correu electrònic',
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: 'Ho sentim, no tens cap mètode de verificació disponible. Contacta amb suport.',
subtitle: "No s'han trobat mètodes alternatius disponibles.",
Expand Down Expand Up @@ -2214,6 +2219,7 @@ export const caES: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: 'Ja estàs connectat.',
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/cs-CZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,7 @@ export const csCZ: LocalizationResource = {
actionText: 'Nemáte žádnou z těchto možností?',
blockButton__backupCode: 'Použít záložní kód',
blockButton__emailCode: 'Odeslat kód na e-mail {{identifier}}',
blockButton__enterpriseSSO: undefined,
blockButton__passkey: 'Použít váš přístupový klíč',
blockButton__password: 'Pokračovat s vaším heslem',
blockButton__phoneCode: 'Odeslat SMS kód na {{identifier}}',
Expand All @@ -1635,6 +1636,10 @@ export const csCZ: LocalizationResource = {
subtitle: 'Zadejte kód odeslaný na váš e-mail pro pokračování',
title: 'Vyžadováno ověření',
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: 'Nelze pokračovat s ověřením. Není nakonfigurován žádný vhodný autentizační faktor',
subtitle: 'Došlo k chybě',
Expand Down Expand Up @@ -2212,6 +2217,7 @@ export const csCZ: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: 'Jste již přihlášen.',
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/da-DK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ export const daDK: LocalizationResource = {
actionText: undefined,
blockButton__backupCode: undefined,
blockButton__emailCode: undefined,
blockButton__enterpriseSSO: undefined,
blockButton__passkey: undefined,
blockButton__password: undefined,
blockButton__phoneCode: undefined,
Expand All @@ -1628,6 +1629,10 @@ export const daDK: LocalizationResource = {
subtitle: undefined,
title: undefined,
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: undefined,
subtitle: undefined,
Expand Down Expand Up @@ -2197,6 +2202,7 @@ export const daDK: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: 'Du er allerede logget ind.',
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/de-DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ export const deDE: LocalizationResource = {
actionText: 'Verwenden Sie eine alternative Verifizierungsmethode',
blockButton__backupCode: 'Mit Wiederherstellungscode verifizieren',
blockButton__emailCode: 'Mit E-Mail-Code verifizieren',
blockButton__enterpriseSSO: undefined,
blockButton__passkey: 'Verwenden Sie Ihren Passkey',
blockButton__password: 'Mit Passwort verifizieren',
blockButton__phoneCode: 'Mit SMS-Code verifizieren',
Expand All @@ -1644,6 +1645,10 @@ export const deDE: LocalizationResource = {
subtitle: 'Überprüfen Sie Ihre E-Mail auf den Verifizierungscode.',
title: 'E-Mail-Code Verifizierung',
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: 'Es sind keine Verifizierungsmethoden mehr verfügbar.',
subtitle: 'Bitte kontaktieren Sie den Support, um Hilfe zu erhalten.',
Expand Down Expand Up @@ -2230,6 +2235,7 @@ export const deDE: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: 'Sie sind bereits angemeldet.',
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/el-GR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,7 @@ export const elGR: LocalizationResource = {
actionText: 'Δεν έχετε κάποιο από αυτά;',
blockButton__backupCode: 'Χρησιμοποιήστε εφεδρικό κωδικό',
blockButton__emailCode: 'Αποστολή κωδικού στο {{identifier}}',
blockButton__enterpriseSSO: undefined,
blockButton__passkey: 'Χρησιμοποιήστε το passkey σας',
blockButton__password: 'Σύνδεση με τον κωδικό πρόσβασής σας',
blockButton__phoneCode: 'Αποστολή κωδικού μέσω SMS στο {{identifier}}',
Expand All @@ -1635,6 +1636,10 @@ export const elGR: LocalizationResource = {
subtitle: 'για να συνεχίσετε',
title: 'Ελέγξτε το email σας',
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: 'Δεν είναι δυνατή η συνέχεια. Δεν υπάρχει διαθέσιμος παράγοντας επαλήθευσης.',
subtitle: 'Παρουσιάστηκε σφάλμα',
Expand Down Expand Up @@ -2222,6 +2227,7 @@ export const elGR: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: 'Έχετε ήδη συνδεθεί.',
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/en-GB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ export const enGB: LocalizationResource = {
actionText: 'Don’t have any of these?',
blockButton__backupCode: 'Use a backup code',
blockButton__emailCode: 'Email code to {{identifier}}',
blockButton__enterpriseSSO: undefined,
blockButton__passkey: undefined,
blockButton__password: 'Continue with your password',
blockButton__phoneCode: 'Send SMS code to {{identifier}}',
Expand All @@ -1629,6 +1630,10 @@ export const enGB: LocalizationResource = {
subtitle: 'Enter the code sent to your email to continue',
title: 'Verification required',
},
enterpriseSSO: {
subtitle: undefined,
title: undefined,
},
noAvailableMethods: {
message: 'Cannot proceed with verification. No suitable authentication factor is configured',
subtitle: 'An error occurred',
Expand Down Expand Up @@ -2204,6 +2209,7 @@ export const enGB: LocalizationResource = {
protect_check_script_load_failed: undefined,
protect_check_timed_out: undefined,
protect_check_unsupported_environment: undefined,
reverification_enterprise_sso_failed: undefined,
session_exists: "You're already signed in.",
signup_rate_limit_exceeded: undefined,
something_went_wrong: undefined,
Expand Down
6 changes: 6 additions & 0 deletions packages/localizations/src/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ export const enUS: LocalizationResource = {
actionText: 'Don’t have any of these?',
blockButton__backupCode: 'Use a backup code',
blockButton__emailCode: 'Email code to {{identifier}}',
blockButton__enterpriseSSO: 'Continue with {{name}}',
blockButton__passkey: 'Use your passkey',
blockButton__password: 'Continue with your password',
blockButton__phoneCode: 'Send SMS code to {{identifier}}',
Expand All @@ -1675,6 +1676,10 @@ export const enUS: LocalizationResource = {
subtitle: 'Enter the code sent to your email to continue',
title: 'Verification required',
},
enterpriseSSO: {
subtitle: 'Continue with your enterprise account to confirm it’s you',
title: 'Verification required',
},
noAvailableMethods: {
message: 'Cannot proceed with verification. No suitable authentication factor is configured',
subtitle: 'An error occurred',
Expand Down Expand Up @@ -2265,6 +2270,7 @@ export const enUS: LocalizationResource = {
protect_check_timed_out: "Verification didn't complete in time. Please try again.",
protect_check_unsupported_environment:
"Verification isn't supported in this environment. Please continue in a standard browser or contact support.",
reverification_enterprise_sso_failed: "Verification with your identity provider didn't complete. Please try again.",
session_exists: undefined,
signup_rate_limit_exceeded: 'Too many requests. Please try again in a bit.',
something_went_wrong: 'Something went wrong. Please try again.',
Expand Down
Loading
Loading