Skip to content

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

feat: updated all required changes

=7004e391fc42
diff --git a/backend/src/ee/routes/v1/ldap-router.ts b/backend/src/ee/routes/v1/ldap-router.ts
index 8771e2b89b..cb19f53c29 100644
--- a/backend/src/ee/routes/v1/ldap-router.ts
+++ b/backend/src/ee/routes/v1/ldap-router.ts
@@ -77,19 +77,10 @@ export const registerLdapRouter = async (server: FastifyZodProvider) => {
const externalId = ldapConfig.uniqueUserAttribute ? user[ldapConfig.uniqueUserAttribute] : user.uidNumber;
const username = ldapConfig.uniqueUserAttribute ? externalId : user.uid;
- // had to put any due to passport ts issue with signature
- let callbackPort: number | undefined;
- try {
- const relayStatePayload =
- typeof fastifyReq?.body === "object"
- ? (fastifyReq.body as { RelayState?: string })?.RelayState
- : undefined;
- if (relayStatePayload && Buffer.byteLength(relayStatePayload) <= 1024) {
- callbackPort = Number(JSON.parse(relayStatePayload)?.callbackPort);
- }
- } catch (err) {
- logger.error(err, "Relay state parsing failed");
- }
+ const callbackPort =
+ typeof fastifyReq?.body === "object"
+ ? (fastifyReq.body as { callbackPort?: number })?.callbackPort
+ : undefined;
const loginResult = await server.services.ldap.ldapLogin({
externalId,
@@ -122,7 +113,8 @@ export const registerLdapRouter = async (server: FastifyZodProvider) => {
},
schema: {
body: z.object({
- organizationSlug: z.string().trim()
+ organizationSlug: z.string().trim(),
+ callbackPort: z.coerce.number().optional()
})
},
preValidation: passport.authenticate("ldapauth", {
@@ -143,9 +135,14 @@ export const registerLdapRouter = async (server: FastifyZodProvider) => {
sameSite: "strict",
secure: appCfg.HTTPS_ENABLED
});
- nextUrl = `${appCfg.SITE_URL}/login/select-organization${cbPort ? `?callback_port=${cbPort}` : ""}`;
+ const sessionUrl = new URL("/login/select-organization", appCfg.SITE_URL);
+ if (cbPort) sessionUrl.searchParams.set("callback_port", String(cbPort));
+ nextUrl = sessionUrl.toString();
} else if (passportResult.result === ProviderAuthResult.SIGNUP_REQUIRED) {
- nextUrl = `${appCfg.SITE_URL}/signup/sso?token=${encodeURIComponent(passportResult.signupToken)}${cbPort ? `&callback_port=${cbPort}` : ""}`;
+ const signupUrl = new URL("/signup/sso", appCfg.SITE_URL);
+ signupUrl.searchParams.set("token", passportResult.signupToken);
+ if (cbPort) signupUrl.searchParams.set("callback_port", String(cbPort));
+ nextUrl = signupUrl.toString();
} else {
throw new BadRequestError({ message: "Unexpected auth result" });
}
diff --git a/backend/src/ee/routes/v1/oidc-router.ts b/backend/src/ee/routes/v1/oidc-router.ts
index d7b730a300..614b4ea73d 100644
--- a/backend/src/ee/routes/v1/oidc-router.ts
+++ b/backend/src/ee/routes/v1/oidc-router.ts
@@ -152,13 +152,16 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
secure: appCfg.HTTPS_ENABLED
});
addAuthOriginDomainCookie(res);
- return res.redirect(`${appCfg.SITE_URL}/login/select-organization${cbPort ? `?callback_port=${cbPort}` : ""}`);
+ const sessionUrl = new URL("/login/select-organization", appCfg.SITE_URL);
+ if (cbPort) sessionUrl.searchParams.set("callback_port", String(cbPort));
+ return res.redirect(sessionUrl.toString());
}
if (passportResult.result === ProviderAuthResult.SIGNUP_REQUIRED) {
- return res.redirect(
- `${appCfg.SITE_URL}/signup/sso?token=${encodeURIComponent(passportResult.signupToken)}${cbPort ? `&callback_port=${cbPort}` : ""}`
- );
+ const signupUrl = new URL("/signup/sso", appCfg.SITE_URL);
+ signupUrl.searchParams.set("token", passportResult.signupToken);
+ if (cbPort) signupUrl.searchParams.set("callback_port", String(cbPort));
+ return res.redirect(signupUrl.toString());
}
throw new Error("Unexpected auth result");
diff --git a/backend/src/ee/routes/v1/saml-router.ts b/backend/src/ee/routes/v1/saml-router.ts
index 6cb46de95d..7bd34b608f 100644
--- a/backend/src/ee/routes/v1/saml-router.ts
+++ b/backend/src/ee/routes/v1/saml-router.ts
@@ -338,13 +338,16 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
secure: appCfg.HTTPS_ENABLED
});
addAuthOriginDomainCookie(res);
- return res.redirect(`${appCfg.SITE_URL}/login/select-organization${cbPort ? `?callback_port=${cbPort}` : ""}`);
+ const sessionUrl = new URL("/login/select-organization", appCfg.SITE_URL);
+ if (cbPort) sessionUrl.searchParams.set("callback_port", String(cbPort));
+ return res.redirect(sessionUrl.toString());
}
if (passportResult.result === ProviderAuthResult.SIGNUP_REQUIRED) {
- return res.redirect(
- `${appCfg.SITE_URL}/signup/sso?token=${encodeURIComponent(passportResult.signupToken)}${cbPort ? `&callback_port=${cbPort}` : ""}`
- );
+ const signupUrl = new URL("/signup/sso", appCfg.SITE_URL);
+ signupUrl.searchParams.set("token", passportResult.signupToken);
+ if (cbPort) signupUrl.searchParams.set("callback_port", String(cbPort));
+ return res.redirect(signupUrl.toString());
}
throw new BadRequestError({ message: "Unexpected auth result" });
diff --git a/backend/src/ee/services/email-domain/email-domain-dal.ts b/backend/src/ee/services/email-domain/email-domain-dal.ts
index 45997e217b..c612f8a393 100644
--- a/backend/src/ee/services/email-domain/email-domain-dal.ts
+++ b/backend/src/ee/services/email-domain/email-domain-dal.ts
@@ -1,11 +1,43 @@
import { TDbClient } from "@app/db";
import { TableName } from "@app/db/schemas";
-import { ormify } from "@app/lib/knex";
+import { ormify, selectAllTableCols } from "@app/lib/knex";
export type TEmailDomainDALFactory = ReturnType<typeof emailDomainDALFactory>;
export const emailDomainDALFactory = (db: TDbClient) => {
const emailDomainOrm = ormify(db, TableName.EmailDomains);
- return emailDomainOrm;
+ const findByFilter = async ({
+ offset,
+ limit,
+ searchTerm
+ }: {
+ offset: number;
+ limit: number;
+ searchTerm?: string;
+ }) => {
+ const query = db
+ .replicaNode()(TableName.EmailDomains)
+ .leftJoin(TableName.Organization, `${TableName.EmailDomains}.orgId`, `${TableName.Organization}.id`)
+ .select(
+ selectAllTableCols(TableName.EmailDomains),
+ db.ref("name").withSchema(TableName.Organization).as("orgName")
+ );
+
+ if (searchTerm) {
+ void query.where((qb) => {
+ void qb
+ .where(`${TableName.EmailDomains}.domain`, "ilike", `%${searchTerm}%`)
+ .orWhere(`${TableName.Organization}.name`, "ilike", `%${searchTerm}%`);
+ });
+ }
+
+ const countQuery = query.clone().clearSelect().count(`${TableName.EmailDomains}.id as count`).first();
+ const domains = await query.clone().orderBy(`${TableName.EmailDomains}.domain`, "asc").limit(limit).offset(offset);
+ const countResult = (await countQuery) as { count?: string } | undefined;
+
+ return { emailDomains: domains, total: Number(countResult?.count || 0) };
+ };
+
+ return { ...emailDomainOrm, findByFilter };
};
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 4f83827f3b..8eb44a0671 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -1135,6 +1135,7 @@ export const registerRoutes = async (
userDAL,
identityDAL,
userAliasDAL,
+ emailDomainDAL,
identityTokenAuthDAL,
identityAccessTokenDAL,
authService: loginService,
diff --git a/backend/src/server/routes/v1/account-recovery-router.ts b/backend/src/server/routes/v1/account-recovery-router.ts
index 8e21430515..28db274a53 100644
--- a/backend/src/server/routes/v1/account-recovery-router.ts
+++ b/backend/src/server/routes/v1/account-recovery-router.ts
@@ -1,9 +1,10 @@
import { z } from "zod";
-import { UsersSchema } from "@app/db/schemas";
import { authRateLimit, smtpRateLimit } from "@app/server/config/rateLimiter";
import { UserEncryption } from "@app/services/user/user-types";
+import { SanitizedUserSchema } from "../sanitizedSchemas";
+
export const registerAccountRecoveryRouter = async (server: FastifyZodProvider) => {
server.route({
method: "POST",
@@ -49,7 +50,7 @@ export const registerAccountRecoveryRouter = async (server: FastifyZodProvider)
}),
response: {
200: z.object({
- user: UsersSchema,
+ user: SanitizedUserSchema,
token: z.string(),
userEncryptionVersion: z.nativeEnum(UserEncryption)
})
diff --git a/backend/src/server/routes/v1/admin-router.ts b/backend/src/server/routes/v1/admin-router.ts
index c90efe01fd..7fd8224140 100644
--- a/backend/src/server/routes/v1/admin-router.ts
+++ b/backend/src/server/routes/v1/admin-router.ts
@@ -2,12 +2,12 @@ import DOMPurify from "isomorphic-dompurify";
import { z } from "zod";
import {
+ EmailDomainsSchema,
IdentitiesSchema,
OrganizationsSchema,
OrgMembershipsSchema,
OrgMembershipStatus,
- SuperAdminSchema,
- UsersSchema
+ SuperAdminSchema as SuperAdminDbSchema
} from "@app/db/schemas";
import { getLicenseKeyConfig } from "@app/ee/services/license/license-fns";
import { LicenseType } from "@app/ee/services/license/license-types";
@@ -27,6 +27,12 @@ import { getServerCfg } from "@app/services/super-admin/super-admin-service";
import { CacheType, LoginMethod } from "@app/services/super-admin/super-admin-types";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
+import { SanitizedUserSchema } from "../sanitizedSchemas";
+
+const SuperAdminSchema = SanitizedUserSchema.extend({
+ superAdmin: z.boolean().optional().nullable()
+});
+
export const registerAdminRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
@@ -38,7 +44,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
operationId: "getAdminConfig",
response: {
200: z.object({
- config: SuperAdminSchema.omit({
+ config: SuperAdminDbSchema.omit({
createdAt: true,
updatedAt: true,
encryptedSlackClientId: true,
@@ -211,14 +217,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- users: UsersSchema.pick({
- username: true,
- firstName: true,
- lastName: true,
- email: true,
- id: true,
- superAdmin: true
- }).array(),
+ users: SuperAdminSchema.array(),
total: z.number()
})
}
@@ -497,13 +496,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- users: UsersSchema.pick({
- username: true,
- firstName: true,
- lastName: true,
- email: true,
- id: true
- })
+ users: SuperAdminSchema
})
}
},
@@ -534,13 +527,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- users: UsersSchema.pick({
- username: true,
- firstName: true,
- lastName: true,
- email: true,
- id: true
- }).array()
+ users: SuperAdminSchema.array()
})
}
},
@@ -650,7 +637,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
message: z.string(),
- user: UsersSchema,
+ user: SanitizedUserSchema,
organization: OrganizationsSchema,
token: z.string(),
new: z.string()
@@ -762,13 +749,7 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- user: UsersSchema.pick({
- username: true,
- firstName: true,
- lastName: true,
- email: true,
- id: true
- })
+ user: SanitizedUserSchema
})
}
},
@@ -802,13 +783,14 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
message: z.string(),
- user: UsersSchema.pick({
+ user: SanitizedUserSchema.pick({
username: true,
firstName: true,
lastName: true,
email: true,
- id: true,
- superAdmin: true
+ id: true
+ }).extend({
+ superAdmin: z.boolean().optional().nullable()
}),
organization: OrganizationsSchema.pick({
id: true,
@@ -1061,4 +1043,92 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
};
}
});
+
+ // Email domain management
+ server.route({
+ method: "GET",
+ url: "/email-domain-management/domains",
+ config: {
+ rateLimit: readLimit
+ },
+ schema: {
+ operationId: "listAdminEmailDomains",
+ querystring: z.object({
+ searchTerm: z.string().default(""),
+ offset: z.coerce.number().default(0),
+ limit: z.coerce.number().max(100).default(20)
+ }),
+ response: {
+ 200: z.object({
+ emailDomains: EmailDomainsSchema.extend({ orgName: z.string().nullable() }).array(),
+ total: z.number()
+ })
+ }
+ },
+ onRequest: (req, res, done) => {
+ verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN])(req, res, () => {
+ verifySuperAdmin(req, res, done);
+ });
+ },
+ handler: async (req) => {
+ return server.services.superAdmin.getEmailDomains(req.query);
+ }
+ });
+
+ server.route({
+ method: "POST",
+ url: "/email-domain-management/domains",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ operationId: "createAdminEmailDomain",
+ body: z.object({
+ orgId: z.string().uuid(),
+ domain: z.string().trim().toLowerCase().min(1)
+ }),
+ response: {
+ 200: z.object({
+ emailDomain: EmailDomainsSchema
+ })
+ }
+ },
+ onRequest: (req, res, done) => {
+ verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN])(req, res, () => {
+ verifySuperAdmin(req, res, done);
+ });
+ },
+ handler: async (req) => {
+ const emailDomain = await server.services.superAdmin.createEmailDomain(req.body);
+ return { emailDomain };
+ }
+ });
+
+ server.route({
+ method: "DELETE",
+ url: "/email-domain-management/domains/:emailDomainId",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ operationId: "deleteAdminEmailDomain",
+ params: z.object({
+ emailDomainId: z.string().uuid()
+ }),
+ response: {
+ 200: z.object({
+ emailDomain: EmailDomainsSchema
+ })
+ }
+ },
+ onRequest: (req, res, done) => {
+ verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN])(req, res, () => {
+ verifySuperAdmin(req, res, done);
+ });
+ },
+ handler: async (req) => {
+ const emailDomain = await server.services.superAdmin.deleteEmailDomain(req.params);
+ return { emailDomain };
+ }
+ });
};
diff --git a/backend/src/server/routes/v1/deprecated-project-membership-router.ts b/backend/src/server/routes/v1/deprecated-project-membership-router.ts
index 3e8a25829b..3212e48d29 100644
--- a/backend/src/server/routes/v1/deprecated-project-membership-router.ts
+++ b/backend/src/server/routes/v1/deprecated-project-membership-router.ts
@@ -7,8 +7,7 @@ import {
OrgMembershipStatus,
ProjectMembershipsSchema,
ProjectUserMembershipRolesSchema,
- TemporaryPermissionMode,
- UsersSchema
+ TemporaryPermissionMode
} from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { ApiDocsTags, PROJECT_USERS } from "@app/lib/api-docs";
@@ -17,6 +16,8 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
+import { SanitizedUserSchema } from "../sanitizedSchemas";
+
export const registerDeprecatedProjectMembershipRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
@@ -39,15 +40,7 @@ export const registerDeprecatedProjectMembershipRouter = async (server: FastifyZ
response: {
200: z.object({
memberships: ProjectMembershipsSchema.extend({
- user: UsersSchema.pick({
- email: true,
- firstName: true,
- lastName: true,
- id: true,
- username: true
- }).extend({
- publicKey: z.string().optional().nullable()
- }),
+ user: SanitizedUserSchema,
roles: z.array(
z.object({
id: z.string(),
@@ -110,15 +103,7 @@ export const registerDeprecatedProjectMembershipRouter = async (server: FastifyZ
response: {
200: z.object({
membership: ProjectMembershipsSchema.extend({
- user: UsersSchema.pick({
- email: true,
- firstName: true,
- lastName: true,
- id: true,
- username: true
- }).extend({
- publicKey: z.string().optional().nullable()
- }),
+ user: SanitizedUserSchema,
roles: z.array(
z.object({
id: z.string(),
@@ -190,14 +175,7 @@ export const registerDeprecatedProjectMembershipRouter = async (server: FastifyZ
response: {
200: z.object({
membership: ProjectMembershipsSchema.extend({
- user: UsersSchema.pick({
- email: true,
- firstName: true,
- lastName: true,
- id: true
- }).extend({
- publicKey: z.string().optional().nullable()
- }),
+ user: SanitizedUserSchema,
roles: z.array(
z.object({
id: z.string(),
diff --git a/backend/src/server/routes/v1/invite-org-router.ts b/backend/src/server/routes/v1/invite-org-router.ts
index db61057c7b..55cd5f892d 100644
--- a/backend/src/server/routes/v1/invite-org-router.ts
+++ b/backend/src/server/routes/v1/invite-org-router.ts
@@ -1,6 +1,6 @@
import { z } from "zod";
-import { AccessScope, OrgMembershipRole, UsersSchema } from "@app/db/schemas";
+import { AccessScope, OrgMembershipRole } from "@app/db/schemas";
import { inviteUserRateLimit, smtpRateLimit } from "@app/server/config/rateLimiter";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
@@ -132,13 +132,12 @@ export const registerInviteOrgRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
message: z.string(),
- token: z.string().optional(),
- user: UsersSchema
+ token: z.string().optional()
})
}
},
handler: async (req) => {
- const { user, token } = await server.services.org.verifyUserToOrg({
+ const { token } = await server.services.org.verifyUserToOrg({
orgId: req.body.organizationId,
code: req.body.code,
email: req.body.email
@@ -146,7 +145,6 @@ export const registerInviteOrgRouter = async (server: FastifyZodProvider) => {
return {
message: "Successfully verified email",
- user,
token
};
}
diff --git a/backend/src/server/routes/v1/project-membership-router.ts b/backend/src/server/routes/v1/project-membership-router.ts
index dcd58abec1..583c13e574 100644
--- a/backend/src/server/routes/v1/project-membership-router.ts
+++ b/backend/src/server/routes/v1/project-membership-router.ts
@@ -5,8 +5,7 @@ import {
ProjectMembershipRole,
ProjectMembershipsSchema,
ProjectUserMembershipRolesSchema,
- TemporaryPermissionMode,
- UsersSchema
+ TemporaryPermissionMode
} from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { ApiDocsTags, PROJECT_USERS } from "@app/lib/api-docs";
@@ -15,6 +14,8 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
+import { SanitizedUserSchema } from "../sanitizedSchemas";
+
export const registerProjectMembershipRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
@@ -37,15 +38,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
response: {
200: z.object({
memberships: ProjectMembershipsSchema.extend({
- user: UsersSchema.pick({
- email: true,
- firstName: true,
- lastName: true,
- id: true,
- username: true
- }).extend({
- publicKey: z.string().optional().nullable()
- }),
+ user: SanitizedUserSchema,
roles: z.array(
z.object({
id: z.string(),
@@ -109,15 +102,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
response: {
200: z.object({
membership: ProjectMembershipsSchema.extend({
- user: UsersSchema.pick({
- email: true,
- firstName: true,
- lastName: true,
- id: true,
- username: true
- }).extend({
- publicKey: z.string().optional().nullable()
- }),
+ user: SanitizedUserSchema,
roles: z.array(
z.object({
id: z.string(),
@@ -190,14 +175,7 @@ export const registerProjectMembershipRouter = async (server: FastifyZodProvider
response: {
200: z.object({
membership: ProjectMembershipsSchema.extend({
- user: UsersSchema.pick({
- email: true,
- firstName: true,
- lastName: true,
- id: true
- }).extend({
- publicKey: z.string().optional().nullable()
- }),
+ user: SanitizedUserSchema,
roles: z.array(
z.object({
id: z.string(),
diff --git a/backend/src/server/routes/v1/sso-router.ts b/backend/src/server/routes/v1/sso-router.ts
index 0e128c0286..b3ea4d6897 100644
--- a/backend/src/server/routes/v1/sso-router.ts
+++ b/backend/src/server/routes/v1/sso-router.ts
@@ -393,25 +393,19 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
secure: appCfg.HTTPS_ENABLED
});
addAuthOriginDomainCookie(res);
- const sessionParams = [
- isAdminLogin ? `isAdminLogin=${isAdminLogin}` : "",
- cbPort ? `callback_port=${cbPort}` : ""
- ]
- .filter(Boolean)
- .join("&");
- return res.redirect(`${appCfg.SITE_URL}/login/select-organization${sessionParams ? `?${sessionParams}` : ""}`);
+ const sessionUrl = new URL("/login/select-organization", appCfg.SITE_URL);
+ if (isAdminLogin) sessionUrl.searchParams.set("isAdminLogin", isAdminLogin);
+ if (cbPort) sessionUrl.searchParams.set("callback_port", String(cbPort));
+ return res.redirect(sessionUrl.toString());
}
if (passportResult.result === ProviderAuthResult.SIGNUP_REQUIRED) {
const serverCfg = await getServerCfg();
- const signupParams = [
- `token=${encodeURIComponent(passportResult.signupToken)}`,
- serverCfg.defaultAuthOrgId && !appCfg.isCloud ? "defaultOrgAllowed=true" : "",
- cbPort ? `callback_port=${cbPort}` : ""
- ]
- .filter(Boolean)
- .join("&");
- return res.redirect(`${appCfg.SITE_URL}/signup/sso?${signupParams}`);
+ const signupUrl = new URL("/signup/sso", appCfg.SITE_URL);
+ signupUrl.searchParams.set("token", passportResult.signupToken);
+ if (serverCfg.defaultAuthOrgId && !appCfg.isCloud) signupUrl.searchParams.set("defaultOrgAllowed", "true");
+ if (cbPort) signupUrl.searchParams.set("callback_port", String(cbPort));
+ return res.redirect(signupUrl.toString());
}
throw new BadRequestError({ message: "Unexpected auth result" });
@@ -522,7 +516,7 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
path: "/api",
sameSite: "strict",
secure: appCfg.HTTPS_ENABLED,
- expires: new Date(Date.now() + ms("15m"))
+ expires: new Date(Date.now() + ms(appCfg.JWT_PROVIDER_AUTH_LIFETIME))
});
}
return handleOAuthCallbackRedirect(req, res);
diff --git a/backend/src/server/routes/v1/user-router.ts b/backend/src/server/routes/v1/user-router.ts
index 5c51c32ea2..b11d7420da 100644
--- a/backend/src/server/routes/v1/user-router.ts
+++ b/backend/src/server/routes/v1/user-router.ts
@@ -8,6 +8,10 @@ import { authRateLimit, readLimit, writeLimit } from "@app/server/config/rateLim
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
+const SantizedUserSchema = UsersSchema.omit({
+ hashedPassword: true
+});
+
export const registerUserRouter = async (server: FastifyZodProvider) => {
const appCfg = getConfig();
@@ -21,7 +25,7 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {
operationId: "getCurrentUserV1",
response: {
200: z.object({
- user: UsersSchema.extend({
+ user: SantizedUserSchema.extend({
encryptionVersion: z.number()
})
})
@@ -44,7 +48,7 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {
operationId: "getDuplicateUserAccounts",
response: {
200: z.object({
- users: UsersSchema.extend({
+ users: SantizedUserSchema.extend({
isMyAccount: z.boolean(),
organizations: z.object({ name: z.string(), slug: z.string() }).array()
}).array()
diff --git a/backend/src/server/routes/v2/user-router.ts b/backend/src/server/routes/v2/user-router.ts
index a57bb3f013..ac53954997 100644
--- a/backend/src/server/routes/v2/user-router.ts
+++ b/backend/src/server/routes/v2/user-router.ts
@@ -1,12 +1,14 @@
import { z } from "zod";
-import { AuthTokenSessionsSchema, UsersSchema } from "@app/db/schemas";
+import { AuthTokenSessionsSchema } from "@app/db/schemas";
import { ApiKeysSchema } from "@app/db/schemas/api-keys";
import { readLimit, smtpRateLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMethod, AuthMode, MfaMethod } from "@app/services/auth/auth-type";
import { sanitizedOrganizationSchema } from "@app/services/org/org-schema";
+import { SanitizedUserSchema } from "../sanitizedSchemas";
+
export const registerUserRouter = async (server: FastifyZodProvider) => {
server.route({
method: "POST",
@@ -45,7 +47,7 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- user: UsersSchema
+ user: SanitizedUserSchema
})
}
},
@@ -75,7 +77,7 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- user: UsersSchema
+ user: SanitizedUserSchema
})
}
},
@@ -99,7 +101,7 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- user: UsersSchema
+ user: SanitizedUserSchema
})
}
},
@@ -154,7 +156,7 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {
}),
response: {
200: z.object({
- user: UsersSchema
+ user: SanitizedUserSchema
})
}
},
@@ -391,7 +393,7 @@ export const registerUserRouter = async (server: FastifyZodProvider) => {
operationId: "deleteUser",
response: {
200: z.object({
- user: UsersSchema
+ user: SanitizedUserSchema
})
}
},
diff --git a/backend/src/server/routes/v3/signup-router.ts b/backend/src/server/routes/v3/signup-router.ts
index 3197fe460a..c6b079746d 100644
--- a/backend/src/server/routes/v3/signup-router.ts
+++ b/backend/src/server/routes/v3/signup-router.ts
@@ -1,6 +1,5 @@
import { z } from "zod";
-import { UsersSchema } from "@app/db/schemas";
import { getConfig } from "@app/lib/config/env";
import { ForbiddenRequestError } from "@app/lib/errors";
import { authRateLimit, smtpRateLimit } from "@app/server/config/rateLimiter";
@@ -10,6 +9,8 @@ import { CompleteAccountType } from "@app/services/auth/auth-signup-type";
import { getServerCfg } from "@app/services/super-admin/super-admin-service";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
+import { SanitizedUserSchema } from "../sanitizedSchemas";
+
export const registerSignupRouter = async (server: FastifyZodProvider) => {
server.route({
url: "/email/signup",
@@ -72,7 +73,7 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
200: z.object({
message: z.string(),
token: z.string(),
- user: UsersSchema
+ user: SanitizedUserSchema
})
}
},
@@ -115,7 +116,7 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
message: z.string(),
- user: UsersSchema,
+ user: SanitizedUserSchema,
token: z.string()
})
}
diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts
index 45f8bf0c41..b8c5cf8fca 100644
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@ -1193,6 +1193,7 @@ export const authLoginServiceFactory = ({
rootOrg.authEnforced &&
!isAuthMethodSaml(userAuthMethod) &&
userAuthMethod !== AuthMethod.OIDC &&
+ userAuthMethod !== AuthMethod.LDAP &&
!canBypassSso
) {
throw new BadRequestError({
@@ -1215,6 +1216,18 @@ export const authLoginServiceFactory = ({
});
}
+ if (!isSubOrganization && orgMembership.status !== OrgMembershipStatus.Accepted) {
+ // Promote any Invited memberships to Accepted now that the user has authenticated into this org
+ await membershipUserDAL.update(
+ {
+ actorUserId: user.id,
+ scopeOrgId: organizationId,
+ scope: AccessScope.Organization
+ },
+ { status: OrgMembershipStatus.Accepted }
+ );
+ }
+
const { isMfaRequired, requiredMfaMethod } = getRequiredMfaMethod(rootOrg, user);
// Check if organization has changed
const hasOrganizationChanged = actorOrgId ? actorOrgId !== rootOrg.id : false;
@@ -1250,24 +1263,15 @@ export const authLoginServiceFactory = ({
mfaMethod
});
- // Promote any Invited memberships to Accepted now that the user has authenticated into this org
- await membershipUserDAL.update(
- {
- actorUserId: user.id,
- scopeOrgId: organizationId,
- scope: AccessScope.Organization,
- status: OrgMembershipStatus.Invited
- },
- { status: OrgMembershipStatus.Accepted }
- );
-
// In the event of this being a break-glass request (non-saml / non-oidc / non-google, when any is enforced)
const isAuthEnforcedBypass =
rootOrg.authEnforced &&
rootOrg.bypassOrgAuthEnabled &&
!isAuthMethodSaml(userAuthMethod) &&
userAuthMethod !== AuthMethod.OIDC &&
+ userAuthMethod !== AuthMethod.LDAP &&
userAuthMethod !== AuthMethod.GOOGLE;
+
const isGoogleSsoEnforcedBypass =
rootOrg.googleSsoAuthEnforced && rootOrg.bypassOrgAuthEnabled && userAuthMethod !== AuthMethod.GOOGLE;
if (isAuthEnforcedBypass || isGoogleSsoEnforcedBypass) {
diff --git a/backend/src/services/super-admin/super-admin-service.ts b/backend/src/services/super-admin/super-admin-service.ts
index fd122030a2..8120291003 100644
--- a/backend/src/services/super-admin/super-admin-service.ts
+++ b/backend/src/services/super-admin/super-admin-service.ts
@@ -9,6 +9,7 @@ import {
TSuperAdminUpdate,
TUsers
} from "@app/db/schemas";
+import { TEmailDomainDALFactory } from "@app/ee/services/email-domain/email-domain-dal";
import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { PgSqlLock, TKeyStoreFactory } from "@app/keystore/keystore";
import { withCache } from "@app/lib/cache/with-cache";
@@ -54,6 +55,9 @@ import {
EnvOverrides,
LoginMethod,
TAdminBootstrapInstanceDTO,
+ TAdminCreateEmailDomainDTO,
+ TAdminDeleteEmailDomainDTO,
+ TAdminGetEmailDomainsDTO,
TAdminGetIdentitiesDTO,
TAdminGetUsersDTO,
TAdminIntegrationConfig,
@@ -74,6 +78,7 @@ type TSuperAdminServiceFactoryDep = {
membershipIdentityDAL: TMembershipIdentityDALFactory;
membershipRoleDAL: TMembershipRoleDALFactory;
userAliasDAL: Pick<TUserAliasDALFactory, "findOne">;
+ emailDomainDAL: TEmailDomainDALFactory;
authService: Pick<TAuthLoginFactory, "generateUserTokens">;
kmsService: Pick<TKmsServiceFactory, "encryptWithRootKey" | "decryptWithRootKey" | "updateEncryptionStrategy">;
kmsRootConfigDAL: TKmsRootConfigDALFactory;
@@ -132,6 +137,7 @@ export const superAdminServiceFactory = ({
identityDAL,
orgDAL,
userAliasDAL,
+ emailDomainDAL,
authService,
orgService,
keyStore,
@@ -1182,6 +1188,39 @@ export const superAdminServiceFactory = ({
return job;
};
+ const getEmailDomains = async ({ offset, limit, searchTerm }: TAdminGetEmailDomainsDTO) => {
+ return emailDomainDAL.findByFilter({ offset, limit, searchTerm });
+ };
+
+ const createEmailDomain = async ({ orgId, domain }: TAdminCreateEmailDomainDTO) => {
+ const org = await orgDAL.findOrgById(orgId);
+ if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
+
+ const existing = await emailDomainDAL.findOne({ orgId, domain: domain.toLowerCase() });
+ if (existing) throw new BadRequestError({ message: `Domain '${domain}' already exists for this organization` });
+
+ const emailDomain = await emailDomainDAL.create({
+ orgId,
+ domain: domain.toLowerCase(),
+ verificationMethod: "admin",
+ verificationCode: crypto.randomBytes(16).toString("hex"),
+ verificationRecordName: `_infisical-verification.${domain.toLowerCase()}`,
+ status: "verified",
+ verifiedAt: new Date(),
+ codeExpiresAt: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000)
+ });
+
+ return emailDomain;
+ };
+
+ const deleteEmailDomain = async ({ emailDomainId }: TAdminDeleteEmailDomainDTO) => {
+ const emailDomain = await emailDomainDAL.findById(emailDomainId);
+ if (!emailDomain) throw new NotFoundError({ message: `Email domain with ID '${emailDomainId}' not found` });
+
+ await emailDomainDAL.deleteById(emailDomainId);
+ return emailDomain;
+ };
+
return {
initServerCfg,
updateServerCfg,
@@ -1208,6 +1247,9 @@ export const superAdminServiceFactory = ({
deleteUsers,
createOrganization,
joinOrganization,
- resendOrgInvite
+ resendOrgInvite,
+ getEmailDomains,
+ createEmailDomain,
+ deleteEmailDomain
};
};
diff --git a/backend/src/services/super-admin/super-admin-types.ts b/backend/src/services/super-admin/super-admin-types.ts
index 6cfdd384d9..95edd96251 100644
--- a/backend/src/services/super-admin/super-admin-types.ts
+++ b/backend/src/services/super-admin/super-admin-types.ts
@@ -34,6 +34,21 @@ export type TGetOrganizationsDTO = {
searchTerm: string;
};
+export type TAdminGetEmailDomainsDTO = {
+ offset: number;
+ limit: number;
+ searchTerm: string;
+};
+
+export type TAdminCreateEmailDomainDTO = {
+ orgId: string;
+ domain: string;
+};
+
+export type TAdminDeleteEmailDomainDTO = {
+ emailDomainId: string;
+};
+
export type TCreateOrganizationDTO = {
name: string;
inviteAdminEmails: string[];
diff --git a/docs/images/platform/email-domain/add-domain-modal.png b/docs/images/platform/email-domain/add-domain-modal.png
index 3142c57a96..becc453561 100644
Binary files a/docs/images/platform/email-domain/add-domain-modal.png and b/docs/images/platform/email-domain/add-domain-modal.png differ
diff --git a/docs/images/platform/email-domain/email-domains-section.png b/docs/images/platform/email-domain/email-domains-section.png
index 52f8643b96..e73067ea5d 100644
Binary files a/docs/images/platform/email-domain/email-domains-section.png and b/docs/images/platform/email-domain/email-domains-section.png differ
diff --git a/docs/images/platform/email-domain/pending.png b/docs/images/platform/email-domain/pending.png
index 693941e341..3c626307ee 100644
Binary files a/docs/images/platform/email-domain/pending.png and b/docs/images/platform/email-domain/pending.png differ
diff --git a/docs/images/platform/email-domain/verification-modal.png b/docs/images/platform/email-domain/verification-modal.png
index bbfe43b414..98f618e12b 100644
Binary files a/docs/images/platform/email-domain/verification-modal.png and b/docs/images/platform/email-domain/verification-modal.png differ
diff --git a/docs/images/platform/email-domain/verified-domain.png b/docs/images/platform/email-domain/verified-domain.png
index b728871f4b..fc6d8dd71f 100644
Binary files a/docs/images/platform/email-domain/verified-domain.png and b/docs/images/platform/email-domain/verified-domain.png differ
diff --git a/frontend/src/hooks/api/admin/mutation.ts b/frontend/src/hooks/api/admin/mutation.ts
index 918a0ecd5e..8517254071 100644
--- a/frontend/src/hooks/api/admin/mutation.ts
+++ b/frontend/src/hooks/api/admin/mutation.ts
@@ -7,7 +7,9 @@ import { organizationKeys } from "../organization/queries";
import { User } from "../users/types";
import { adminQueryKeys, adminStandaloneKeys } from "./queries";
import {
+ AdminEmailDomain,
RootKeyEncryptionStrategy,
+ TAdminCreateEmailDomainDTO,
TCreateAdminUserDTO,
TCreateOrganizationDTO,
TInvalidateCacheDTO,
@@ -252,3 +254,40 @@ export const useGenerateUsageReport = () => {
}
});
};
+
+export const useAdminCreateEmailDomain = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<{ emailDomain: AdminEmailDomain }, object, TAdminCreateEmailDomainDTO>({
+ mutationFn: async (dto) => {
+ const { data } = await apiRequest.post<{ emailDomain: AdminEmailDomain }>(
+ "/api/v1/admin/email-domain-management/domains",
+ dto
+ );
+ return data;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({
+ queryKey: [adminStandaloneKeys.getEmailDomains]
+ });
+ }
+ });
+};
+
+export const useAdminDeleteEmailDomain = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<{ emailDomain: AdminEmailDomain }, object, string>({
+ mutationFn: async (emailDomainId) => {
+ const { data } = await apiRequest.delete<{ emailDomain: AdminEmailDomain }>(
+ `/api/v1/admin/email-domain-management/domains/${emailDomainId}`
+ );
+ return data;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({
+ queryKey: [adminStandaloneKeys.getEmailDomains]
+ });
+ }
+ });
+};
diff --git a/frontend/src/hooks/api/admin/queries.ts b/frontend/src/hooks/api/admin/queries.ts
index ea7226ad60..48d455acb7 100644
--- a/frontend/src/hooks/api/admin/queries.ts
+++ b/frontend/src/hooks/api/admin/queries.ts
@@ -3,10 +3,12 @@ import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import {
+ AdminGetEmailDomainsFilters,
AdminGetIdentitiesFilters,
AdminGetOrganizationsFilters,
AdminGetUsersFilters,
AdminIntegrationsConfig,
+ TGetEmailDomainsResponse,
TGetEnvOverrides,
TGetIdentitiesResponse,
TGetInvalidatingCacheStatus,
@@ -19,7 +21,8 @@ import {
export const adminStandaloneKeys = {
getUsers: "get-users",
getOrganizations: "get-organizations",
- getIdentities: "get-identities"
+ getIdentities: "get-identities",
+ getEmailDomains: "get-email-domains"
};
export const adminQueryKeys = {
@@ -33,7 +36,9 @@ export const adminQueryKeys = {
getServerEncryptionStrategies: () => ["server-encryption-strategies"] as const,
getInvalidateCache: () => ["admin-invalidate-cache"] as const,
getAdminIntegrationsConfig: () => ["admin-integrations-config"] as const,
- getEnvOverrides: () => ["env-overrides"] as const
+ getEnvOverrides: () => ["env-overrides"] as const,
+ getEmailDomains: (filters: AdminGetEmailDomainsFilters) =>
+ [adminStandaloneKeys.getEmailDomains, { filters }] as const
};
export const fetchServerConfig = async () => {
@@ -166,3 +171,17 @@ export const useGetEnvOverrides = () => {
}
});
};
+
+export const useAdminGetEmailDomains = (filters: AdminGetEmailDomainsFilters) => {
+ return useQuery({
+ queryKey: adminQueryKeys.getEmailDomains(filters),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<TGetEmailDomainsResponse>(
+ "/api/v1/admin/email-domain-management/domains",
+ { params: { ...filters } }
+ );
+ return { emailDomains: data.emailDomains, totalCount: data.total };
+ },
+ placeholderData: (previousData) => previousData
+ });
+};
diff --git a/frontend/src/hooks/api/admin/types.ts b/frontend/src/hooks/api/admin/types.ts
index 8888e4bc63..171b82da7b 100644
--- a/frontend/src/hooks/api/admin/types.ts
+++ b/frontend/src/hooks/api/admin/types.ts
@@ -117,6 +117,34 @@ export type AdminGetIdentitiesFilters = {
searchTerm?: string;
};
+export type AdminEmailDomain = {
+ id: string;
+ orgId: string;
+ domain: string;
+ verificationMethod: string;
+ status: string;
+ verifiedAt?: string | null;
+ createdAt: string;
+ updatedAt: string;
+ orgName: string | null;
+};
+
+export type AdminGetEmailDomainsFilters = {
+ limit?: number;
+ offset?: number;
+ searchTerm?: string;
+};
+
+export type TGetEmailDomainsResponse = {
+ emailDomains: AdminEmailDomain[];
+ total: number;
+};
+
+export type TAdminCreateEmailDomainDTO = {
+ orgId: string;
+ domain: string;
+};
+
export type AdminIntegrationsConfig = {
slack: {
clientId: string;
diff --git a/frontend/src/hooks/api/auth/refresh.ts b/frontend/src/hooks/api/auth/refresh.ts
index 043953c416..59ac07b01e 100644
--- a/frontend/src/hooks/api/auth/refresh.ts
+++ b/frontend/src/hooks/api/auth/refresh.ts
@@ -30,14 +30,19 @@ export const fetchAuthToken = async (): Promise<GetAuthTokenAPI> => {
const currentToken = getAuthToken();
if (currentToken) {
try {
- const decoded = jwtDecode<{ organizationId?: string; subOrganizationId?: string }>(
- currentToken
- );
- return {
- token: currentToken,
- organizationId: decoded.organizationId,
- subOrganizationId: decoded.subOrganizationId
- };
+ const decoded = jwtDecode<{
+ organizationId?: string;
+ subOrganizationId?: string;
+ exp?: number;
+ }>(currentToken);
+ // Only reuse if the token has more than 10 seconds before expiry
+ if (decoded.exp && decoded.exp * 1000 > Date.now() + 10_000) {
+ return {
+ token: currentToken,
+ organizationId: decoded.organizationId,
+ subOrganizationId: decoded.subOrganizationId
+ };
+ }
} catch {
// decode failed — fall through to refresh
}
diff --git a/frontend/src/hooks/api/auth/types.ts b/frontend/src/hooks/api/auth/types.ts
index 1e0f8bc645..bc4c27446b 100644
--- a/frontend/src/hooks/api/auth/types.ts
+++ b/frontend/src/hooks/api/auth/types.ts
@@ -89,6 +89,7 @@ export type LoginLDAPDTO = {
organizationSlug: string;
username: string;
password: string;
+ callbackPort?: number;
};
export type LoginLDAPRes = {
diff --git a/frontend/src/layouts/AdminLayout/AdminSidebar.tsx b/frontend/src/layouts/AdminLayout/AdminSidebar.tsx
index 77423035eb..8e4f04ed87 100644
--- a/frontend/src/layouts/AdminLayout/AdminSidebar.tsx
+++ b/frontend/src/layouts/AdminLayout/AdminSidebar.tsx
@@ -10,6 +10,7 @@ import {
HardDrive,
Key,
Lock,
+ Mail,
Plug,
Shield,
ShieldCheck,
@@ -48,7 +49,8 @@ const RESOURCE_OVERVIEW_SUBMENU: AdminSubmenu = {
items: [
{ label: "Organizations", icon: Building, tab: "organizations" },
{ label: "Users", icon: User, tab: "users" },
- { label: "Machine Identities", icon: HardDrive, tab: "identities" }
+ { label: "Machine Identities", icon: HardDrive, tab: "identities" },
+ { label: "Email Domains", icon: Mail, tab: "emailDomains" }
]
};
diff --git a/frontend/src/pages/admin/ResourceOverviewPage/ResourceOverviewPage.tsx b/frontend/src/pages/admin/ResourceOverviewPage/ResourceOverviewPage.tsx
index 567ca2a069..2281717cae 100644
--- a/frontend/src/pages/admin/ResourceOverviewPage/ResourceOverviewPage.tsx
+++ b/frontend/src/pages/admin/ResourceOverviewPage/ResourceOverviewPage.tsx
@@ -4,7 +4,12 @@ import { useSearch } from "@tanstack/react-router";
import { PageHeader } from "@app/components/v2";
-import { MachineIdentitiesTable, OrganizationsTable, UserIdentitiesTable } from "./components";
+import {
+ EmailDomainsTable,
+ MachineIdentitiesTable,
+ OrganizationsTable,
+ UserIdentitiesTable
+} from "./components";
export const ResourceOverviewPage = () => {
const { t } = useTranslation();
@@ -30,6 +35,7 @@ export const ResourceOverviewPage = () => {
{activeTab === "organizations" && <OrganizationsTable />}
{activeTab === "users" && <UserIdentitiesTable />}
{activeTab === "identities" && <MachineIdentitiesTable />}
+ {activeTab === "emailDomains" && <EmailDomainsTable />}
</div>
</div>
</div>
diff --git a/frontend/src/pages/admin/ResourceOverviewPage/components/EmailDomainsTable.tsx b/frontend/src/pages/admin/ResourceOverviewPage/components/EmailDomainsTable.tsx
new file mode 100644
index 0000000000..ce0693cfcb
--- /dev/null
+++ b/frontend/src/pages/admin/ResourceOverviewPage/components/EmailDomainsTable.tsx
@@ -0,0 +1,312 @@
+import { useState } from "react";
+import { Controller, useForm } from "react-hook-form";
+import {
+ faEllipsisV,
+ faGlobe,
+ faMagnifyingGlass,
+ faPlus,
+ faTrash
+} from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { createNotification } from "@app/components/notifications";
+import {
+ Button,
+ DeleteActionModal,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+ EmptyState,
+ FilterableSelect,
+ FormControl,
+ IconButton,
+ Input,
+ Modal,
+ ModalContent,
+ Pagination,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
+import { Badge } from "@app/components/v3";
+import {
+ getUserTablePreference,
+ PreferenceKey,
+ setUserTablePreference
+} from "@app/helpers/userTablePreferences";
+import { useDebounce, usePagination, usePopUp, useResetPageHelper } from "@app/hooks";
+import {
+ useAdminCreateEmailDomain,
+ useAdminDeleteEmailDomain,
+ useAdminGetEmailDomains,
+ useAdminGetOrganizations
+} from "@app/hooks/api";
+import { OrganizationWithProjects } from "@app/hooks/api/admin/types";
+
+const AddEmailDomainSchema = z.object({
+ organization: z.object({ id: z.string(), name: z.string() }),
+ domain: z.string().trim().toLowerCase().min(1, "Domain is required")
+});
+
+type AddEmailDomainFormData = z.infer<typeof AddEmailDomainSchema>;
+
+const AddEmailDomainContent = ({ onClose }: { onClose: () => void }) => {
+ const createEmailDomain = useAdminCreateEmailDomain();
+
+ const {
+ handleSubmit,
+ control,
+ register,
+ formState: { isSubmitting, errors }
+ } = useForm<AddEmailDomainFormData>({
+ resolver: zodResolver(AddEmailDomainSchema)
+ });
+
+ const [searchOrgFilter, setSearchOrgFilter] = useState("");
+ const [debouncedSearchTerm, setDebouncedSearchTerm] = useDebounce(searchOrgFilter, 500);
+
+ const { data, isPending } = useAdminGetOrganizations({
+ limit: 20,
+ searchTerm: debouncedSearchTerm
+ });
+
+ const { organizations = [] } = data ?? {};
+
+ const onSubmit = async ({ organization, domain }: AddEmailDomainFormData) => {
+ try {
+ await createEmailDomain.mutateAsync({ orgId: organization.id, domain });
+ createNotification({ text: "Email domain added successfully", type: "success" });
+ onClose();
+ } catch (err: any) {
+ createNotification({
+ text: err?.response?.data?.message || "Failed to add email domain",
+ type: "error"
+ });
+ }
+ };
+
+ return (
+ <form onSubmit={handleSubmit(onSubmit)}>
+ <Controller
+ control={control}
+ name="organization"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl isError={Boolean(error)} errorText={error?.message} label="Organization">
+ <FilterableSelect<OrganizationWithProjects>
+ isLoading={searchOrgFilter !== debouncedSearchTerm || isPending}
+ placeholder="Search organizations..."
+ options={organizations}
+ getOptionLabel={(org) => org.name}
+ getOptionValue={(org) => org.id}
+ value={field.value as unknown as OrganizationWithProjects}
+ onChange={field.onChange}
+ onInputChange={(value) => {
+ setSearchOrgFilter(value);
+ if (!value) setDebouncedSearchTerm("");
+ }}
+ />
+ </FormControl>
+ )}
+ />
+ <FormControl
+ isError={Boolean(errors.domain)}
+ errorText={errors.domain?.message}
+ label="Domain"
+ >
+ <Input {...register("domain")} placeholder="company.com" />
+ </FormControl>
+ <div className="flex w-full gap-4 pt-4">
+ <Button
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ colorSchema="secondary"
+ >
+ Add Domain
+ </Button>
+ <Button onClick={onClose} variant="plain" colorSchema="secondary">
+ Cancel
+ </Button>
+ </div>
+ </form>
+ );
+};
+
+const AddEmailDomainModal = ({
+ isOpen,
+ onOpenChange
+}: {
+ isOpen: boolean;
+ onOpenChange: (isOpen: boolean) => void;
+}) => {
+ return (
+ <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
+ <ModalContent bodyClassName="overflow-visible" title="Add Verified Email Domain">
+ <AddEmailDomainContent onClose={() => onOpenChange(false)} />
+ </ModalContent>
+ </Modal>
+ );
+};
+
+export const EmailDomainsTable = () => {
+ const [searchFilter, setSearchFilter] = useState("");
+ const [debouncedSearchTerm] = useDebounce(searchFilter, 500);
+
+ const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
+ "deleteEmailDomain",
+ "addEmailDomain"
+ ] as const);
+
+ const { offset, limit, setPage, perPage, page, setPerPage } = usePagination("", {
+ initPerPage: getUserTablePreference(
+ "ResourceOverviewEmailDomainsTable",
+ PreferenceKey.PerPage,
+ 10
+ )
+ });
+
+ const handlePerPageChange = (newPerPage: number) => {
+ setPerPage(newPerPage);
+ setUserTablePreference("ResourceOverviewEmailDomainsTable", PreferenceKey.PerPage, newPerPage);
+ };
+
+ const { data, isPending } = useAdminGetEmailDomains({
+ limit,
+ offset,
+ searchTerm: debouncedSearchTerm
+ });
+
+ const { emailDomains, totalCount = 0 } = data ?? {};
+ const isEmpty = !isPending && !totalCount;
+
+ useResetPageHelper({ totalCount, offset, setPage });
+
+ const { mutateAsync: deleteEmailDomain } = useAdminDeleteEmailDomain();
+
+ const handleDelete = async () => {
+ const { emailDomainId } = popUp?.deleteEmailDomain?.data as { emailDomainId: string };
+ await deleteEmailDomain(emailDomainId);
+ createNotification({ text: "Email domain deleted", type: "success" });
+ handlePopUpClose("deleteEmailDomain");
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <div className="mb-4 flex items-center justify-between">
+ <div>
+ <p className="text-xl font-medium text-mineshaft-100">Email Domains</p>
+ <p className="text-sm text-bunker-300">
+ Manage verified email domains across your instance.
+ </p>
+ </div>
+ <Button
+ colorSchema="secondary"
+ onClick={() => handlePopUpOpen("addEmailDomain")}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ >
+ Add Domain
+ </Button>
+ </div>
+ <Input
+ value={searchFilter}
+ onChange={(e) => setSearchFilter(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search by domain or organization name..."
+ className="flex-1"
+ />
+ <div className="mt-4">
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-1/3">Domain</Th>
+ <Th className="w-1/3">Organization</Th>
+ <Th className="w-1/6">Status</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isPending && <TableSkeleton columns={4} innerKey="email-domains" />}
+ {!isPending &&
+ emailDomains?.map((ed) => (
+ <Tr key={ed.id} className="w-full">
+ <Td className="max-w-0">
+ <p className="truncate">{ed.domain}</p>
+ </Td>
+ <Td className="max-w-0">
+ <p className="truncate">{ed.orgName ?? ed.orgId}</p>
+ </Td>
+ <Td>
+ <Badge variant={ed.status === "verified" ? "success" : "warning"}>
+ {ed.status}
+ </Badge>
+ </Td>
+ <Td>
+ <div className="flex justify-end">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ ariaLabel="Options"
+ colorSchema="secondary"
+ className="w-6"
+ variant="plain"
+ >
+ <FontAwesomeIcon icon={faEllipsisV} />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent sideOffset={2} align="end">
+ <DropdownMenuItem
+ icon={<FontAwesomeIcon icon={faTrash} />}
+ onClick={() =>
+ handlePopUpOpen("deleteEmailDomain", {
+ emailDomainId: ed.id,
+ domain: ed.domain
+ })
+ }
+ >
+ Delete Domain
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </Td>
+ </Tr>
+ ))}
+ </TBody>
+ </Table>
+ {!isPending && isEmpty && <EmptyState title="No email domains found" icon={faGlobe} />}
+ </TableContainer>
+ {!isPending && totalCount > 0 && (
+ <Pagination
+ count={totalCount}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={handlePerPageChange}
+ />
+ )}
+ </div>
+ <DeleteActionModal
+ isOpen={popUp.deleteEmailDomain.isOpen}
+ deleteKey="delete"
+ title={`Are you sure you want to delete domain ${
+ (popUp?.deleteEmailDomain?.data as { domain: string })?.domain || ""
+ }?`}
+ onChange={(isOpen) => handlePopUpToggle("deleteEmailDomain", isOpen)}
+ onDeleteApproved={handleDelete}
+ />
+ <AddEmailDomainModal
+ isOpen={popUp.addEmailDomain.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("addEmailDomain", isOpen)}
+ />
+ </div>
+ );
+};
diff --git a/frontend/src/pages/admin/ResourceOverviewPage/components/index.ts b/frontend/src/pages/admin/ResourceOverviewPage/components/index.ts
index ce70dee053..badc3ca411 100644
--- a/frontend/src/pages/admin/ResourceOverviewPage/components/index.ts
+++ b/frontend/src/pages/admin/ResourceOverviewPage/components/index.ts
@@ -1,3 +1,4 @@
+export * from "./EmailDomainsTable";
export * from "./MachineIdentitiesTable";
export * from "./OrganizationsTable";
export * from "./UserIdentitiesTable";
diff --git a/frontend/src/pages/auth/LoginLdapPage/LoginLDAPPage.tsx b/frontend/src/pages/auth/LoginLdapPage/LoginLDAPPage.tsx
index 15ad41c2ec..46920d9943 100644
--- a/frontend/src/pages/auth/LoginLdapPage/LoginLDAPPage.tsx
+++ b/frontend/src/pages/auth/LoginLdapPage/LoginLDAPPage.tsx
@@ -28,6 +28,7 @@ export const LoginLdapPage = () => {
const queryParams = new URLSearchParams(window.location.search);
const passedOrgSlug = queryParams.get("organizationSlug");
const passedUsername = queryParams.get("username");
+ const callbackPort = queryParams.get("callback_port");
const lastLoginSlug =
lastLogin?.method === LoginMethod.LDAP && lastLogin.orgSlug ? lastLogin.orgSlug : "";
@@ -44,7 +45,8 @@ export const LoginLdapPage = () => {
const { nextUrl } = await loginLDAPRedirect({
organizationSlug,
username,
- password
+ password,
+ callbackPort: callbackPort ? Number(callbackPort) : undefined
});
if (!nextUrl) {
diff --git a/frontend/src/pages/auth/LoginPage/components/InitialStep/InitialStep.tsx b/frontend/src/pages/auth/LoginPage/components/InitialStep/InitialStep.tsx
index 3d7c77ef6e..ea96c8b9b9 100644
--- a/frontend/src/pages/auth/LoginPage/components/InitialStep/InitialStep.tsx
+++ b/frontend/src/pages/auth/LoginPage/components/InitialStep/InitialStep.tsx
@@ -368,7 +368,14 @@ export const InitialStep = ({ setSection, isAdmin }: Props) => {
{shouldDisplayLoginMethod(LoginMethod.LDAP) && (
<OrgLoginButton
label="Continue with LDAP"
- onClick={() => navigate({ to: "/login/ldap" })}
+ onClick={() =>
+ navigate({
+ to: "/login/ldap",
+ search: {
+ callback_port: callbackPort
+ }
+ })
+ }
className="mt-2"
showLastUsed={isLastUsedMethod(LoginMethod.LDAP)}
/>
diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
index e010668ee7..1b5108bcde 100644
--- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
@@ -90,7 +90,7 @@ export const SelectOrgPage = () => {
);
const [selectedRootOrg, setSelectedRootOrg] = useState<TOrgWithSubOrgs | null>(null);
const [searchTerm, setSearchTerm] = useState("");
- const mfaSuccessCallback = useRef<() => void>(() => {});
+ const mfaOrgInfo = useRef<{ rootOrg: TOrgWithSubOrgs; subOrgId?: string } | null>(null);
const handleLogout = useCallback(async () => {
try {
@@ -133,114 +133,112 @@ export const SelectOrgPage = () => {
}, [selectedRootOrg, searchTerm]);
// For sub-orgs, inherit the root org's SSO settings but override the ID
- const handleSelectOrganization = useCallback(
- async (org: TOrgWithSubOrgs, subOrgId?: string) => {
- const targetOrgId = subOrgId || org.id;
- const canBypassOrgAuth = org.bypassOrgAuthEnabled && isBreakglassRoute;
+ const handleSelectOrganization = async (org: TOrgWithSubOrgs, subOrgId?: string) => {
+ const targetOrgId = subOrgId || org.id;
+ const canBypassOrgAuth = org.bypassOrgAuthEnabled && isBreakglassRoute;
+
+ if (isBreakglassRoute && !org.bypassOrgAuthEnabled) {
+ createNotification({
+ text: "This organization does not have bypass org auth enabled",
+ type: "error"
+ });
+ return;
+ }
+
+ if ((org.authEnforced || org.googleSsoAuthEnforced) && !canBypassOrgAuth) {
+ const authToken = jwtDecode(getAuthToken()) as { authMethod: AuthMethod };
+
+ let ssoRequired = false;
+ let ssoType = "";
+
+ if (org.googleSsoAuthEnforced && authToken.authMethod !== AuthMethod.GOOGLE) {
+ ssoRequired = true;
+ ssoType = "Google SSO";
+ } else if (
+ org.orgAuthMethod === AuthMethod.OIDC &&
+ authToken.authMethod !== AuthMethod.OIDC
+ ) {
+ ssoRequired = true;
+ ssoType = "OIDC SSO";
+ } else if (
+ org.orgAuthMethod === AuthMethod.SAML &&
+ !SAML_AUTH_METHODS.includes(authToken.authMethod as (typeof SAML_AUTH_METHODS)[number])
+ ) {
+ ssoRequired = true;
+ ssoType = "SAML SSO";
+ }
- if (isBreakglassRoute && !org.bypassOrgAuthEnabled) {
+ if (ssoRequired) {
createNotification({
- text: "This organization does not have bypass org auth enabled",
+ text: `This organization requires ${ssoType}. Please log out and re-login via your identity provider.`,
type: "error"
});
return;
}
+ }
- if ((org.authEnforced || org.googleSsoAuthEnforced) && !canBypassOrgAuth) {
- const authToken = jwtDecode(getAuthToken()) as { authMethod: AuthMethod };
-
- let ssoRequired = false;
- let ssoType = "";
-
- if (org.googleSsoAuthEnforced && authToken.authMethod !== AuthMethod.GOOGLE) {
- ssoRequired = true;
- ssoType = "Google SSO";
- } else if (
- org.orgAuthMethod === AuthMethod.OIDC &&
- authToken.authMethod !== AuthMethod.OIDC
- ) {
- ssoRequired = true;
- ssoType = "OIDC SSO";
- } else if (
- org.orgAuthMethod === AuthMethod.SAML &&
- !SAML_AUTH_METHODS.includes(authToken.authMethod as (typeof SAML_AUTH_METHODS)[number])
- ) {
- ssoRequired = true;
- ssoType = "SAML SSO";
- }
-
- if (ssoRequired) {
- createNotification({
- text: `This organization requires ${ssoType}. Please log out and re-login via your identity provider.`,
- type: "error"
- });
- return;
- }
- }
+ let token;
+ let isMfaEnabled;
+ let mfaMethod;
- let token;
- let isMfaEnabled;
- let mfaMethod;
+ try {
+ const result = await selectOrg.mutateAsync({
+ organizationId: targetOrgId,
+ userAgent: callbackPort ? UserAgentType.CLI : undefined
+ });
+ token = result.token;
+ isMfaEnabled = result.isMfaEnabled;
+ mfaMethod = result.mfaMethod;
+ } catch (error: any) {
+ const message = error?.response?.data?.message || "Failed to select organization.";
+ createNotification({ text: message, type: "error" });
+ return;
+ }
- try {
- const result = await selectOrg.mutateAsync({
- organizationId: targetOrgId,
- userAgent: callbackPort ? UserAgentType.CLI : undefined
- });
- token = result.token;
- isMfaEnabled = result.isMfaEnabled;
- mfaMethod = result.mfaMethod;
- } catch (error: any) {
- const message = error?.response?.data?.message || "Failed to select organization.";
- createNotification({ text: message, type: "error" });
- return;
+ await router.invalidate();
+
+ if (isMfaEnabled) {
+ SecurityClient.setMfaToken(token);
+ if (mfaMethod) {
+ setRequiredMfaMethod(mfaMethod);
}
+ toggleShowMfa.on();
+ mfaOrgInfo.current = { rootOrg: org, subOrgId };
+ return;
+ }
- await router.invalidate();
+ if (callbackPort) {
+ let error: string | null = null;
- if (isMfaEnabled) {
- SecurityClient.setMfaToken(token);
- if (mfaMethod) {
- setRequiredMfaMethod(mfaMethod);
- }
- toggleShowMfa.on();
- mfaSuccessCallback.current = () => handleSelectOrganization(org, subOrgId);
+ console.log(user);
+ if (!user?.email) error = "User email not found";
+ if (!token) error = "No token found";
+
+ if (error) {
+ createNotification({ text: error, type: "error" });
return;
}
- if (callbackPort) {
- let error: string | null = null;
-
- if (!user?.email) error = "User email not found";
- if (!token) error = "No token found";
-
- if (error) {
- createNotification({ text: error, type: "error" });
- return;
- }
-
- const payload = {
- JTWToken: token,
- email: user?.email,
- privateKey: ""
- };
-
- sessionStorage.setItem(
- SessionStorageKeys.CLI_TERMINAL_TOKEN,
- JSON.stringify({
- expiry: formatISO(addSeconds(new Date(), 30)),
- data: window.btoa(JSON.stringify(payload)),
- callbackPort
- })
- );
- navigate({ to: "/cli-redirect" });
- } else {
- setAuthToken(token);
- navigateUserToOrg({ navigate, organizationId: targetOrgId });
- }
- },
- [selectOrg, callbackPort, isBreakglassRoute, user, router, toggleShowMfa, navigate]
- );
+ const payload = {
+ JTWToken: token,
+ email: user?.email,
+ privateKey: ""
+ };
+
+ sessionStorage.setItem(
+ SessionStorageKeys.CLI_TERMINAL_TOKEN,
+ JSON.stringify({
+ expiry: formatISO(addSeconds(new Date(), 30)),
+ data: window.btoa(JSON.stringify(payload)),
+ callbackPort
+ })
+ );
+ navigate({ to: "/cli-redirect" });
+ } else {
+ setAuthToken(token);
+ navigateUserToOrg({ navigate, organizationId: targetOrgId });
+ }
+ };
// MFA pending from IdP redirect
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -251,7 +249,7 @@ export const SelectOrgPage = () => {
sessionStorage.removeItem(SessionStorageKeys.MFA_TEMP_TOKEN);
SecurityClient.setMfaToken(storedMfaToken);
toggleShowMfa.on();
- mfaSuccessCallback.current = () => handleSelectOrganization(defaultOrg);
+ mfaOrgInfo.current = { rootOrg: defaultOrg };
}
}, [mfaMethodFromSearch, orgs?.length, orgId]);
@@ -386,7 +384,11 @@ export const SelectOrgPage = () => {
{shouldShowMfa ? (
<Mfa
email={user.email as string}
- successCallback={mfaSuccessCallback.current}
+ successCallback={() => {
+ if (mfaOrgInfo.current) {
+ handleSelectOrganization(mfaOrgInfo.current.rootOrg, mfaOrgInfo.current.subOrgId);
+ }
+ }}
method={requiredMfaMethod as MfaMethod}
/>
) : (
diff --git a/frontend/src/pages/auth/SignUpInvitePage/route.tsx b/frontend/src/pages/auth/SignUpInvitePage/route.tsx
index 4b33de781f..b93305532a 100644
--- a/frontend/src/pages/auth/SignUpInvitePage/route.tsx
+++ b/frontend/src/pages/auth/SignUpInvitePage/route.tsx
@@ -2,6 +2,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
import { zodValidator } from "@tanstack/zod-adapter";
import { z } from "zod";
+import { createNotification } from "@app/components/notifications";
import SecurityClient from "@app/components/utilities/SecurityClient";
import { authKeys, fetchAuthToken, verifySignupInvite } from "@app/hooks/api/auth/queries";
import { setAuthToken } from "@app/hooks/api/reactQuery";
@@ -40,6 +41,13 @@ export const Route = createFileRoute("/_restrict-login-signup/signupinvite")({
organizationId
});
+ if (!result.token) {
+ createNotification({
+ text: "Invitation accepted. Please login into your account",
+ type: "success"
+ });
+ }
+
if (authData) {
// Logged-in user — invitation accepted, go to the org
throw redirect({
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 5969aed349..6492babc7a 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgEmailDomainsSection/OrgEmailDomainsSection.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgEmailDomainsSection/OrgEmailDomainsSection.tsx
@@ -37,7 +37,7 @@ export const OrgEmailDomainsSection = () => {
/>
</div>
<p className="mt-1 mb-2 text-gray-400">
- Verify ownership of your email domains to use with SSO and identity providers. For mo
+ Verify ownership of your email domains to use with SSO and identity providers.
</p>
</div>
{hasEmailDomainVerification && (
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgSsoTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgSsoTab.tsx
index 76ab52ab12..05a5aa84ff 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgSsoTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/OrgSsoTab.tsx
@@ -1,7 +1,7 @@
import { twMerge } from "tailwind-merge";
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
-import { Button, ContentLoader, EmptyState } from "@app/components/v2";
+import { Alert, AlertDescription, Button, ContentLoader, EmptyState } from "@app/components/v2";
import {
OrgPermissionSsoActions,
OrgPermissionSubjects,
@@ -11,7 +11,12 @@ import {
} from "@app/context";
import { withPermission } from "@app/hoc";
import { usePopUp } from "@app/hooks";
-import { useGetLDAPConfig, useGetOIDCConfig, useGetSSOConfig } from "@app/hooks/api";
+import {
+ useGetEmailDomains,
+ useGetLDAPConfig,
+ useGetOIDCConfig,
+ useGetSSOConfig
+} from "@app/hooks/api";
import { LoginMethod } from "@app/hooks/api/admin/types";
import { LDAPModal } from "./LDAPModal";
@@ -38,6 +43,10 @@ export const OrgSsoTab = withPermission(
const { subscription } = useSubscription();
+ const { data: emailDomains, isPending } = useGetEmailDomains(
+ subscription?.emailDomainVerification ? currentOrg?.id : ""
+ );
+
const { data: oidcConfig, isPending: isLoadingOidcConfig } = useGetOIDCConfig(
currentOrg?.id ?? ""
);
@@ -79,6 +88,13 @@ export const OrgSsoTab = withPermission(
Connect your identity provider to simplify user management with options like SAML,
OIDC, and LDAP.
</p>
+ {subscription?.emailDomainVerification && !isPending && !emailDomains?.length && (
+ <Alert hideTitle iconClassName="text-yellow-500" variant="warning">
+ <AlertDescription>
+ Email domain verification is required to use an identity provider.
+ </AlertDescription>
+ </Alert>
+ )}
</div>
{shouldDisplaySection(LoginMethod.SAML) && (
<div
@@ -198,6 +214,13 @@ export const OrgSsoTab = withPermission(
createIdentityProviderView
) : (
<div className="mb-4 space-y-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
+ {subscription?.emailDomainVerification && !isPending && !emailDomains?.length && (
+ <Alert hideTitle iconClassName="text-yellow-500" variant="warning">
+ <AlertDescription>
+ Email domain verification is required to use an identity provider.
+ </AlertDescription>
+ </Alert>
+ )}
<div>
{isSamlConfigured && shouldDisplaySection(LoginMethod.SAML) && <OrgSSOSection />}
{isOidcConfigured && shouldDisplaySection(LoginMethod.OIDC) && <OrgOIDCSection />}