Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types,clerkjs,backend): Add support for enterprise_sso strategy #4596

Conversation

Nikpolik
Copy link
Member

Description

This PR adds support for the new enterprise_sso strategy for signing in and signing up.

This strategy supersedes SAML to provide a single strategy as the entry point for Enterprise Single Sign On regardless of the underlying protocol used to authenticate the user. For now there are two new types of connections that are supported in addition to SAML, Custom OAuth and EASIE (multi-tenant OAuth).

This new strategy will is available from API version 2024-10-01 and after because the way the API responds for Sign In's with an email address that matches a SAML connection changes.

From this version and onwards the API will respond with a status of needs_first_factor, the only strategy that will be included in supported first factors is enterprise_sso and the email address that matched will be returned in the identifier field. This change was made to make a bit clear the next step required.

Changes

  1. Include enterprise_sso in responses and request types.
  2. Update Sign In response handling to take in to account enterprise_sso in supported first factors.
  3. Update Sign Up response handling to take in to account enterprise_sso in missing fields
  4. Update the SUPPORTED_API_VERSION constant to 2024-10-01

API Version 2024-10-01

Besides this change updating the version to 2024-10-01 will also enable the email's for Sign Ins from new clients feature.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated (TODO)

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@Nikpolik Nikpolik self-assigned this Nov 18, 2024
Copy link

changeset-bot bot commented Nov 18, 2024

🦋 Changeset detected

Latest commit: 4af970e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Minor
@clerk/types Patch
@clerk/backend Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/astro Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/shared Patch
@clerk/tanstack-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/ui Patch
@clerk/vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Nikpolik Nikpolik force-pushed the nikpolik/user-939-add-support-for-enterprise_sso-strategy-in-clerkjs branch 4 times, most recently from 4557562 to d676e5e Compare November 18, 2024 17:47
@LauraBeatris
Copy link
Member

LauraBeatris commented Nov 19, 2024

const showEnterpriseAccounts = user && user.enterpriseAccounts.length > 0;

@Nikpolik Could we update showEnterpriseAccounts here to check for userSettings.enteprise_sso.enabled

We're already checking for active accounts within EnterpriseAccountsSection, so it's not a bug, but better to explicitly check for enterprise_sso on the parent component as another layer of safety.

If tests start failing, we should probably introduce a withEnterpriseSso test helper.

Copy link

vercel bot commented Nov 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 4:54pm

@Nikpolik Nikpolik force-pushed the nikpolik/user-939-add-support-for-enterprise_sso-strategy-in-clerkjs branch from 9975d2b to f1bac6d Compare November 25, 2024 10:17
@Nikpolik Nikpolik force-pushed the nikpolik/user-939-add-support-for-enterprise_sso-strategy-in-clerkjs branch from f1bac6d to b2351cb Compare November 25, 2024 10:19
@Nikpolik Nikpolik marked this pull request as ready for review November 25, 2024 10:21
Handle the case of a sign in request that includes an identifier that
matches the domain of an enterprise connection (SAML, Custom OAuth or
EASIE).

From version 2024-10-01 and onwards the API will respond with a status
of `needs_first_factor`, the only strategy that will be included in
supported first factors is `enterprise_sso` and the email address that
matched will be returned in the identifier field.

This commit updates the sign in component to read this new response and proceed
with the enterprise_sso strategy.
When you enable SAML or any other enterprise sso strategy, both SAML and
EnterprisSso will become enabled in the user_settings.

Update the test helper to more closely reflect that.
@Nikpolik Nikpolik force-pushed the nikpolik/user-939-add-support-for-enterprise_sso-strategy-in-clerkjs branch from b2351cb to 97628f8 Compare November 25, 2024 13:00
packages/types/src/userSettings.ts Show resolved Hide resolved
packages/types/src/redirects.ts Outdated Show resolved Hide resolved
@@ -13,6 +13,7 @@ export type BackupCodeStrategy = 'backup_code';
export type ResetPasswordPhoneCodeStrategy = 'reset_password_phone_code';
export type ResetPasswordEmailCodeStrategy = 'reset_password_email_code';
export type CustomOAuthStrategy = `oauth_custom_${string}`;
export type EnterpriseSSOStrategy = 'enterprise_sso';
Copy link
Member

Choose a reason for hiding this comment

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

🔧 We should mark SamlStrategy as deprecated in favor of EnterpriseSSOStrategy:

/**
 * @deprecated Use `EnterpriseSSOStrategy` instead
 */
export type SamlStrategy = 'saml';

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed f9c2194

Thanks for catching this, we need to mention it in the API docs as well I'll update them!

Copy link
Member

@LauraBeatris LauraBeatris Nov 27, 2024

Choose a reason for hiding this comment

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

packages/clerk-js/src/ui/components/SignIn/SignInStart.tsx Outdated Show resolved Hide resolved
.changeset/famous-experts-begin.md Outdated Show resolved Hide resolved
Copy link
Member

@LauraBeatris LauraBeatris left a comment

Choose a reason for hiding this comment

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

Just need to update the changesets but overall looks good to me 👍🏻

@Nikpolik Nikpolik force-pushed the nikpolik/user-939-add-support-for-enterprise_sso-strategy-in-clerkjs branch from 6d1b541 to 4af970e Compare November 27, 2024 16:52
@Nikpolik Nikpolik merged commit 8a28d1f into main Nov 28, 2024
27 checks passed
@Nikpolik Nikpolik deleted the nikpolik/user-939-add-support-for-enterprise_sso-strategy-in-clerkjs branch November 28, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants