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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

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("")
const router = useRouter()

  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 { setActive, signIn, setActive } = await startSSOFlow({
        identifier: email,
        strategy: "enterprise_sso"
      })

      // If the sign-in was successful, set the session to active
      if (attemptFirstFactor.status === 'complete') {
        await setActive({ session: createdSessionId })
        // Performs navigation
        router.replace('/dashboard')
      } else if (attemptFirstFactor.status === 'needs_second_factor') {
        // If the sign-in requires a second factor, display a TOTP form
        // Handles second factor, eg: Displaying a TOTP form
      } else {
        // If the sign-in failed, check why. User might need to
        // complete further steps.
        console.error(JSON.stringify(attemptFirstFactor, null, 2))
      }
    } 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: c7af016

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 17, 2025 5:49pm

@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

@panteliselef
Copy link
Member

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/astro 2.1.8-snapshot.v20250116110852
@clerk/backend 1.22.1-snapshot.v20250116110852
@clerk/chrome-extension 2.1.12-snapshot.v20250116110852
@clerk/clerk-js 5.44.1-snapshot.v20250116110852
@clerk/elements 0.22.8-snapshot.v20250116110852
@clerk/clerk-expo 2.7.0-snapshot.v20250116110852
@clerk/expo-passkeys 0.1.7-snapshot.v20250116110852
@clerk/express 1.3.35-snapshot.v20250116110852
@clerk/fastify 2.1.8-snapshot.v20250116110852
@clerk/localizations 3.9.8-snapshot.v20250116110852
@clerk/nextjs 6.9.11-snapshot.v20250116110852
@clerk/nuxt 1.0.4-snapshot.v20250116110852
@clerk/clerk-react 5.21.3-snapshot.v20250116110852
@clerk/react-router 0.1.9-snapshot.v20250116110852
@clerk/remix 4.4.10-snapshot.v20250116110852
@clerk/shared 2.20.7-snapshot.v20250116110852
@clerk/tanstack-start 0.8.9-snapshot.v20250116110852
@clerk/testing 1.4.8-snapshot.v20250116110852
@clerk/themes 2.2.6-snapshot.v20250116110852
@clerk/types 4.40.3-snapshot.v20250116110852
@clerk/ui 0.3.9-snapshot.v20250116110852
@clerk/vue 1.0.3-snapshot.v20250116110852

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/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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/localizations

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/clerk-react

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/shared

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

@clerk/themes

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

@clerk/types

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

@clerk/ui

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

@clerk/vue

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

@LauraBeatris
Copy link
Member Author

Web:

CleanShot.2025-01-16.at.10.37.50.mp4

Android:

CleanShot.2025-01-16.at.11.43.28.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.15-snapshot.v20250117174854
@clerk/clerk-js 5.45.2-snapshot.v20250117174854
@clerk/clerk-expo 2.7.0-snapshot.v20250117174854
@clerk/localizations 3.9.11-snapshot.v20250117174854
@clerk/ui 0.3.12-snapshot.v20250117174854

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

@clerk/localizations

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

@clerk/ui

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

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