-
Notifications
You must be signed in to change notification settings - Fork 575
feat: Adds support for multitenancy #555
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…s across mulitple user pools
This was referenced May 15, 2023
Merged
* fix: fixed logging * fix: pr comments * fix: pr comments
* fix: session v4 * fix: tests * fix: pr comments and tests * fix: test * fix: pr comments
* fix: changelog * fix: changelog * fix: pr comments
…689) * Update Dashboard verify session API to return the user's email * Update tests * Update CHANGELOG * Make changes based on PR comments
* fix: inmemory impl * fix: test fixes * fix: test fixes
* fix: mongo plugin * test: fix mongodb tests * fix: pr comments --------- Co-authored-by: Mihaly Lengyel <[email protected]>
rishabhpoddar
commented
Jun 2, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of change
Adds ability to load from different config values based on tenant id and connection uri in requests. This also enables the user to use different connection pools per tenant.
Related issues
Test Plan
Config.loadAllTenantConfig
is not called.loadAllTenantConfig
function with different stuff saved in the db has effect on the loaded config - DONEmergingTenantWithBaseConfigWithConflictingConfigsThrowsError
oneTest how a userpoolid is defined.Adding 100k tenants works fine in terms of the time and resources taking for checking the validity of their config.User pool ID vs connection pool ID testsgetTableSchema
Cronjob testsadds two tenants with same user pool id, yields only one cronjobadds two tenants with different user pool id yields two cronjobsNotFoundOrHelloAPI
with base path set. - DONETenantnotFound exception testsemailpassword + multitenancyuseridmapping + multitenancy_
if an app is removed, then the eelicensecheck cronjob for that app is not removed - we need to remove that as well."TODO: add recipe usage + RAM tests + optimise how these 1000 tenants are created" -> testCreating1000TenantsWithOneStorageUsage (uncomment the test)"TODO: we need to test recipe usage for the apps + RAM usage." -> testCreating50StorageLayersUsage (in plugin tests)addInfoToNonAuthRecipesBasedOnUserId
) - DONEmergingTenantWithBaseConfigWithConflictingConfigsThrowsError
oneTenantnotFound exception testsAdd tenantid, appid validation_
"TODO: add recipe usage + RAM tests + optimise how these 1000 tenants are created" -> testCreating1000TenantsWithOneStorageUsage (uncomment the test)"TODO: we need to test recipe usage for the apps + RAM usage." -> testCreating50StorageLayersUsage (in plugin tests)Documentation changes
TODO
Checklist for important updates
coreDriverInterfaceSupported.json
file has been updated (if needed)pluginInterfaceSupported.json
file has been updated (if needed)build.gradle
getPaidFeatureStats
function in FeatureFlag.java filebuild.gradle
, please make sure to add themin
implementationDependencies.json
.git tag
) in the formatvX.Y.Z
, and then find thelatest branch (
git branch --all
) whoseX.Y
is greater than the latest released tag.Tracking recipe changes
Remaining TODOs for this PR
Allow people to create their own connectionUriShould we change- We discussed about taking userPoolId from the user, but we can do it later.getUserPoolId
to read from the database and return an ID as opposed to just rely on the connection info?QuitProgramFromPluginException
cause if one tenant has an issue, then the whole core shouldn't stop.Change how unique pool and connection ID are created to hash the outputJWKs and hello API special case where we need to return a union of tenants:null
tenantIdappid-
Cronjob to refresh tenants in the core very frequently - this is useful when many cores are deployed and a new tenant is created.getResource
function before trying thenull
connection uri.getResource
function.<connection uri>/appId?/tenantId?/path
(appId can be part of connectionUri configured in supertokens.init + works well with JWKs endpoint config.)<connection uri/appid-<appId>/tenantId?/path
(appId can be part of connectionUri configured in supertokens.init + works well with JWKs endpoint config.)<connection uri>/appId?/path?tenantId=...
(appId can be part of connectionUri configured in supertokens.init - does jwks endpoint allow for query param?)<connection uri>/path?tenantId=...&appId=...
change connectionuridomain to appid everywhere, so it will be (appid, tenantid)"public"
.We should perhaps disable creation of users in non default tenant as well?Need a cronjob to refresh the tenant list in memory - cause there are a few operations which will read from that list during API calls (like sign up email password, if the tenant has enabled that or not). And if the config is changed in another core, it should eventually reflect in other cores as well.-> Not needed because we call refresh list in resource distributorremoveRoleFromTenant in multitenancyassertAllTenantConfigsAreValid
createNewRoleOrModifyItsPermissions function should also add to the tenantId <-> role table-> roles are per app nowChange getUsers API to also have includeAll query param which will return results across all tenants for the appDIFFERENT_ACROSS_TENANTS
orDIFFERENT_ACROSS_APPS
. since in the docs, we say to lookout for this comment to know which config can be different per tenant.AccessTokenSigningKey.initForBaseTenant(this);
in main.java, the session tests still pass.. not sure why.supertokens_saas_secret
./config
API to only be queried by the base tenant