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

chore(backend): Organization takes precedence over personal account in organization sync options #4320

Merged
merged 6 commits into from
Oct 17, 2024

Conversation

izaaklauer
Copy link
Contributor

@izaaklauer izaaklauer commented Oct 11, 2024

What changed?

This change makes organization URL patterns take precedence over personal account patterns in the new OrganizationSync handshake options.

Why now?

Initially, we didn't have a strong argument for which option should have precedence. Now, a use-case has become clear! If a fixed prefix is going to be present in a URL, we think it's more likely that it will be in org-indicating URLs and not personal-account-indicating URLs.

E.g. the following pattern:
/orgs/myorg/settings <- Fixed prefix "orgs" implies "mygreatorg" is active
/settings <- Absence of prefix implies that the personal account is active

Will occur more often than:
/me/settings <- Fixed prefix "me" indicates that the personal account is active
/mygreatorg/settings <- Absence of fixed prefix implies an organization is active

This is relevant because it's easiest to have the activatible entity type (org or personal account) with a fixed prefix take presedence, so that the other can wildcard match all routes.

For example, for an app using the first pattern, they could use the following middleware options:

{
  personalAccountPatterns: [
    '/', 
    '/(.*)'
  ],
  organizationPatterns: [
    '/orgs/:slug', 
    '/orgs/:slug/(.*)'
  ]
}

E.g. letting the personal account match everything that does not have the org prefix.

Is this a breaking change?

Technically yes, but this feature was introduced early this week, and has not yet been documented or formally announced, so I don't expect it to be in use yet, much less for anyone to be depending on this nuance yet.

Checklist

  • npm test runs as expected.
  • npm run 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:

Copy link

changeset-bot bot commented Oct 11, 2024

🦋 Changeset detected

Latest commit: 93deeba

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

This PR includes changesets to release 9 packages
Name Type
@clerk/backend Minor
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/tanstack-start Patch
@clerk/testing 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

@izaaklauer izaaklauer changed the title Izaak/orgs 132 org precidence over personal account chore(backend): organization takes precedence over personal account in organization sync options Oct 11, 2024
@izaaklauer izaaklauer changed the title chore(backend): organization takes precedence over personal account in organization sync options chore(backend): Organization takes precedence over personal account in organization sync options. Oct 11, 2024
@LauraBeatris LauraBeatris changed the title chore(backend): Organization takes precedence over personal account in organization sync options. chore(backend): Organization takes precedence over personal account in organization sync options Oct 14, 2024
@LauraBeatris LauraBeatris changed the title chore(backend): Organization takes precedence over personal account in organization sync options chore(backend): organizationPatterns takes precedence over personalAccountPatterns in organization sync options Oct 14, 2024
@LauraBeatris
Copy link
Member

@izaaklauer I think this is more like a bug fix than an chore, cause if there was a case like the following:

{
  personalAccountPatterns: [
    '/', 
    '/(.*)'
  ],
  organizationPatterns: [
    '/orgs/:slug', 
    '/orgs/:slug/(.*)'
  ]
}

then it wouldn't apply the organization patterns even if the route was matching correctly.

@izaaklauer izaaklauer changed the title chore(backend): organizationPatterns takes precedence over personalAccountPatterns in organization sync options chore(backend): Organization takes precedence over personal account in organization sync options Oct 15, 2024
@izaaklauer izaaklauer marked this pull request as ready for review October 15, 2024 19:21
@@ -0,0 +1,5 @@
---
"@clerk/backend": patch
Copy link
Member

Choose a reason for hiding this comment

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

I'd do minor as the change is significant but necessary.

@izaaklauer
Copy link
Contributor Author

izaaklauer commented Oct 17, 2024

@izaaklauer I think this is more like a bug fix than an chore, cause if there was a case like the following:

{
  personalAccountPatterns: [
    '/', 
    '/(.*)'
  ],
  organizationPatterns: [
    '/orgs/:slug', 
    '/orgs/:slug/(.*)'
  ]
}

then it wouldn't apply the organization patterns even if the route was matching correctly.

@LauraBeatris You're right that those settings today will always activate the personal workspace, but today's jsdoc comments also specify that the personal workspace takes prescience, so it's not a bug! This change only switches which pattern matcher is applied first. It used to be personal workspace, but now it's organization, because organization is more likely to be prefixed.

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.

4 participants