Skip to content

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

feat: updated with review changes

=76c6fc2c12e7
diff --git a/backend/e2e-test/routes/v3/auth-idp.spec.ts b/backend/e2e-test/routes/v3/auth-idp.spec.ts
index be660385a5..7f95d0e768 100644
--- a/backend/e2e-test/routes/v3/auth-idp.spec.ts
+++ b/backend/e2e-test/routes/v3/auth-idp.spec.ts
@@ -149,7 +149,8 @@ describe("Auth IdP Service-Level Tests", () => {
userAgent: "test-agent"
});
- expect(result).toBeDefined();
+ expect(result.result).toBe(ProviderAuthResult.SIGNUP_REQUIRED);
+ expect(result).toHaveProperty("signupToken");
const db = getDb();
const alias = await db(TableName.UserAliases).where({ externalId, orgId: TEST_ORG_ID }).first();
diff --git a/backend/src/ee/services/ldap-config/ldap-config-service.ts b/backend/src/ee/services/ldap-config/ldap-config-service.ts
index afd860b7b9..add6385ab9 100644
--- a/backend/src/ee/services/ldap-config/ldap-config-service.ts
+++ b/backend/src/ee/services/ldap-config/ldap-config-service.ts
@@ -261,7 +261,7 @@ export const ldapConfigServiceFactory = ({
scope: OrganizationActionScope.ParentOrganization,
actor,
actorId,
- orgId: actorOrgId,
+ orgId,
actorAuthMethod,
actorOrgId
});
@@ -346,7 +346,7 @@ export const ldapConfigServiceFactory = ({
scope: OrganizationActionScope.ParentOrganization,
actor,
actorId,
- orgId: actorOrgId,
+ orgId,
actorAuthMethod,
actorOrgId
});
@@ -658,7 +658,7 @@ export const ldapConfigServiceFactory = ({
scope: OrganizationActionScope.ParentOrganization,
actor,
actorId,
- orgId: actorOrgId,
+ orgId,
actorAuthMethod,
actorOrgId
});
@@ -694,7 +694,7 @@ export const ldapConfigServiceFactory = ({
scope: OrganizationActionScope.ParentOrganization,
actor,
actorId,
- orgId: actorOrgId,
+ orgId,
actorAuthMethod,
actorOrgId
});
@@ -755,7 +755,7 @@ export const ldapConfigServiceFactory = ({
scope: OrganizationActionScope.ParentOrganization,
actor,
actorId,
- orgId: actorOrgId,
+ orgId,
actorAuthMethod,
actorOrgId
});
@@ -801,7 +801,7 @@ export const ldapConfigServiceFactory = ({
scope: OrganizationActionScope.ParentOrganization,
actor,
actorId,
- orgId: actorOrgId,
+ orgId,
actorAuthMethod,
actorOrgId
});
diff --git a/backend/src/server/routes/v1/password-router.ts b/backend/src/server/routes/v1/password-router.ts
index b421c3b9e8..03f030dda6 100644
--- a/backend/src/server/routes/v1/password-router.ts
+++ b/backend/src/server/routes/v1/password-router.ts
@@ -1,73 +1,11 @@
import { z } from "zod";
-import { BackupPrivateKeySchema } from "@app/db/schemas";
import { getConfig } from "@app/lib/config/env";
import { authRateLimit, smtpRateLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
-import { validateSignUpAuthorization } from "@app/services/auth/auth-fns";
import { ActorType, AuthMode } from "@app/services/auth/auth-type";
export const registerPasswordRouter = async (server: FastifyZodProvider) => {
- server.route({
- method: "GET",
- url: "/backup-private-key",
- config: {
- rateLimit: authRateLimit
- },
- schema: {
- operationId: "getBackupPrivateKey",
- response: {
- 200: z.object({
- message: z.string(),
- backupPrivateKey: BackupPrivateKeySchema.omit({ verifier: true })
- })
- }
- },
- handler: async (req) => {
- const token = validateSignUpAuthorization(req.headers.authorization as string, "", false);
- const backupPrivateKey = await server.services.password.getBackupPrivateKeyOfUser(token.userId);
- if (!backupPrivateKey) throw new Error("Failed to find backup key");
-
- return { message: "Successfully fetched backup private key", backupPrivateKey };
- }
- });
-
- server.route({
- method: "POST",
- url: "/password-reset",
- config: {
- rateLimit: authRateLimit
- },
- schema: {
- operationId: "resetPasswordByBackupKey",
- body: z.object({
- protectedKey: z.string().trim(),
- protectedKeyIV: z.string().trim(),
- protectedKeyTag: z.string().trim(),
- encryptedPrivateKey: z.string().trim(),
- encryptedPrivateKeyIV: z.string().trim(),
- encryptedPrivateKeyTag: z.string().trim(),
- salt: z.string().trim(),
- verifier: z.string().trim(),
- password: z.string().trim()
- }),
- response: {
- 200: z.object({
- message: z.string()
- })
- }
- },
- handler: async (req) => {
- const token = validateSignUpAuthorization(req.headers.authorization as string, "", false);
- await server.services.password.resetPasswordByBackupKey({
- ...req.body,
- userId: token.userId
- });
-
- return { message: "Successfully reset password" };
- }
- });
-
server.route({
method: "POST",
url: "/email/password-setup",
diff --git a/backend/src/server/routes/v3/login-router.ts b/backend/src/server/routes/v3/login-router.ts
index f8663f9c2a..a13a814ec6 100644
--- a/backend/src/server/routes/v3/login-router.ts
+++ b/backend/src/server/routes/v3/login-router.ts
@@ -178,6 +178,13 @@ export const registerLoginRouter = async (server: FastifyZodProvider) => {
);
}
+ void res.setCookie("jid", tokens.refreshToken, {
+ httpOnly: true,
+ path: "/api",
+ sameSite: "strict",
+ secure: appCfg.HTTPS_ENABLED
+ });
+
addAuthOriginDomainCookie(res);
void res.cookie("infisical-project-assume-privileges", "", {
httpOnly: true,
diff --git a/backend/src/services/auth/auth-password-service.ts b/backend/src/services/auth/auth-password-service.ts
index dadd7ad9cd..8856da4f7b 100644
--- a/backend/src/services/auth/auth-password-service.ts
+++ b/backend/src/services/auth/auth-password-service.ts
@@ -9,14 +9,8 @@ import { TokenType } from "../auth-token/auth-token-types";
import { SmtpTemplates, TSmtpService } from "../smtp/smtp-service";
import { TTotpConfigDALFactory } from "../totp/totp-config-dal";
import { TUserDALFactory } from "../user/user-dal";
-import { UserEncryption } from "../user/user-types";
import { TAuthDALFactory } from "./auth-dal";
-import {
- ResetPasswordV2Type,
- TResetPasswordV2DTO,
- TResetPasswordViaBackupKeyDTO,
- TSetupPasswordViaBackupKeyDTO
-} from "./auth-password-type";
+import { ResetPasswordV2Type, TResetPasswordV2DTO, TSetupPasswordViaBackupKeyDTO } from "./auth-password-type";
import { ActorType, AuthMethod } from "./auth-type";
type TAuthPasswordServiceFactoryDep = {
@@ -28,19 +22,13 @@ type TAuthPasswordServiceFactoryDep = {
};
export type TAuthPasswordFactory = ReturnType<typeof authPaswordServiceFactory>;
-export const authPaswordServiceFactory = ({
- authDAL,
- userDAL,
- tokenService,
- smtpService,
- totpConfigDAL
-}: TAuthPasswordServiceFactoryDep) => {
+export const authPaswordServiceFactory = ({ userDAL, tokenService, smtpService }: TAuthPasswordServiceFactoryDep) => {
const resetPasswordV2 = async ({ userId, newPassword, oldPassword, type }: TResetPasswordV2DTO) => {
const cfg = getConfig();
const user = await userDAL.findById(userId);
- if (!user) {
- throw new BadRequestError({ message: `User encryption key not found for user with ID '${userId}'` });
+ if (!user || !user.isAccepted || !user.isEmailVerified) {
+ throw new BadRequestError({ message: `Invalid token` });
}
if (!user.authMethods?.includes(AuthMethod.EMAIL)) {
@@ -75,62 +63,6 @@ export const authPaswordServiceFactory = ({
await tokenService.revokeAllMySessions(userId);
};
- /*
- * Reset password of a user via backup key
- * */
- const resetPasswordByBackupKey = async ({
- encryptedPrivateKey,
- protectedKeyTag,
- protectedKey,
- protectedKeyIV,
- salt,
- verifier,
- encryptedPrivateKeyIV,
- encryptedPrivateKeyTag,
- userId,
- password
- }: TResetPasswordViaBackupKeyDTO) => {
- const cfg = getConfig();
-
- const hashedPassword = await crypto.hashing().createHash(password, cfg.SALT_ROUNDS);
-
- await userDAL.updateUserEncryptionByUserId(userId, {
- encryptionVersion: 2,
- protectedKey,
- protectedKeyIV,
- protectedKeyTag,
- encryptedPrivateKey,
- iv: encryptedPrivateKeyIV,
- tag: encryptedPrivateKeyTag,
- salt,
- verifier,
- hashedPassword
- });
-
- await userDAL.updateById(userId, {
- isLocked: false,
- temporaryLockDateEnd: null,
- consecutiveFailedMfaAttempts: 0
- });
-
- /* we reset the mobile authenticator configs of the user
- because we want this to be one of the recovery modes from account lockout */
- await totpConfigDAL.delete({
- userId
- });
- };
-
- const getBackupPrivateKeyOfUser = async (userId: string) => {
- const user = await userDAL.findUserEncKeyByUserId(userId);
- if (!user || (user && !user.isAccepted)) {
- throw new Error("Failed to find user");
- }
- const backupKey = await authDAL.getBackupPrivateKeyByUserId(userId);
- if (!backupKey) throw new Error("Failed to find user backup key");
-
- return backupKey;
- };
-
const sendPasswordSetupEmail = async (actor: OrgServiceActor) => {
if (actor.type !== ActorType.USER)
throw new BadRequestError({ message: `Actor of type ${actor.type} cannot set password` });
@@ -196,13 +128,10 @@ export const authPaswordServiceFactory = ({
const hashedPassword = await crypto.hashing().createHash(password, cfg.SALT_ROUNDS);
- await userDAL.updateUserEncryptionByUserId(
+ await userDAL.updateById(
actor.id,
{
- encryptionVersion: UserEncryption.V2,
- hashedPassword,
- serverPrivateKey: null,
- clientPublicKey: null
+ hashedPassword
},
tx
);
@@ -212,8 +141,6 @@ export const authPaswordServiceFactory = ({
};
return {
- resetPasswordByBackupKey,
- getBackupPrivateKeyOfUser,
sendPasswordSetupEmail,
setupPassword,
resetPasswordV2
diff --git a/backend/src/services/auth/auth-signup-service.ts b/backend/src/services/auth/auth-signup-service.ts
index 9cfe46cfa5..d8ff331274 100644
--- a/backend/src/services/auth/auth-signup-service.ts
+++ b/backend/src/services/auth/auth-signup-service.ts
@@ -253,20 +253,25 @@ export const authSignupServiceFactory = ({
userUpdates.isAccepted = true;
}
- if (userAlias?.orgId) {
- await orgDAL.updateMembership(
- {
- actorUserId: user.id,
- scope: AccessScope.Organization,
- scopeOrgId: userAlias.orgId
- },
- {
- status: OrgMembershipStatus.Accepted
- }
- );
- }
+ user = await userDAL.transaction(async (tx) => {
+ if (userAlias?.orgId) {
+ await orgDAL.updateMembership(
+ {
+ actorUserId: user.id,
+ scope: AccessScope.Organization,
+ scopeOrgId: userAlias.orgId
+ },
+ {
+ status: OrgMembershipStatus.Accepted
+ },
+ tx
+ );
+ }
+
+ const el = await userDAL.updateById(user.id, userUpdates, tx);
+ return el;
+ });
- user = await userDAL.updateById(user.id, userUpdates);
authMethod = decodedToken.authMethod;
}
diff --git a/docs/documentation/platform/ldap/general.mdx b/docs/documentation/platform/ldap/general.mdx
index c1d062ef59..e9428fec1f 100644
--- a/docs/documentation/platform/ldap/general.mdx
+++ b/docs/documentation/platform/ldap/general.mdx
@@ -3,6 +3,11 @@ title: "General LDAP"
description: "Learn how to log in to Infisical with LDAP."
---
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Info>
LDAP is a paid feature. If you're using Infisical Cloud, then it is available
under the **Enterprise Tier**. If you're self-hosting Infisical, then you
diff --git a/docs/documentation/platform/ldap/jumpcloud.mdx b/docs/documentation/platform/ldap/jumpcloud.mdx
index d520598d18..94577ba284 100644
--- a/docs/documentation/platform/ldap/jumpcloud.mdx
+++ b/docs/documentation/platform/ldap/jumpcloud.mdx
@@ -3,6 +3,11 @@ title: "JumpCloud LDAP"
description: "Learn how to configure JumpCloud LDAP for authenticating into Infisical."
---
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Info>
LDAP is a paid feature. If you're using Infisical Cloud, then it is available
under the **Enterprise Tier**. If you're self-hosting Infisical, then you
diff --git a/docs/documentation/platform/sso/auth0-oidc.mdx b/docs/documentation/platform/sso/auth0-oidc.mdx
index 0f616c5196..b70da3b31e 100644
--- a/docs/documentation/platform/sso/auth0-oidc.mdx
+++ b/docs/documentation/platform/sso/auth0-oidc.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure Auth0 OIDC for Infisical SSO."
it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Setup application in Auth0">
1.1. From the Application's Page, navigate to the settings tab of the Auth0 application you want to integrate with Infisical.
diff --git a/docs/documentation/platform/sso/auth0-saml.mdx b/docs/documentation/platform/sso/auth0-saml.mdx
index 824fdd4614..d729268dba 100644
--- a/docs/documentation/platform/sso/auth0-saml.mdx
+++ b/docs/documentation/platform/sso/auth0-saml.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure Auth0 SAML for Infisical SSO."
to use it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Prepare the SAML SSO configuration in Infisical">
In Infisical, head to the **Single Sign-On (SSO)** page and select the **General** tab. Click **Connect** for **SAML** under the Connect to an Identity Provider section. Select **Auth0**, then click **Connect** again.
diff --git a/docs/documentation/platform/sso/azure.mdx b/docs/documentation/platform/sso/azure.mdx
index 0957dc4d1e..097c2fc606 100644
--- a/docs/documentation/platform/sso/azure.mdx
+++ b/docs/documentation/platform/sso/azure.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure Microsoft Entra ID for Infisical SSO."
then you should contact [email protected] to purchase an enterprise license to use it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Prepare the SAML SSO configuration in Infisical">
In Infisical, head to the **Single Sign-On (SSO)** page and select the **General** tab. Click **Connect** for **SAML** under the Connect to an Identity Provider section. Select **Azure / Entra**, then click **Connect** again.
diff --git a/docs/documentation/platform/sso/general-oidc/overview.mdx b/docs/documentation/platform/sso/general-oidc/overview.mdx
index 9f5d0c54a3..f31fcc90d9 100644
--- a/docs/documentation/platform/sso/general-oidc/overview.mdx
+++ b/docs/documentation/platform/sso/general-oidc/overview.mdx
@@ -11,6 +11,11 @@ description: "Learn how to configure OIDC for Infisical SSO with any OIDC-compli
it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
You can configure your organization in Infisical to have members authenticate with the platform through identity providers via [OpenID Connect](https://openid.net/specs/openid-connect-core-1_0.html).
Prerequisites:
diff --git a/docs/documentation/platform/sso/google-saml.mdx b/docs/documentation/platform/sso/google-saml.mdx
index 639a113216..b38d883fc0 100644
--- a/docs/documentation/platform/sso/google-saml.mdx
+++ b/docs/documentation/platform/sso/google-saml.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure Google SAML for Infisical SSO."
to use it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Prepare the SAML SSO configuration in Infisical">
In Infisical, head to the **Single Sign-On (SSO)** page and select the **General** tab. Click **Connect** for **SAML** under the Connect to an Identity Provider section. Select **Google**, then click **Connect** again.
diff --git a/docs/documentation/platform/sso/jumpcloud.mdx b/docs/documentation/platform/sso/jumpcloud.mdx
index 3cad22247b..7d185d87bd 100644
--- a/docs/documentation/platform/sso/jumpcloud.mdx
+++ b/docs/documentation/platform/sso/jumpcloud.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure JumpCloud SAML for Infisical SSO."
then you should contact [email protected] to purchase an enterprise license to use it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Prepare the SAML SSO configuration in Infisical">
In Infisical, head to the **Single Sign-On (SSO)** page and select the **General** tab. Click **Connect** for **SAML** under the Connect to an Identity Provider section. Select **JumpCloud**, then click **Connect** again.
diff --git a/docs/documentation/platform/sso/keycloak-oidc/overview.mdx b/docs/documentation/platform/sso/keycloak-oidc/overview.mdx
index 0a32df2284..4db4ab8583 100644
--- a/docs/documentation/platform/sso/keycloak-oidc/overview.mdx
+++ b/docs/documentation/platform/sso/keycloak-oidc/overview.mdx
@@ -11,6 +11,11 @@ description: "Learn how to configure Keycloak OIDC for Infisical SSO."
use it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Create an OIDC client application in Keycloak">
1.1. In your realm, navigate to the **Clients** tab and click **Create client** to create a new client application.
diff --git a/docs/documentation/platform/sso/keycloak-saml.mdx b/docs/documentation/platform/sso/keycloak-saml.mdx
index daca360b43..358bab80f4 100644
--- a/docs/documentation/platform/sso/keycloak-saml.mdx
+++ b/docs/documentation/platform/sso/keycloak-saml.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure Keycloak SAML for Infisical SSO."
then you should contact [email protected] to purchase an enterprise license to use it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Prepare the SAML SSO configuration in Infisical">
In Infisical, head to the **Single Sign-On (SSO)** page and select the **General** tab. Click **Connect** for **SAML** under the Connect to an Identity Provider section. Select **Keycloak**, then click **Connect** again.
diff --git a/docs/documentation/platform/sso/okta-oidc.mdx b/docs/documentation/platform/sso/okta-oidc.mdx
index c80cbe5d1d..9abea30d7e 100644
--- a/docs/documentation/platform/sso/okta-oidc.mdx
+++ b/docs/documentation/platform/sso/okta-oidc.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure Okta OIDC for Infisical SSO."
it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Create an OIDC application in Okta">
In the Okta Admin Portal, select Applications > Applications from the navigation. On the Applications screen, click the **Create App Integration** button.
diff --git a/docs/documentation/platform/sso/okta.mdx b/docs/documentation/platform/sso/okta.mdx
index ecdf6ca397..79e4c8daba 100644
--- a/docs/documentation/platform/sso/okta.mdx
+++ b/docs/documentation/platform/sso/okta.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure Okta SAML 2.0 for Infisical SSO."
it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Prepare the SAML SSO configuration in Infisical">
In Infisical, head to the **Single Sign-On (SSO)** page and select the **General** tab. Click **Connect** for **SAML** under the Connect to an Identity Provider section. Select **Okta**, then click **Connect** again.
diff --git a/docs/documentation/platform/sso/pingone-oidc.mdx b/docs/documentation/platform/sso/pingone-oidc.mdx
index 1fea5f8154..d650f9b494 100644
--- a/docs/documentation/platform/sso/pingone-oidc.mdx
+++ b/docs/documentation/platform/sso/pingone-oidc.mdx
@@ -10,6 +10,11 @@ description: "Learn how to configure PingOne OIDC for Infisical SSO."
it.
</Info>
+<Note>
+ SSO authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via SSO.
+</Note>
+
<Steps>
<Step title="Setup application in PingOne">
1.1. From the Application's Page, create a new OIDC Web App application.
diff --git a/frontend/src/hooks/api/auth/index.tsx b/frontend/src/hooks/api/auth/index.tsx
index cf7a32e436..2da17b1bdc 100644
--- a/frontend/src/hooks/api/auth/index.tsx
+++ b/frontend/src/hooks/api/auth/index.tsx
@@ -1,7 +1,6 @@
export {
useGetAuthToken,
useOauthTokenExchange,
- useResetPassword,
useResetPasswordV2,
useResetUserPasswordV2,
useSelectOrganization,
diff --git a/frontend/src/hooks/api/auth/queries.tsx b/frontend/src/hooks/api/auth/queries.tsx
index 1f84b1d468..488a2667be 100644
--- a/frontend/src/hooks/api/auth/queries.tsx
+++ b/frontend/src/hooks/api/auth/queries.tsx
@@ -12,7 +12,6 @@ import { TGenerateAuthenticationOptionsResponse, TVerifyAuthenticationDTO } from
import { fetchAuthToken } from "./refresh";
import {
CompleteAccountSignupDTO,
- GetBackupEncryptedPrivateKeyDTO,
Login1DTO,
Login1Res,
Login2DTO,
@@ -23,7 +22,6 @@ import {
LoginV3Res,
MfaMethod,
OauthTokenExchangeRes,
- ResetPasswordDTO,
ResetPasswordV2DTO,
ResetUserPasswordV2DTO,
SendMfaTokenDTO,
@@ -106,9 +104,8 @@ export const useSelectOrganization = () => {
// Invalidate the auth token cache so the authenticate middleware
// re-calls fetchAuthToken (which reads the new in-memory token with orgId)
queryClient.invalidateQueries({ queryKey: authKeys.getAuthToken });
- queryClient.invalidateQueries({
- queryKey: [organizationKeys.getUserOrganizations, projectKeys.getAllUserProjects]
- });
+ queryClient.invalidateQueries({ queryKey: organizationKeys.getUserOrganizations });
+ queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects });
}
});
};
@@ -230,46 +227,6 @@ export const useVerifySignupEmailVerificationCode = () => {
});
};
-export const getBackupEncryptedPrivateKey = async ({
- verificationToken
-}: GetBackupEncryptedPrivateKeyDTO) => {
- const { data } = await apiRequest.get("/api/v1/password/backup-private-key", {
- headers: {
- Authorization: `Bearer ${verificationToken}`
- }
- });
-
- return data.backupPrivateKey;
-};
-
-export const useResetPassword = () => {
- return useMutation({
- mutationFn: async (details: ResetPasswordDTO) => {
- const { data } = await apiRequest.post(
- "/api/v1/password/password-reset",
- {
- protectedKey: details.protectedKey,
- protectedKeyIV: details.protectedKeyIV,
- protectedKeyTag: details.protectedKeyTag,
- encryptedPrivateKey: details.encryptedPrivateKey,
- encryptedPrivateKeyIV: details.encryptedPrivateKeyIV,
- encryptedPrivateKeyTag: details.encryptedPrivateKeyTag,
- salt: details.salt,
- verifier: details.verifier,
- password: details.password
- },
- {
- headers: {
- Authorization: `Bearer ${details.verificationToken}`
- }
- }
- );
-
- return data;
- }
- });
-};
-
export const useResetPasswordV2 = () => {
return useMutation({
mutationFn: async (details: ResetPasswordV2DTO) => {
diff --git a/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx b/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
index f598dcf7ca..c435242646 100644
--- a/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
+++ b/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
@@ -10,7 +10,6 @@ import { UserEncryptionVersion } from "@app/hooks/api/auth/types";
import { ConfirmEmailStep } from "./components/ConfirmEmailStep";
import { EnterPasswordStep } from "./components/EnterPasswordStep";
-import { InputBackupKeyStep } from "./components/InputBackupKeyStep";
import { RecoveryMethod, SelectRecoveryMethodStep } from "./components/SelectRecoveryMethodStep";
enum Steps {
@@ -87,20 +86,9 @@ export const AccountRecoveryResetPage = () => {
hasEmailAuthEnabled={userDetails.hasEmailAuthEnabled}
/>
)}
- {step === Steps.InputBackupKey && (
- <InputBackupKeyStep
- verificationToken={userDetails.verificationToken}
- onComplete={(key) => {
- setUserDetails((prev) => ({ ...prev, privateKey: key }));
- setStep(Steps.EnterNewPassword);
- }}
- />
- )}
{step === Steps.EnterNewPassword && (
<EnterPasswordStep
verificationToken={userDetails.verificationToken}
- privateKey={userDetails.privateKey}
- encryptionVersion={userDetails.userEncryptionVersion}
onComplete={() => {
navigate({ to: "/login" });
}}
diff --git a/frontend/src/pages/auth/AccountRecoveryResetPage/components/EnterPasswordStep.tsx b/frontend/src/pages/auth/AccountRecoveryResetPage/components/EnterPasswordStep.tsx
index 75dd46d2e3..c81ca2e771 100644
--- a/frontend/src/pages/auth/AccountRecoveryResetPage/components/EnterPasswordStep.tsx
+++ b/frontend/src/pages/auth/AccountRecoveryResetPage/components/EnterPasswordStep.tsx
@@ -1,10 +1,6 @@
-import crypto from "crypto";
-
import { useState } from "react";
import { faCheck, faXmark } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useSearch } from "@tanstack/react-router";
-import jsrp from "jsrp";
import { ChevronLeft } from "lucide-react";
import { checkIsPasswordBreached } from "@app/components/utilities/checks/password/checkIsPasswordBreached";
@@ -15,13 +11,9 @@ import {
numAndSpecialCharRegex,
repeatedCharRegex
} from "@app/components/utilities/checks/password/passwordRegexes";
-import Aes256Gcm from "@app/components/utilities/cryptography/aes-256-gcm";
-import { deriveArgonKey } from "@app/components/utilities/cryptography/crypto";
import { FormControl, Input } from "@app/components/v2";
import { Button } from "@app/components/v3";
-import { ROUTE_PATHS } from "@app/const/routes";
-import { useResetPassword, useResetPasswordV2 } from "@app/hooks/api";
-import { UserEncryptionVersion } from "@app/hooks/api/auth/types";
+import { useResetPasswordV2 } from "@app/hooks/api";
type PasswordErrors = {
tooShort: boolean;
@@ -52,22 +44,11 @@ const hasValidationErrors = (errors: PasswordErrors): boolean => {
type Props = {
verificationToken: string;
- privateKey: string;
- encryptionVersion: UserEncryptionVersion;
onComplete: () => void;
onBack: () => void;
};
-export const EnterPasswordStep = ({
- verificationToken,
- encryptionVersion,
- privateKey,
- onComplete,
- onBack
-}: Props) => {
- const search = useSearch({ from: ROUTE_PATHS.Auth.AccountRecoveryResetPage.id });
- const { to: email } = search;
-
+export const EnterPasswordStep = ({ verificationToken, onComplete, onBack }: Props) => {
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [passwordErrors, setPasswordErrors] = useState<PasswordErrors>({
@@ -85,7 +66,6 @@ export const EnterPasswordStep = ({
const passwordsMatch = password === confirmPassword;
const showConfirmError = confirmPassword.length > 0 && !passwordsMatch;
- const { mutateAsync: resetPassword, isPending: isLoading } = useResetPassword();
const { mutateAsync: resetPasswordV2, isPending: isLoadingV2 } = useResetPasswordV2();
const handlePasswordChange = (value: string) => {
@@ -108,82 +88,18 @@ export const EnterPasswordStep = ({
setIsSubmitting(true);
try {
- if (encryptionVersion === UserEncryptionVersion.V2) {
- await resetPasswordV2({
- newPassword: password,
- verificationToken
- });
- onComplete();
- } else {
- // eslint-disable-next-line new-cap
- const client = new jsrp.client();
- client.init(
- {
- username: email,
- password
- },
- async () => {
- client.createVerifier(async (_err: any, result: { salt: string; verifier: string }) => {
- const derivedKey = await deriveArgonKey({
- password,
- salt: result.salt,
- mem: 65536,
- time: 3,
- parallelism: 1,
- hashLen: 32
- });
-
- if (!derivedKey) throw new Error("Failed to derive key from password");
-
- const key = crypto.randomBytes(32);
-
- // create encrypted private key by encrypting the private
- // key with the symmetric key [key]
- const {
- ciphertext: encryptedPrivateKey,
- iv: encryptedPrivateKeyIV,
- tag: encryptedPrivateKeyTag
- } = Aes256Gcm.encrypt({
- text: privateKey,
- secret: key
- });
-
- // create the protected key by encrypting the symmetric key
- // [key] with the derived key
- const {
- ciphertext: protectedKey,
- iv: protectedKeyIV,
- tag: protectedKeyTag
- } = Aes256Gcm.encrypt({
- text: key.toString("hex"),
- secret: Buffer.from(derivedKey.hash)
- });
-
- await resetPassword({
- protectedKey,
- protectedKeyIV,
- protectedKeyTag,
- encryptedPrivateKey,
- encryptedPrivateKeyIV,
- encryptedPrivateKeyTag,
- salt: result.salt,
- verifier: result.verifier,
- verificationToken,
- password
- });
-
- onComplete();
- });
- }
- );
- }
+ await resetPasswordV2({
+ newPassword: password,
+ verificationToken
+ });
+ onComplete();
} finally {
setIsSubmitting(false);
}
};
const isPasswordError = hasValidationErrors(passwordErrors);
- const isFormLoading = isSubmitting || isLoading || isLoadingV2;
+ const isFormLoading = isSubmitting || isLoadingV2;
const validationRules = [
{ key: "tooShort", label: "at least 14 characters", hasError: passwordErrors.tooShort },
diff --git a/frontend/src/pages/auth/AccountRecoveryResetPage/components/InputBackupKeyStep.tsx b/frontend/src/pages/auth/AccountRecoveryResetPage/components/InputBackupKeyStep.tsx
deleted file mode 100644
index 9adc04e1d6..0000000000
--- a/frontend/src/pages/auth/AccountRecoveryResetPage/components/InputBackupKeyStep.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import { Controller, useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-
-import Aes256Gcm from "@app/components/utilities/cryptography/aes-256-gcm";
-import { Button, FormControl, Input } from "@app/components/v2";
-import { getBackupEncryptedPrivateKey } from "@app/hooks/api/auth/queries";
-
-type Props = {
- verificationToken: string;
- onComplete: (privateKey: string) => void;
-};
-
-const formData = z.object({
- backupKey: z.string()
-});
-type TFormData = z.infer<typeof formData>;
-
-export const InputBackupKeyStep = ({ verificationToken, onComplete }: Props) => {
- const { control, handleSubmit, setError } = useForm<TFormData>({
- resolver: zodResolver(formData)
- });
-
- const getEncryptedKeyHandler = async (data: z.infer<typeof formData>) => {
- try {
- const result = await getBackupEncryptedPrivateKey({ verificationToken });
-
- const privateKey = Aes256Gcm.decrypt({
- ciphertext: result.encryptedPrivateKey,
- iv: result.iv,
- tag: result.tag,
- secret: data.backupKey
- });
-
- onComplete(privateKey);
- // setStep(3);
- } catch (err) {
- console.error(err);
- setError("backupKey", { message: "Failed to decrypt private key" });
- }
- };
-
- return (
- <form
- onSubmit={handleSubmit(getEncryptedKeyHandler)}
- className="mx-auto flex w-full flex-col items-center justify-center"
- >
- <h1 className="mb-2 bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-xl font-medium text-transparent">
- Enter your backup key
- </h1>
- <p className="w-max justify-center text-center text-sm text-gray-400">
- You can find it in your emergency kit you downloaded during signup.
- </p>
- <div className="mt-8 w-1/4 min-w-[21.2rem] rounded-md text-center md:min-w-[20.1rem] lg:w-1/6">
- <Controller
- control={control}
- name="backupKey"
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <FormControl
- className="w-full"
- isError={Boolean(error)}
- errorText={error?.message}
- label="Backup Key"
- >
- <Input
- className="w-full"
- value={value}
- onChange={onChange}
- placeholder="08af467b815ffa412f2c98cc3326acdb"
- />
- </FormControl>
- )}
- />
- </div>
- <div className="w-1/4 min-w-[21.2rem] rounded-md text-center md:min-w-[20.1rem] lg:w-1/6">
- <Button
- type="submit"
- size="sm"
- isFullWidth
- className="h-10"
- colorSchema="primary"
- variant="solid"
- >
- Submit Backup Key
- </Button>
- </div>
- </form>
- );
-};
diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
index 63aa8e8320..35eca6db39 100644
--- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
@@ -23,7 +23,7 @@ import {
useSelectOrganization
} from "@app/hooks/api";
import { MfaMethod, UserAgentType } from "@app/hooks/api/auth/types";
-import { getAuthToken, isLoggedIn, setAuthToken } from "@app/hooks/api/reactQuery";
+import { getAuthToken, setAuthToken } from "@app/hooks/api/reactQuery";
import { AuthMethod, SAML_AUTH_METHODS } from "@app/hooks/api/users/types";
import { navigateUserToOrg } from "../LoginPage/Login.utils";
@@ -244,23 +244,6 @@ export const SelectOrgPage = () => {
[selectOrg, callbackPort, isBreakglassRoute, user, router, toggleShowMfa, navigate]
);
- // CLI redirect on mount
- // eslint-disable-next-line react-hooks/exhaustive-deps
- useMemo(() => {
- if (callbackPort) {
- const authToken = getAuthToken();
- if (authToken && !callbackPort) {
- const decodedJwt = jwtDecode(authToken) as any;
- if (decodedJwt?.organizationId) {
- navigateUserToOrg({ navigate, organizationId: decodedJwt.organizationId });
- }
- }
- if (!isLoggedIn()) {
- navigate({ to: "/login" });
- }
- }
- }, []);
-
// MFA pending from IdP redirect
// eslint-disable-next-line react-hooks/exhaustive-deps
useMemo(() => {
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgEmailDomainsSection/OrgEmailDomainsSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgEmailDomainsSection/OrgEmailDomainsSection.tsx
index f4f9d54349..66d35af223 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgEmailDomainsSection/OrgEmailDomainsSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgEmailDomainsSection/OrgEmailDomainsSection.tsx
@@ -25,12 +25,11 @@ export const OrgEmailDomainsSection = () => {
return (
<>
- <hr className="border-mineshaft-600" />
- <div className="pt-4">
+ <div className="mb-4 space-y-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
<div className="mb-4 flex items-center justify-between">
<div>
<p className="text-xl font-medium text-gray-200">Email Domains</p>
- <p className="mt-1 text-sm text-gray-400">
+ <p className="mt-1 mb-2 text-gray-400">
Verify ownership of your email domains to use with SSO and identity providers.
</p>
</div>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgSsoTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgSsoTab.tsx
index 3740783670..76ab52ab12 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgSsoTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgSsoTab.tsx
@@ -193,7 +193,7 @@ export const OrgSsoTab = withPermission(
isLdapActive={Boolean(ldapConfig?.isActive)}
/>
)}
-
+ <OrgEmailDomainsSection />
{shouldShowCreateIdentityProviderView ? (
createIdentityProviderView
) : (
@@ -206,7 +206,6 @@ export const OrgSsoTab = withPermission(
</div>
)}
</div>
- <OrgEmailDomainsSection />
<UpgradePlanModal
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}