Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Only allow sign up when invted
Maidul Islam2022988e773a
diff --git a/backend/src/config/index.ts b/backend/src/config/index.tsindex 1ea6bc3a16..1d8665c725 100644--- a/backend/src/config/index.ts+++ b/backend/src/config/index.ts@@ -1,6 +1,6 @@const PORT = process.env.PORT || 4000;const EMAIL_TOKEN_LIFETIME = parseInt(process.env.EMAIL_TOKEN_LIFETIME! || '86400');-const DISABLE_NEW_SIGN_UP = process.env.DISABLE_NEW_SIGN_UP == undefined ? false : process.env.DISABLE_NEW_SIGN_UP+const INVITE_ONLY_SIGNUP = process.env.INVITE_ONLY_SIGNUP == undefined ? false : process.env.INVITE_ONLY_SIGNUPconst ENCRYPTION_KEY = process.env.ENCRYPTION_KEY!;const SALT_ROUNDS = parseInt(process.env.SALT_ROUNDS!) || 10;const JWT_AUTH_LIFETIME = process.env.JWT_AUTH_LIFETIME! || '10d';@@ -51,7 +51,7 @@ const LICENSE_KEY = process.env.LICENSE_KEY!;export {PORT,EMAIL_TOKEN_LIFETIME,- DISABLE_NEW_SIGN_UP,+ INVITE_ONLY_SIGNUP,ENCRYPTION_KEY,SALT_ROUNDS,JWT_AUTH_LIFETIME,diff --git a/backend/src/controllers/v1/signupController.ts b/backend/src/controllers/v1/signupController.tsindex dc9860f437..dad9632db9 100644--- a/backend/src/controllers/v1/signupController.ts+++ b/backend/src/controllers/v1/signupController.ts@@ -1,6 +1,6 @@import { Request, Response } from 'express';import * as Sentry from '@sentry/node';-import { NODE_ENV, JWT_SIGNUP_LIFETIME, JWT_SIGNUP_SECRET, DISABLE_NEW_SIGN_UP } from '../../config';+import { NODE_ENV, JWT_SIGNUP_LIFETIME, JWT_SIGNUP_SECRET, INVITE_ONLY_SIGNUP } from '../../config';import { User, MembershipOrg } from '../../models';import { completeAccount } from '../../helpers/user';import {@@ -25,8 +25,12 @@ export const beginEmailSignup = async (req: Request, res: Response) => {try {email = req.body.email;- if (DISABLE_NEW_SIGN_UP) {- throw BadRequestError({ message: "New signups are not permitted at this time" })+ if (INVITE_ONLY_SIGNUP) {+ // Only one user can create an account without being invited. The rest need to be invited in order to make an account+ const userCount = await User.countDocuments({})+ if (userCount != 0) {+ throw BadRequestError({ message: "New user sign ups are not allowed at this time. You must be invited to sign up." })+ }}const user = await User.findOne({ email }).select('+publicKey');diff --git a/docs/self-hosting/configuration/envars.mdx b/docs/self-hosting/configuration/envars.mdxindex 42af4da796..804df78c25 100644--- a/docs/self-hosting/configuration/envars.mdx+++ b/docs/self-hosting/configuration/envars.mdx@@ -39,4 +39,4 @@ Configuring Infisical requires setting some environment variables. There is a fi| `CLIENT_SECRET_GITHUB` | OAuth2 client secret for GitHub integration | `None` || `CLIENT_SLUG_VERCEL` | OAuth2 slug for Netlify integration | `None` || `SENTRY_DSN` | DSN for error-monitoring with Sentry | `None` |-| `DISABLE_NEW_SIGN_UP` | Block new sign ups on your self hosted instance | `false` |+| `INVITE_ONLY_SIGNUP` | If true, users can only sign up if they are invited | `false` |