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(clerk-expo): Introduce SAML support #4880

Merged
merged 14 commits into from
Jan 24, 2025
Merged

feat(clerk-expo): Introduce SAML support #4880

merged 14 commits into from
Jan 24, 2025

Conversation

LauraBeatris
Copy link
Member

@LauraBeatris LauraBeatris commented Jan 13, 2025

Description

Resolves ORGS-454

This PR introduces a new React hook to trigger a wider range of SSO types such as SAML with the enterprise_sso strategy.

SAML support for native flows has been released on FAPI, and implemented by our native IOS SDK. It leverages the same rotating_token_nonce solution on SSO callback as it currently has for social OAuth.

const { startSSOFlow } = useSSO()
const [email, setEmail] = useState("") // Derived from a input field

  const handleSSO = async () => {
    if (!isLoaded) return

    try {
      // Triggers SSO on a browser window on mobile + opens in a new tab for web
     // On authorization, redirects back to the application
      const { createdSessionId, setActive, signIn, signUp } = await startSSOFlow({
        identifier: email,
        strategy: "enterprise_sso"
      })

      // If the sign-in was successful, set the session to active
      if (createdSessionId) {
        await setActive({ session: createdSessionId })
      }  else {
        // Use signIn or signUp returned  for next steps
      }
    } catch (err) {
      // See https://clerk.com/docs/custom-flows/error-handling
      // for more info on error handling
      console.error(JSON.stringify(err, null, 2))
    }
  }

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

Type of change

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

@LauraBeatris LauraBeatris self-assigned this Jan 13, 2025
Copy link

changeset-bot bot commented Jan 13, 2025

🦋 Changeset detected

Latest commit: d79d297

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

This PR includes changesets to release 1 package
Name Type
@clerk/clerk-expo Minor

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

Copy link

vercel bot commented Jan 13, 2025

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 Jan 22, 2025 7:59pm

@LauraBeatris LauraBeatris changed the title feat(expo): Enterprise SSO support feat(expo): SAML support Jan 13, 2025
@LauraBeatris
Copy link
Member Author

Before merging this PR, we should also raise an update to our docs: https://clerk.com/docs/references/expo/use-oauth

@LauraBeatris
Copy link
Member Author

!snapshot

@LauraBeatris LauraBeatris changed the title feat(expo): SAML support feat(expo): Introduce SAML support Jan 13, 2025
@clerk-cookie
Copy link
Collaborator

Hey @LauraBeatris - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 2.1.7-snapshot.v20250113122215
@clerk/backend 1.21.7-snapshot.v20250113122215
@clerk/chrome-extension 2.1.11-snapshot.v20250113122215
@clerk/clerk-js 5.44.0-snapshot.v20250113122215
@clerk/clerk-expo 2.7.0-snapshot.v20250113122215
@clerk/express 1.3.34-snapshot.v20250113122215
@clerk/fastify 2.1.7-snapshot.v20250113122215
@clerk/nextjs 6.9.10-snapshot.v20250113122215
@clerk/nuxt 1.0.3-snapshot.v20250113122215
@clerk/react-router 0.1.8-snapshot.v20250113122215
@clerk/remix 4.4.9-snapshot.v20250113122215
@clerk/tanstack-start 0.8.8-snapshot.v20250113122215
@clerk/testing 1.4.7-snapshot.v20250113122215

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@LauraBeatris LauraBeatris changed the title feat(expo): Introduce SAML support feat(clerk-expo): Introduce SAML support Jan 13, 2025
@LauraBeatris
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @LauraBeatris - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 2.1.7-snapshot.v20250113125959
@clerk/backend 1.21.7-snapshot.v20250113125959
@clerk/chrome-extension 2.1.11-snapshot.v20250113125959
@clerk/clerk-js 5.44.0-snapshot.v20250113125959
@clerk/clerk-expo 2.7.0-snapshot.v20250113125959
@clerk/express 1.3.34-snapshot.v20250113125959
@clerk/fastify 2.1.7-snapshot.v20250113125959
@clerk/nextjs 6.9.10-snapshot.v20250113125959
@clerk/nuxt 1.0.3-snapshot.v20250113125959
@clerk/react-router 0.1.8-snapshot.v20250113125959
@clerk/remix 4.4.9-snapshot.v20250113125959
@clerk/tanstack-start 0.8.8-snapshot.v20250113125959
@clerk/testing 1.4.7-snapshot.v20250113125959

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@LauraBeatris
Copy link
Member Author

Transfer flow:

CleanShot.2025-01-22.at.10.58.36.mp4

User already exists -> sign in:

CleanShot.2025-01-22.at.10.59.26.mp4

@LauraBeatris
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @LauraBeatris - the snapshot version command generated the following package versions:

Package Version
@clerk/chrome-extension 2.1.18-snapshot.v20250122140244
@clerk/clerk-js 5.47.1-snapshot.v20250122140244
@clerk/clerk-expo 2.7.0-snapshot.v20250122140244

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@LauraBeatris
Copy link
Member Author

I'll hold a bit here, we have a customer trying this feature via snapshot. They couldn't get it working on a previous snapshot, so I've sent the latest and am waiting for their response.

@LauraBeatris
Copy link
Member Author

I've tested this with multiple cases and I'm confident to merge. If defects appear afterward, let's release a patch to fix it.

@LauraBeatris LauraBeatris merged commit bd96d6c into main Jan 24, 2025
29 checks passed
@LauraBeatris LauraBeatris deleted the laura/saml-expo branch January 24, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants