Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Merge branch 'main' into feat-admin-signup

Maidul Islam3138784d1ac2
diff --cc backend/src/services/auth/auth-login-service.ts
index 04304980ad,dcc9381b70..ee2cc59954
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@@ -262,27 -261,21 +262,28 @@@ export const authLoginServiceFactory =
/*
* OAuth2 login for google,github, and other oauth2 provider
* */
- const oauth2Login = async ({
- email,
- firstName,
- lastName,
- authMethod,
- callbackPort,
- isSignupAllowed
- }: TOauthLoginDTO) => {
+ const oauth2Login = async ({ email, firstName, lastName, authMethod, callbackPort }: TOauthLoginDTO) => {
let user = await userDAL.findUserByEmail(email);
+ const serverCfg = await getServerCfg();
+
const appCfg = getConfig();
- const isOauthSignUpDisabled = !isSignupAllowed && !user;
- if (isOauthSignUpDisabled) throw new BadRequestError({ message: "User signup disabled", name: "Oauth 2 login" });
if (!user) {
+ // Create a new user based on oAuth
+ if (!serverCfg?.allowSignUp) throw new BadRequestError({ message: "Sign Up disabled", name: "Oauth 2 login" });
+
+ if (serverCfg?.allowedSignUpDomain) {
+ const domain = email.split("@")[1];
+ const allowedDomains = serverCfg.allowedSignUpDomain.split(",").map((e) => e.trim());
+ if (!allowedDomains.includes(domain))
+ throw new BadRequestError({
+ message: `Email with a domain (@${domain}) is not supported`,
+ name: "Oauth 2 login"
+ });
+ }
-
- user = await userDAL.create({ email, firstName, lastName, authMethods: [authMethod] });
++
+ user = await userDAL.create({ email, firstName, lastName, authMethods: [authMethod], isGhost: false });
++
}
const isLinkingRequired = !user?.authMethods?.includes(authMethod);
const isUserCompleted = user.isAccepted;