-
Notifications
You must be signed in to change notification settings - Fork 323
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
Tenancies #418
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
teamId String @default(uuid()) @db.Uuid | ||
// Team IDs must be unique across all organizations (but not necessarily across all branches). | ||
// To model this in the DB, we add two columns that are always equal to tenancy.projectId and tenancy.branchId. | ||
mirroredProjectId String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we call these mirroredProjectId instead of just projectId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because they're not the source of truth, they are just a mirror. Like a cache
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/webhooks/page-client.tsx
Outdated
Show resolved
Hide resolved
} | ||
|
||
export default function PageClient() { | ||
const stackAdminApp = useAdminApp(); | ||
const svixToken = stackAdminApp.useSvixToken(); | ||
const [updateCounter, setUpdateCounter] = useState(0); | ||
|
||
// This is a hack to make sure svix hooks update when content changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that after removing this code, the manual Svix API requests are refreshed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested it but I'd be surprised if it didn't, I added key={updateCounter}
const { payload } = await jose.jwtVerify(accessToken, jwks); | ||
expect(payload).toEqual({ | ||
"exp": expect.any(Number), | ||
"iat": expect.any(Number), | ||
"iss": "https://access-token.jwt-signature.stack-auth.com", | ||
"aud": expect.any(String), | ||
"sub": expect.any(String), | ||
"branchId": "main", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to have a different secret key per branch in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would the purpose of that be?
* eventually, we'll nicely pass around tenancies and won't need this function anymore, so the cache is a good temp | ||
* solution | ||
*/ | ||
const soleTenancyIdsCache = new Map<string, string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it problematic if we delete a tenancy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would only happen if we delete the associated Project
Co-authored-by: Zai Shi <[email protected]>
…/webhooks/page-client.tsx Co-authored-by: Zai Shi <[email protected]>
Adds Tenancies to the database schema. This is the name of the concept that's
Project x Branch x Environment x Organization
.For now, this adds a
tenancy
property to SmartRequestAuth. Later, in the "Make all endpoints support organizations" step, we want to get rid of this, as onlyprojectId
andbranchId
are known by SmartRequest (each endpoint may use a different strategy to pick the organization — usually based on the user ID, but can be anything). However, for now, it makes the transition much easier.Important
Introduces 'Tenancies' to support multi-tenancy, affecting database schema, authentication, and API handling.
Tenancy
table inmigration.sql
to representProject x Branch x Environment x Organization
.migration.sql
to usetenancyId
instead ofprojectId
.ProjectConfigOverride
table.tenancy
property toSmartRequestAuth
insmart-request.tsx
.createAuthTokens()
andgenerateAccessToken()
intokens.tsx
to usetenancy
.OAuthModel
inmodel.tsx
to handletenancy
for token operations.crud-handler.tsx
to supporttenancy
.verification-code-handler.tsx
to usetenancy
.parseAuth()
insmart-request.tsx
to includetenancy
in authentication context.errors.tsx
to accommodate new tenancy logic.backend-helpers.ts
to validate tenancy-related changes.page-client.tsx
andutils.tsx
for webhooks.This description was created by
for 60f6231. It will automatically update as commits are pushed.