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

Support for Self-hosted Multi-Org Deployments (Enterprise Only) #1706

Merged
merged 15 commits into from Oct 12, 2023

Conversation

tzjames
Copy link
Collaborator

@tzjames tzjames commented Oct 3, 2023

Features and Changes

Adds a IS_MULTI_ORG env var.
Changes many of the locations where we check for IS_CLOUD or isCloud to instead check to see if it is a multi-org installation.

Testing

Test sign up flow:
Add the following env vars to /packages/front-end/.env.local AND /packages/back-end/.env.local
IS_MULTI_ORG=true
ALLOW_SELF_ORG_CREATION=false
Remove mongo dir.
Restart mongo.
Restart app.
Sign up first user.
Look in LeftNav and see no Settings->Admin
In MongoCompass add superAdmin: true for the first user.
See the admin screen.

In private browser:
Register a new user.
See message that they can't create an org without admin.
Modify packages/front-end/components/Auth/CreateOrganization.tsx to not care about ALLOW_SELF_ORG_CREATION
Enter a new org name and submit.
See error message from the back-end that they can't create an org without an admin.
Revert packages/front-end/components/Auth/CreateOrganization.tsx
See message in front-end again that the can't create an org without an admin.

Remove ALLOW_SELF_ORG_CREATION=false from .env.local files
Enter a new org name and submit and see them join the new org.

Go to http://localhost:3000/settings/team and see that the orphaned user list is not there.

Testing IS_CLOUD=true:
Set to IS_CLOUD=true
Set SSO_CONFIG=prod's SSO_CONFIG
Set IS_MULTI_ORG=true
Remove ALLOW_SELF_ORG_CREATION
Restart servers.
In private browser:
Register a new user
Create a new org with that user
In super user window, invite new user to an org as an admin
Back in private window go to settings->team and see that they don't see the orphaned users
In super user window go to /admin and create a new organization.

@github-actions
Copy link

github-actions bot commented Oct 3, 2023

Your preview environment pr-1706-bttf has been deployed.

Preview environment endpoints are available at:

@@ -106,8 +106,7 @@ export default function InAppHelp() {
className="btn btn-premium font-weight-normal my-2 w-100"
onClick={() => setUpgradeModal(true)}
>
Start {isCloud() ? "Free" : "Enterprise"} Trial{" "}
<GBPremiumBadge />
Start Free Trial <GBPremiumBadge />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Higher up in this file we set const showUpgradeModal = config && !hasCommercialFeature("livechat") && isCloud(); and we are only showing this section if showUpgradeModal is true, so this check is superfulous.

@tzjames tzjames requested a review from jdorn October 5, 2023 08:36

// Default to true, false only if explicitly set to "false"
export const ALLOW_SELF_ORG_CREATION =
process.env.ALLOW_SELF_ORG_CREATION !== "false";
Copy link
Member

Choose a reason for hiding this comment

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

We check for truthy/falsy values all over the place in this file. We should add a helper function to parse a string into a boolean so we're able to properly support things like 0, 1, true, false, TRUE, FALSE, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. I fell like that is a refactor that should be separate from this PR.

cloud: !!IS_CLOUD,
cloud: IS_CLOUD === "true",
isMultiOrg: IS_MULTI_ORG === "true",
allowSelfOrgCreation: ALLOW_SELF_ORG_CREATION !== "false", // Default to true, false only if explicitly set to "false"
Copy link
Member

Choose a reason for hiding this comment

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

Same here, we should have a "parse env string as boolean" function in the shared package and use it both here and the back-end

@tzjames tzjames requested a review from jdorn October 11, 2023 13:26
@github-actions
Copy link

Deploy preview for docs ready!

✅ Preview
https://docs-dxzbjfk96-growthbook.vercel.app

Built with commit 6a0cf09.
This pull request is being automatically deployed with vercel-action

@jdorn jdorn changed the title WIP: Change cloud->multiorg where appropriate Support for Self-hosted Multi-Org Deployments (Enterprise Only) Oct 12, 2023
@tzjames tzjames merged commit 7bb5d47 into main Oct 12, 2023
6 checks passed
@tzjames tzjames deleted the ji/multiorg branch October 12, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants