Skip to content

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

doc: added doc and corrected some more behavoir

=b2f3c824d1af
diff --git a/backend/e2e-test/routes/v3/auth-email-signup.spec.ts b/backend/e2e-test/routes/v3/auth-email-signup.spec.ts
index 50a746adfa..c95ef57660 100644
--- a/backend/e2e-test/routes/v3/auth-email-signup.spec.ts
+++ b/backend/e2e-test/routes/v3/auth-email-signup.spec.ts
@@ -101,7 +101,7 @@ describe("Auth Email Signup V3", () => {
// Step 3: Complete account
const res = await testServer.inject({
method: "POST",
- url: "/api/v3/signup/complete-account/signup",
+ url: "/api/v3/signup/complete-account",
headers: {
authorization: `Bearer ${signupToken}`
},
@@ -125,7 +125,7 @@ describe("Auth Email Signup V3", () => {
test("Complete account without signup token fails", async () => {
const res = await testServer.inject({
method: "POST",
- url: "/api/v3/signup/complete-account/signup",
+ url: "/api/v3/signup/complete-account",
body: {
type: "email",
diff --git a/backend/e2e-test/routes/v3/auth-signup-sso.spec.ts b/backend/e2e-test/routes/v3/auth-signup-sso.spec.ts
index e26f303213..8b9635d3da 100644
--- a/backend/e2e-test/routes/v3/auth-signup-sso.spec.ts
+++ b/backend/e2e-test/routes/v3/auth-signup-sso.spec.ts
@@ -110,7 +110,7 @@ describe("Auth SSO Signup V3", () => {
// Complete account with alias type
const res = await testServer.inject({
method: "POST",
- url: "/api/v3/signup/complete-account/signup",
+ url: "/api/v3/signup/complete-account",
headers: {
authorization: `Bearer ${result.signupToken}`
},
@@ -150,7 +150,7 @@ describe("Auth SSO Signup V3", () => {
const res = await testServer.inject({
method: "POST",
- url: "/api/v3/signup/complete-account/signup",
+ url: "/api/v3/signup/complete-account",
headers: {
authorization: `Bearer ${result.signupToken}`
},
diff --git a/backend/src/server/routes/v1/sso-router.ts b/backend/src/server/routes/v1/sso-router.ts
index d66f782efc..d5e7259e13 100644
--- a/backend/src/server/routes/v1/sso-router.ts
+++ b/backend/src/server/routes/v1/sso-router.ts
@@ -145,7 +145,7 @@ export const registerOauthMiddlewares = (server: FastifyZodProvider) => {
// eslint-disable-next-line
async (req: any, accessToken: string, _refreshToken: string, _profile: any, done: Function) => {
const ghEmails = await fetchGithubEmails(accessToken);
- const { email } = ghEmails.filter((gitHubEmail) => gitHubEmail.primary)[0];
+ const { email } = ghEmails.filter((gitHubEmail) => gitHubEmail.primary && gitHubEmail.verified)[0];
if (!email) throw new Error("No primary email found");
diff --git a/backend/src/server/routes/v3/signup-router.ts b/backend/src/server/routes/v3/signup-router.ts
index 1e84fe0173..a359bb4dbd 100644
--- a/backend/src/server/routes/v3/signup-router.ts
+++ b/backend/src/server/routes/v3/signup-router.ts
@@ -90,7 +90,7 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
});
server.route({
- url: "/complete-account/signup",
+ url: "/complete-account",
method: "POST",
config: {
rateLimit: authRateLimit
@@ -109,8 +109,7 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
}),
z.object({
type: z.literal(CompleteAccountType.Alias),
- code: z.string().trim(),
- organizationName: GenericResourceNameSchema.optional()
+ code: z.string().trim()
})
]),
response: {
diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts
index 1ea885b114..45157af384 100644
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@ -321,8 +321,7 @@ export const authLoginServiceFactory = ({
}: TProcessProviderCallbackDTO) => {
const appCfg = getConfig();
- // Step 1: If user is not fully set up or alias needs verification, issue a signup token
- if (!user.isAccepted || !isAliasVerified) {
+ if (!user.isAccepted || isEmailVerified || !isAliasVerified) {
const signupToken = crypto.jwt().sign(
{
authTokenType: AuthTokenType.SIGNUP_TOKEN,
@@ -344,37 +343,14 @@ export const authLoginServiceFactory = ({
return { result: ProviderAuthResult.SIGNUP_REQUIRED, signupToken, callbackPort } as const;
}
- // Step 2: For org-scoped IdP flows with MFA, issue tokens without org scope
- // so the user gets a session (for TOTP setup) but must go through selectOrganization
- // which handles MFA before granting org access.
- if (organizationId) {
- const org = await orgDAL.findById(organizationId);
- if (org) {
- const { isMfaRequired } = getRequiredMfaMethod(org, user);
-
- if (isMfaRequired) {
- const tokens = await generateUserTokens({
- userId: user.id,
- ip,
- userAgent,
- authMethod
- });
-
- return { result: ProviderAuthResult.SESSION, tokens, callbackPort } as const;
- }
- }
- }
-
- // Step 3: No MFA — issue org-scoped session tokens
+ // let them select the org and do the mfa
const tokens = await generateUserTokens({
userId: user.id,
ip,
userAgent,
- authMethod,
- organizationId
+ authMethod
});
- // Step 4: Promote any Invited memberships to Accepted now that the user has authenticated
if (organizationId) {
await membershipUserDAL.update(
{
diff --git a/backend/src/services/auth/auth-signup-service.ts b/backend/src/services/auth/auth-signup-service.ts
index 8cf3b92250..2c20d8fe96 100644
--- a/backend/src/services/auth/auth-signup-service.ts
+++ b/backend/src/services/auth/auth-signup-service.ts
@@ -1,7 +1,7 @@
import { AccessScope, OrgMembershipStatus } from "@app/db/schemas";
import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto/cryptography";
-import { BadRequestError, ForbiddenRequestError, UnauthorizedError } from "@app/lib/errors";
+import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
import { isDisposableEmail, validateEmail } from "@app/lib/validator";
import { TAuthTokenServiceFactory } from "../auth-token/auth-token-service";
@@ -9,7 +9,6 @@ import { TokenType } from "../auth-token/auth-token-types";
import { TOrgDALFactory } from "../org/org-dal";
import { TOrgServiceFactory } from "../org/org-service";
import { SmtpTemplates, TSmtpService } from "../smtp/smtp-service";
-import { getServerCfg } from "../super-admin/super-admin-service";
import { TUserDALFactory } from "../user/user-dal";
import { TUserAliasDALFactory } from "../user-alias/user-alias-dal";
import { TAuthDALFactory } from "./auth-dal";
@@ -164,13 +163,10 @@ export const authSignupServiceFactory = ({
// checking rejection conditions, so the response time is constant regardless of
// whether the request is valid. This prevents timing-based user/alias enumeration.
let authMethod: AuthMethod;
-
+ let organizationId: string | undefined;
if (dto.type === CompleteAccountType.Email) {
- const sanitizedEmail = dto.email.trim().toLowerCase();
- const userByEmail = await userDAL.findOne({ username: sanitizedEmail });
-
// Determine rejection before hashing, but don't throw yet
- const shouldReject = !user || user.isAccepted || !userByEmail || userByEmail.id !== user?.id;
+ const shouldReject = !user || user.isAccepted;
// Always hash the password so bcrypt cost is incurred regardless of validity
const hashedPassword = await crypto.hashing().createHash(dto.password, appCfg.SALT_ROUNDS);
@@ -185,6 +181,29 @@ export const authSignupServiceFactory = ({
{ firstName: dto.firstName, lastName: dto.lastName, isAccepted: true, hashedPassword },
tx
);
+
+ // Step 4: Check org membership — create org if self-signup with no existing membership
+ const existingMemberships = await orgDAL.findMembership(
+ {
+ actorUserId: user.id,
+ scope: AccessScope.Organization
+ },
+ { tx }
+ );
+ const isInvitedUser = existingMemberships.length > 0;
+ if (!isInvitedUser && dto.organizationName) {
+ const org = await orgService.createOrganization(
+ {
+ userId: user.id,
+ userEmail: user.email ?? user.username,
+ orgName: dto.organizationName
+ },
+ tx
+ );
+
+ organizationId = org.id;
+ }
+
return { ...us, hashedPassword: null };
});
user = updatedUser;
@@ -250,31 +269,6 @@ export const authSignupServiceFactory = ({
authMethod = decodedToken.authMethod;
}
- // Step 4: Check org membership — create org if self-signup with no existing membership
- const existingMemberships = await orgDAL.findMembership({
- actorUserId: user.id,
- scope: AccessScope.Organization
- });
- const isInvitedUser = existingMemberships.length > 0;
-
- let { organizationId } = decodedToken;
- if (!isInvitedUser) {
- const serverCfg = await getServerCfg();
- if (!serverCfg.allowSignUp) {
- throw new ForbiddenRequestError({ message: "Signups are disabled" });
- }
-
- if (dto.organizationName) {
- const org = await orgService.createOrganization({
- userId: user.id,
- userEmail: user.email ?? user.username,
- orgName: dto.organizationName
- });
-
- organizationId = org.id;
- }
- }
-
// Step 5: Issue session tokens
const tokens = await loginService.generateUserTokens({
userId: user.id,
@@ -286,7 +280,6 @@ export const authSignupServiceFactory = ({
return {
user,
- isInvitedUser,
accessToken: tokens.access,
refreshToken: tokens.refresh,
authMethod
diff --git a/backend/src/services/auth/auth-signup-type.ts b/backend/src/services/auth/auth-signup-type.ts
index 058529a8f0..b8e6f15154 100644
--- a/backend/src/services/auth/auth-signup-type.ts
+++ b/backend/src/services/auth/auth-signup-type.ts
@@ -7,7 +7,6 @@ type TCompleteAccountBase = {
ip: string;
userAgent: string;
authorization: string;
- organizationName?: string;
};
type TCompleteAccountEmail = TCompleteAccountBase & {
@@ -17,6 +16,7 @@ type TCompleteAccountEmail = TCompleteAccountBase & {
firstName: string;
lastName?: string;
attributionSource?: string;
+ organizationName?: string;
};
type TCompleteAccountAlias = TCompleteAccountBase & {
diff --git a/backend/src/services/membership-user/membership-user-service.ts b/backend/src/services/membership-user/membership-user-service.ts
index bac3bea535..0870626a83 100644
--- a/backend/src/services/membership-user/membership-user-service.ts
+++ b/backend/src/services/membership-user/membership-user-service.ts
@@ -110,9 +110,9 @@ export const membershipUserServiceFactory = ({
const invalidEmails = newUserEmails.filter((el) => {
try {
validateEmail(el);
- return true;
- } catch {
return false;
+ } catch (err) {
+ return true;
}
});
if (invalidEmails.length > 0) {
diff --git a/backend/src/services/org/org-dal.ts b/backend/src/services/org/org-dal.ts
index 572beea206..8422fd46f1 100644
--- a/backend/src/services/org/org-dal.ts
+++ b/backend/src/services/org/org-dal.ts
@@ -245,74 +245,54 @@ export const orgDALFactory = (db: TDbClient) => {
try {
const conn = db.replicaNode();
- // Group IDs the user belongs to
+ // Query 1: Get root orgs the user has direct membership in (full org info)
+ const rootOrgs = (await conn(TableName.Organization)
+ .join(TableName.Membership, (qb) => {
+ void qb
+ .on(`${TableName.Membership}.scopeOrgId`, "=", db.ref("id").withSchema(TableName.Organization))
+ .andOn(`${TableName.Membership}.scope`, db.raw("?", [AccessScope.Organization]))
+ .andOn(`${TableName.Membership}.actorUserId`, db.raw("?", [dto.actorId]));
+ })
+ .whereNull(`${TableName.Organization}.rootOrgId`)
+ .select(
+ selectAllTableCols(TableName.Organization),
+ db.ref("createdAt").withSchema(TableName.Membership).as("userJoinedAt")
+ )) as (TOrganizations & { userJoinedAt: Date | null })[];
+
+ if (rootOrgs.length === 0) return [];
+
+ const rootOrgIds = rootOrgs.map((o) => o.id);
+
+ // Query 2: Get sub-orgs under those root orgs that the user can access (direct or via group)
const userGroupIdsSubquery = conn(TableName.Groups)
.join(TableName.UserGroupMembership, `${TableName.UserGroupMembership}.groupId`, `${TableName.Groups}.id`)
.where(`${TableName.UserGroupMembership}.userId`, dto.actorId)
.select(db.ref("id").withSchema(TableName.Groups));
- // Single query for both root orgs and sub-orgs: rootOrgId IS NULL → root, else → sub-org.
- // inner join on access_m filters to orgs the user can access (direct or via group),
- // left join on direct_m / UserGroupMembership resolves userJoinedAt for both cases.
- const allOrgs = (await conn(TableName.Organization)
- .join(`${TableName.Membership} as access_m`, (qb) => {
- void qb
- .on(`access_m.scopeOrgId`, "=", db.ref("id").withSchema(TableName.Organization))
- .andOn(`access_m.scope`, db.raw("?", [AccessScope.Organization]));
- })
- .where((qb) => {
- void qb.where(`access_m.actorUserId`, dto.actorId).orWhereIn(`access_m.actorGroupId`, userGroupIdsSubquery);
- })
- .leftJoin(`${TableName.Membership} as direct_m`, (qb) => {
+ const subOrgs = (await conn(TableName.Organization)
+ .join(TableName.Membership, (qb) => {
void qb
- .on(`direct_m.scopeOrgId`, "=", db.ref("id").withSchema(TableName.Organization))
- .andOn(`direct_m.scope`, db.raw("?", [AccessScope.Organization]))
- .andOn(`direct_m.actorUserId`, db.raw("?", [dto.actorId]));
+ .on(`${TableName.Membership}.scopeOrgId`, "=", db.ref("id").withSchema(TableName.Organization))
+ .andOn(`${TableName.Membership}.scope`, db.raw("?", [AccessScope.Organization]));
})
- .leftJoin(TableName.UserGroupMembership, (qb) => {
+ .whereIn(`${TableName.Organization}.rootOrgId`, rootOrgIds)
+ .andWhere((qb) => {
void qb
- .on(`${TableName.UserGroupMembership}.groupId`, "=", db.raw(`"access_m"."actorGroupId"`))
- .andOn(`${TableName.UserGroupMembership}.userId`, db.raw("?", [dto.actorId]));
+ .where(`${TableName.Membership}.actorUserId`, dto.actorId)
+ .orWhereIn(`${TableName.Membership}.actorGroupId`, userGroupIdsSubquery);
})
- .groupBy(
- db.ref("id").withSchema(TableName.Organization),
- db.ref("name").withSchema(TableName.Organization),
- db.ref("slug").withSchema(TableName.Organization),
- db.ref("createdAt").withSchema(TableName.Organization),
- db.ref("rootOrgId").withSchema(TableName.Organization)
- )
.select(
db.ref("id").withSchema(TableName.Organization),
db.ref("name").withSchema(TableName.Organization),
db.ref("slug").withSchema(TableName.Organization),
- db.ref("createdAt").withSchema(TableName.Organization),
db.ref("rootOrgId").withSchema(TableName.Organization),
- db.raw(
- `COALESCE(MIN("direct_m"."createdAt"), MIN("${TableName.UserGroupMembership}"."createdAt")) as "userJoinedAt"`
- )
- )) as {
- id: string;
- name: string;
- slug: string;
- createdAt: Date;
- rootOrgId: string | null;
- userJoinedAt: Date | null;
- }[];
-
- const rootOrgs = allOrgs.filter((o) => !o.rootOrgId);
- const rootOrgIdSet = new Set(rootOrgs.map((o) => o.id));
-
- // Only include sub-orgs whose root org is itself accessible to this user
- const subOrgsByRootId = groupBy(
- allOrgs.filter((o) => o.rootOrgId && rootOrgIdSet.has(o.rootOrgId)),
- (s) => s.rootOrgId as string
- );
+ db.ref("createdAt").withSchema(TableName.Membership).as("userJoinedAt")
+ )) as { id: string; name: string; slug: string; rootOrgId: string; userJoinedAt: Date | null }[];
+
+ const subOrgsByRootId = groupBy(subOrgs, (s) => s.rootOrgId);
return rootOrgs.map((org) => ({
- id: org.id,
- name: org.name,
- slug: org.slug,
- createdAt: org.createdAt,
+ ...org,
userJoinedAt: org.userJoinedAt ?? null,
subOrganizations: (subOrgsByRootId[org.id] ?? []).map((s) => ({
id: s.id,
diff --git a/backend/src/services/org/org-schema.ts b/backend/src/services/org/org-schema.ts
index b42f822f07..2f81669baa 100644
--- a/backend/src/services/org/org-schema.ts
+++ b/backend/src/services/org/org-schema.ts
@@ -2,23 +2,6 @@ import { z } from "zod";
import { OrganizationsSchema } from "@app/db/schemas";
-/** Zod schema for API response: org with sub-orgs */
-export const OrgWithSubOrgsSchema = OrganizationsSchema.pick({
- id: true,
- name: true,
- slug: true,
- createdAt: true
-}).extend({
- userJoinedAt: z.date().optional().nullable(),
- subOrganizations: OrganizationsSchema.pick({
- id: true,
- name: true,
- slug: true
- })
- .extend({ userJoinedAt: z.date().optional().nullable() })
- .array()
-});
-
export const sanitizedOrganizationSchema = OrganizationsSchema.pick({
id: true,
name: true,
@@ -52,3 +35,15 @@ export const sanitizedOrganizationSchema = OrganizationsSchema.pick({
parentOrgId: true,
secretShareBrandConfig: true
});
+
+/** Zod schema for API response: root org (full info) with sub-orgs (basic info) */
+export const OrgWithSubOrgsSchema = sanitizedOrganizationSchema.extend({
+ userJoinedAt: z.date().optional().nullable(),
+ subOrganizations: OrganizationsSchema.pick({
+ id: true,
+ name: true,
+ slug: true
+ })
+ .extend({ userJoinedAt: z.date().optional().nullable() })
+ .array()
+});
diff --git a/docs/documentation/platform/email-domain.mdx b/docs/documentation/platform/email-domain.mdx
new file mode 100644
index 0000000000..3742ef1ae8
--- /dev/null
+++ b/docs/documentation/platform/email-domain.mdx
@@ -0,0 +1,180 @@
+---
+title: "Email Domain Verification"
+description: "Learn how to verify your organization's email domains for secure SSO and user provisioning."
+---
+
+<Info>
+ Email Domain Verification is a paid feature. If you're using Infisical Cloud,
+ then it is available under the **Pro Tier**. If you're self-hosting Infisical,
+ then you should contact [email protected] to purchase an enterprise license
+ to use it.
+</Info>
+
+## Overview
+
+Email Domain Verification allows organizations to prove ownership of their email domains (e.g., `company.com`) through DNS verification. Once verified, the domain is exclusively linked to your organization, enabling:
+
+- **Secure SSO login** — Users can log in via SAML, OIDC, or LDAP using just their work email. Infisical automatically routes them to the correct organization's identity provider.
+- **SCIM provisioning** — SCIM user provisioning requires a verified email domain to ensure only authorized organizations can manage users.
+- **Simplified login experience** — Users enter their work email to login in via SSO.
+
+## How It Works
+
+Email domain verification uses DNS TXT records to prove ownership. The flow is:
+
+1. **Add a domain** — Enter the domain you want to verify (e.g., `company.com`).
+2. **Get a verification code** — Infisical generates a unique verification code and DNS record name.
+3. **Add a DNS TXT record** — Add the verification record to your domain's DNS configuration.
+4. **Verify** — Infisical checks the DNS TXT record and marks the domain as verified.
+
+The verification code expires after **7 days**. You must complete verification within this window.
+
+### DNS Record Format
+
+| Field | Value |
+| ---------------- | --------------------------------------------------- |
+| **Record Type** | TXT |
+| **Record Name** | `_infisical-verification.yourdomain.com` |
+| **Record Value** | `infisical-domain-verification=<verification-code>` |
+
+<Note>
+ Some DNS providers automatically append your domain to the record name. In
+ that case, enter only `_infisical-verification` as the host/name.
+</Note>
+
+## Setting Up Email Domain Verification
+
+<Steps>
+ <Step title="Navigate to Email Domain Settings">
+ Go to **Organization Settings** → **Authentication** → scroll down to the **Email Domains** section.
+
+ {/* ![Email Domains Section](/images/platform/email-domain/email-domains-section.png) */}
+
+ </Step>
+
+ <Step title="Add an Email Domain">
+ Click **Add domain** and enter the domain you want to verify (e.g., `company.com`).
+
+ {/* ![Add Domain Modal](/images/platform/email-domain/add-domain-modal.png) */}
+
+ Click **Add Domain** to create the verification request.
+
+ </Step>
+
+ <Step title="Copy DNS Verification Details">
+ After adding the domain, click the **eye icon** (View details & Verify) on the pending domain row.
+
+ A modal will show you the DNS TXT record details:
+ - **Record Name** — The DNS hostname to add the TXT record to.
+ - **Record Value** — The verification string to use as the TXT record value.
+
+ Copy both values using the copy buttons.
+
+ {/* ![Verification Details Modal](/images/platform/email-domain/verification-modal.png) */}
+
+ </Step>
+
+ <Step title="Add the DNS TXT Record">
+ Go to your domain's DNS management panel (e.g., Cloudflare, Route 53, GoDaddy) and add a new TXT record with the copied values.
+
+ | Setting | Value |
+ |---------|-------|
+ | Type | TXT |
+ | Name/Host | `_infisical-verification` (or `_infisical-verification.yourdomain.com`) |
+ | Value/Content | `infisical-domain-verification=<your-code>` |
+ | TTL | Auto or 3600 |
+
+ <Note>
+ DNS changes can take up to **48 hours** to propagate, though most providers update within minutes.
+ </Note>
+
+ </Step>
+
+ <Step title="Verify the Domain">
+ Return to the Infisical Email Domains section and click **View details & Verify** on the pending domain.
+
+ Click the **Verify Domain** button. Infisical will perform a DNS TXT lookup to confirm the record exists and matches.
+
+ Once verified, the domain status changes to **Verified** and it's exclusively linked to your organization.
+
+ {/* ![Verified Domain](/images/platform/email-domain/verified-domain.png) */}
+
+ </Step>
+</Steps>
+
+## SSO Login with Email Domain
+
+Once your domain is verified, users can log in via SSO by entering their work email instead of an organization slug.
+
+<Steps>
+ <Step title="Go to the Login Page">
+ Navigate to the Infisical login page and select **SAML SSO** or **OIDC SSO**.
+ </Step>
+
+ <Step title="Enter Work Email">
+ Enter your full work email (e.g., `[email protected]`). Infisical extracts the domain and looks up the verified domain to find your organization's SSO configuration.
+
+ {/* ![SSO Email Login](/images/platform/email-domain/sso-email-login.png) */}
+
+ </Step>
+
+ <Step title="Authenticate via IdP">
+ You'll be redirected to your organization's identity provider (Okta, Azure AD, Google Workspace, etc.) to complete authentication.
+ </Step>
+</Steps>
+
+## Domain Hierarchy
+
+Email domains are verified at the exact domain level:
+
+- Verifying `company.com` covers only `[email protected]` — **not** `[email protected]`.
+- Each subdomain must be verified separately if you want SSO to work for subdomain email addresses.
+- You can verify both a parent domain and its subdomains independently.
+
+## Platform-Level Uniqueness
+
+Each domain can only be verified by **one organization** across the entire Infisical instance:
+
+- If Organization A verifies `company.com`, Organization B cannot verify or claim the same domain.
+- This prevents cross-organization user provisioning attacks where a malicious org could claim users by email domain.
+
+## SCIM Integration
+
+When [SCIM provisioning](/documentation/platform/scim/overview) is enabled, email domain verification is **required**:
+
+- SCIM `POST /Users` requests are validated against the organization's verified domains.
+- If the user's email domain is not verified by the SCIM token's organization, the request is rejected.
+- SCIM `PATCH` and `PUT` operations that change a user's email are blocked — email is treated as an immutable identifier.
+
+## FAQ
+
+<AccordionGroup>
+ <Accordion title="What happens if DNS verification fails?">
+ If the DNS TXT record is not found or doesn't match, verification will fail with an error message.
+ Common causes include DNS propagation delays (wait and retry), incorrect record name (some providers
+ auto-append the domain), or extra whitespace/quotes in the record value.
+ </Accordion>
+
+<Accordion title="Can I verify a domain that's already verified by another organization?">
+ No. Each domain is platform-unique. If another organization has already
+ verified a domain, you'll receive an error when trying to add it. Contact your
+ Infisical administrator to resolve domain ownership conflicts.
+</Accordion>
+
+<Accordion title="What happens if I delete a verified domain?">
+ Deleting a verified domain removes the domain claim from your organization.
+ SSO login via that domain will stop working, and SCIM provisioning for users
+ with that domain will be blocked. Another organization could then verify and
+ claim the domain.
+</Accordion>
+
+<Accordion title="Do I need to verify domains for email/password login?">
+ No. Email domain verification is required only for SSO (SAML, OIDC, LDAP) and
+ SCIM provisioning flows. Email/password login is not affected.
+</Accordion>
+
+<Accordion title="Does verifying a parent domain cover all subdomains?">
+ No. Each subdomain must be verified independently. Verifying `company.com`
+ does not automatically cover `app.company.com` or `dev.company.com`.
+</Accordion>
+</AccordionGroup>
diff --git a/docs/documentation/platform/ldap/overview.mdx b/docs/documentation/platform/ldap/overview.mdx
index c1a980b041..3083748bf5 100644
--- a/docs/documentation/platform/ldap/overview.mdx
+++ b/docs/documentation/platform/ldap/overview.mdx
@@ -4,6 +4,11 @@ sidebarTitle: "Overview"
description: "Learn how to authenticate into Infisical with LDAP."
---
+<Note>
+ LDAP authentication requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before users can log in via LDAP.
+</Note>
+
<Info>
LDAP is a paid feature.
diff --git a/docs/documentation/platform/scim/overview.mdx b/docs/documentation/platform/scim/overview.mdx
index 21f06cd8d8..70733ae4e4 100644
--- a/docs/documentation/platform/scim/overview.mdx
+++ b/docs/documentation/platform/scim/overview.mdx
@@ -3,6 +3,11 @@ title: "SCIM Overview"
description: "Learn how to provision users for Infisical via SCIM."
---
+<Note>
+ SCIM provisioning requires [Email Domain Verification](/documentation/platform/email-domain).
+ You must verify your organization's email domain before provisioning users via SCIM.
+</Note>
+
<Note>
SCIM provisioning can only be enabled when either SAML or OIDC is setup for
the organization.
diff --git a/docs/documentation/platform/sso/overview.mdx b/docs/documentation/platform/sso/overview.mdx
index 66243f7d80..aa91f056d2 100644
--- a/docs/documentation/platform/sso/overview.mdx
+++ b/docs/documentation/platform/sso/overview.mdx
@@ -4,6 +4,11 @@ sidebarTitle: "Overview"
description: "Learn how to log in to Infisical via SSO protocols."
---
+<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>
Infisical offers Google SSO and GitHub SSO for free across both Infisical
Cloud and Infisical Self-hosted. Infisical also offers SAML SSO authentication
diff --git a/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx b/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
index 1f0d79ef63..93554a034b 100644
--- a/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
+++ b/frontend/src/components/organization/CreateOrgModal/CreateOrgModal.tsx
@@ -5,7 +5,18 @@ import { useNavigate } from "@tanstack/react-router";
import z from "zod";
import { createNotification } from "@app/components/notifications";
-import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
+import {
+ Button,
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ FieldError,
+ FieldLabel,
+ UnstableInput
+} from "@app/components/v3";
import { useCreateOrg, useSelectOrganization } from "@app/hooks/api";
import { GenericResourceNameSchema } from "@app/lib/schemas";
@@ -43,13 +54,9 @@ export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) =>
const { mutateAsync: selectOrg } = useSelectOrganization();
const onFormSubmit = async ({ name }: FormData) => {
- const organization = await createOrg({
- name
- });
+ const organization = await createOrg({ name });
- await selectOrg({
- organizationId: organization.id
- });
+ await selectOrg({ organizationId: organization.id });
createNotification({
text: "Successfully created organization",
@@ -68,38 +75,51 @@ export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) =>
};
return (
- <Modal modal={false} isOpen={isOpen}>
- <ModalContent
- title="Create Organization"
- subTitle="Looks like you're not part of any organizations. Create one to start using Infisical"
- >
+ <Dialog
+ open={isOpen}
+ onOpenChange={(open) => {
+ if (!open) {
+ reset();
+ onClose();
+ }
+ }}
+ >
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>Create Organization</DialogTitle>
+ <DialogDescription>
+ Welcome! It looks like you haven&apos;t joined or created an organization yet. Create
+ one to get started.
+ </DialogDescription>
+ </DialogHeader>
<form onSubmit={handleSubmit(onFormSubmit)}>
<Controller
control={control}
defaultValue=""
name="name"
render={({ field, fieldState: { error } }) => (
- <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
- <Input {...field} placeholder="Acme Corp" />
- </FormControl>
+ <div className="mb-4">
+ <FieldLabel>Name</FieldLabel>
+ <UnstableInput {...field} placeholder="Acme Corp" className="h-10" />
+ {error && <FieldError>{error.message}</FieldError>}
+ </div>
)}
/>
- <div className="flex w-full gap-4">
+ <DialogFooter>
+ <Button type="button" variant="outline" onClick={onClose}>
+ Cancel
+ </Button>
<Button
- className=""
- size="sm"
type="submit"
- isLoading={isSubmitting}
+ variant="project"
+ isPending={isSubmitting}
isDisabled={isSubmitting}
>
Create
</Button>
- <Button className="" size="sm" variant="outline_bg" type="button" onClick={onClose}>
- Cancel
- </Button>
- </div>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
);
};
diff --git a/frontend/src/hooks/api/auth/queries.tsx b/frontend/src/hooks/api/auth/queries.tsx
index 5b4992776a..1f84b1d468 100644
--- a/frontend/src/hooks/api/auth/queries.tsx
+++ b/frontend/src/hooks/api/auth/queries.tsx
@@ -144,7 +144,7 @@ export const useOauthTokenExchange = () => {
};
export const completeAccountSignup = async (details: CompleteAccountSignupDTO) => {
- const { data } = await apiRequest.post("/api/v3/signup/complete-account/signup", details);
+ const { data } = await apiRequest.post("/api/v3/signup/complete-account", details);
return data;
};
diff --git a/frontend/src/hooks/api/auth/types.ts b/frontend/src/hooks/api/auth/types.ts
index cac703614c..1e0f8bc645 100644
--- a/frontend/src/hooks/api/auth/types.ts
+++ b/frontend/src/hooks/api/auth/types.ts
@@ -108,7 +108,6 @@ export type CompleteAccountSignupDTO =
| {
type: "alias";
code: string;
- organizationName?: string;
};
export type VerifySignupInviteDTO = {
diff --git a/frontend/src/hooks/api/organization/queries.tsx b/frontend/src/hooks/api/organization/queries.tsx
index 9d38c51da6..ce7ebea338 100644
--- a/frontend/src/hooks/api/organization/queries.tsx
+++ b/frontend/src/hooks/api/organization/queries.tsx
@@ -22,11 +22,7 @@ import {
UpdateOrgDTO
} from "./types";
-export type TOrgWithSubOrgs = {
- id: string;
- name: string;
- slug: string;
- createdAt: string;
+export type TOrgWithSubOrgs = Organization & {
userJoinedAt?: string | null;
subOrganizations: { id: string; name: string; slug: string; userJoinedAt?: string | null }[];
};
diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
index 5ac6a38c91..63aa8e8320 100644
--- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx
@@ -17,7 +17,6 @@ import { ROUTE_PATHS } from "@app/const/routes";
import { useToggle } from "@app/hooks";
import {
TOrgWithSubOrgs,
- useGetOrganizations,
useGetOrganizationsWithSubOrgs,
useGetUser,
useLogoutUser,
@@ -25,12 +24,10 @@ import {
} from "@app/hooks/api";
import { MfaMethod, UserAgentType } from "@app/hooks/api/auth/types";
import { getAuthToken, isLoggedIn, setAuthToken } from "@app/hooks/api/reactQuery";
-import { Organization } from "@app/hooks/api/types";
import { AuthMethod, SAML_AUTH_METHODS } from "@app/hooks/api/users/types";
import { navigateUserToOrg } from "../LoginPage/Login.utils";
-// Shared org row component to avoid repeating the same layout + userJoinedAt logic
const OrgRow = ({
name,
label,
@@ -84,8 +81,7 @@ export const SelectOrgPage = () => {
mfa_pending: mfaPending
} = search;
- const organizations = useGetOrganizations();
- const orgsWithSubOrgs = useGetOrganizationsWithSubOrgs();
+ const { data: orgs, isPending: orgsLoading } = useGetOrganizationsWithSubOrgs();
const selectOrg = useSelectOrganization();
const { data: user, isPending: userLoading } = useGetUser();
const logout = useLogoutUser();
@@ -96,31 +92,6 @@ export const SelectOrgPage = () => {
const [searchTerm, setSearchTerm] = useState("");
const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {});
- const defaultSelectedOrg = organizations.data?.find((org) => org.id === orgId);
-
- // Build a flat lookup map: orgId → { org (full Organization), rootOrg? (for sub-orgs) }
- const orgLookup = useMemo(() => {
- const map = new Map<string, { org: Organization; rootOrg?: Organization }>();
- if (!organizations.data || !orgsWithSubOrgs.data) return map;
-
- organizations.data.forEach((fullOrg) => {
- map.set(fullOrg.id, { org: fullOrg });
- });
-
- orgsWithSubOrgs.data.forEach((entry) => {
- const rootOrg = organizations.data.find((o) => o.id === entry.id);
- if (!rootOrg) return;
-
- entry.subOrganizations.forEach((sub) => {
- if (!map.has(sub.id)) {
- map.set(sub.id, { org: { ...rootOrg, id: sub.id }, rootOrg });
- }
- });
- });
-
- return map;
- }, [organizations.data, orgsWithSubOrgs.data]);
-
const handleLogout = useCallback(async () => {
try {
await logout.mutateAsync();
@@ -131,11 +102,11 @@ export const SelectOrgPage = () => {
}, [logout, navigate]);
const filteredOrgs = useMemo(() => {
- if (!orgsWithSubOrgs.data) return [];
- if (!searchTerm.trim()) return orgsWithSubOrgs.data;
+ if (!orgs) return [];
+ if (!searchTerm.trim()) return orgs;
const term = searchTerm.toLowerCase();
- return orgsWithSubOrgs.data
+ return orgs
.filter(
(org) =>
org.name.toLowerCase().includes(term) ||
@@ -147,12 +118,12 @@ export const SelectOrgPage = () => {
? org.subOrganizations
: org.subOrganizations.filter((sub) => sub.name.toLowerCase().includes(term))
}));
- }, [orgsWithSubOrgs.data, searchTerm]);
+ }, [orgs, searchTerm]);
const totalOrgCount = useMemo(() => {
- if (!orgsWithSubOrgs.data) return 0;
- return orgsWithSubOrgs.data.reduce((sum, org) => sum + 1 + org.subOrganizations.length, 0);
- }, [orgsWithSubOrgs.data]);
+ if (!orgs) return 0;
+ return orgs.reduce((sum, org) => sum + 1 + org.subOrganizations.length, 0);
+ }, [orgs]);
const filteredSubOrgs = useMemo(() => {
if (!selectedRootOrg) return [];
@@ -161,11 +132,13 @@ export const SelectOrgPage = () => {
return selectedRootOrg.subOrganizations.filter((sub) => sub.name.toLowerCase().includes(term));
}, [selectedRootOrg, searchTerm]);
+ // For sub-orgs, inherit the root org's SSO settings but override the ID
const handleSelectOrganization = useCallback(
- async (organization: Organization) => {
- const canBypassOrgAuth = organization.bypassOrgAuthEnabled && isBreakglassRoute;
+ async (org: TOrgWithSubOrgs, subOrgId?: string) => {
+ const targetOrgId = subOrgId || org.id;
+ const canBypassOrgAuth = org.bypassOrgAuthEnabled && isBreakglassRoute;
- if (isBreakglassRoute && !organization.bypassOrgAuthEnabled) {
+ if (isBreakglassRoute && !org.bypassOrgAuthEnabled) {
createNotification({
text: "This organization does not have bypass org auth enabled",
type: "error"
@@ -173,24 +146,23 @@ export const SelectOrgPage = () => {
return;
}
- // SSO enforcement: block and notify instead of logging out
- if ((organization.authEnforced || organization.googleSsoAuthEnforced) && !canBypassOrgAuth) {
+ if ((org.authEnforced || org.googleSsoAuthEnforced) && !canBypassOrgAuth) {
const authToken = jwtDecode(getAuthToken()) as { authMethod: AuthMethod };
let ssoRequired = false;
let ssoType = "";
- if (organization.googleSsoAuthEnforced && authToken.authMethod !== AuthMethod.GOOGLE) {
+ if (org.googleSsoAuthEnforced && authToken.authMethod !== AuthMethod.GOOGLE) {
ssoRequired = true;
ssoType = "Google SSO";
} else if (
- organization.orgAuthMethod === AuthMethod.OIDC &&
+ org.orgAuthMethod === AuthMethod.OIDC &&
authToken.authMethod !== AuthMethod.OIDC
) {
ssoRequired = true;
ssoType = "OIDC SSO";
} else if (
- organization.orgAuthMethod === AuthMethod.SAML &&
+ org.orgAuthMethod === AuthMethod.SAML &&
!SAML_AUTH_METHODS.includes(authToken.authMethod as (typeof SAML_AUTH_METHODS)[number])
) {
ssoRequired = true;
@@ -212,7 +184,7 @@ export const SelectOrgPage = () => {
try {
const result = await selectOrg.mutateAsync({
- organizationId: organization.id,
+ organizationId: targetOrgId,
userAgent: callbackPort ? UserAgentType.CLI : undefined
});
token = result.token;
@@ -232,7 +204,7 @@ export const SelectOrgPage = () => {
setRequiredMfaMethod(mfaMethod);
}
toggleShowMfa.on();
- setMfaSuccessCallback(() => () => handleSelectOrganization(organization));
+ setMfaSuccessCallback(() => () => handleSelectOrganization(org, subOrgId));
return;
}
@@ -266,61 +238,46 @@ export const SelectOrgPage = () => {
navigate({ to: "/cli-redirect" });
} else {
setAuthToken(token);
- navigateUserToOrg({ navigate, organizationId: organization.id });
+ navigateUserToOrg({ navigate, organizationId: targetOrgId });
}
},
[selectOrg, callbackPort, isBreakglassRoute, user, router, toggleShowMfa, navigate]
);
- const handleLoginById = useCallback(
- (id: string) => {
- const entry = orgLookup.get(id);
- if (entry) {
- handleSelectOrganization(entry.org);
- return;
- }
- createNotification({ text: "Organization not found", type: "error" });
- },
- [orgLookup, handleSelectOrganization]
- );
-
- const handleCliRedirect = useCallback(() => {
- 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" });
- }
- }, [callbackPort, navigate]);
-
// CLI redirect on mount
// eslint-disable-next-line react-hooks/exhaustive-deps
useMemo(() => {
- if (callbackPort) handleCliRedirect();
+ 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(() => {
- if (mfaPending && defaultSelectedOrg) {
+ const defaultOrg = orgs?.find((o) => o.id === orgId);
+ if (mfaPending && defaultOrg) {
const storedMfaToken = sessionStorage.getItem(SessionStorageKeys.MFA_TEMP_TOKEN);
if (storedMfaToken) {
sessionStorage.removeItem(SessionStorageKeys.MFA_TEMP_TOKEN);
SecurityClient.setMfaToken(storedMfaToken);
toggleShowMfa.on();
- setMfaSuccessCallback(() => () => handleSelectOrganization(defaultSelectedOrg));
+ setMfaSuccessCallback(() => () => handleSelectOrganization(defaultOrg));
}
}
- }, [mfaPending, defaultSelectedOrg]);
+ }, [mfaPending, orgs, orgId]);
const renderListContent = () => {
- if (orgsWithSubOrgs.isPending) {
+ if (orgsLoading) {
return (
<div className="flex justify-center py-6">
<Spinner size="sm" />
@@ -334,11 +291,8 @@ export const SelectOrgPage = () => {
<OrgRow
name={selectedRootOrg.name}
label="Root organization"
- joinedAt={
- selectedRootOrg.userJoinedAt ??
- organizations.data?.find((o) => o.id === selectedRootOrg.id)?.userJoinedAt
- }
- onClick={() => handleLoginById(selectedRootOrg.id)}
+ joinedAt={selectedRootOrg.userJoinedAt}
+ onClick={() => handleSelectOrganization(selectedRootOrg)}
variant="root"
/>
<p className="px-1 pt-1 text-xs font-medium tracking-wider text-mineshaft-400 uppercase">
@@ -354,7 +308,7 @@ export const SelectOrgPage = () => {
key={sub.id}
name={sub.name}
joinedAt={sub.userJoinedAt}
- onClick={() => handleLoginById(sub.id)}
+ onClick={() => handleSelectOrganization(selectedRootOrg, sub.id)}
variant="sub"
/>
))
@@ -367,13 +321,11 @@ export const SelectOrgPage = () => {
return <p className="py-4 text-center text-sm text-mineshaft-400">No organizations found</p>;
}
- const isSearching = !!searchTerm.trim();
+ const isSearching = Boolean(searchTerm.trim());
return (
<div className="space-y-2">
{filteredOrgs.map((org) => {
const hasSubOrgs = org.subOrganizations.length > 0;
- const joinedAt =
- org.userJoinedAt ?? organizations.data?.find((o) => o.id === org.id)?.userJoinedAt;
return (
<div key={org.id}>
@@ -381,15 +333,15 @@ export const SelectOrgPage = () => {
<div className="relative overflow-clip rounded-md border border-mineshaft-600 text-gray-200 shadow-md">
<button
type="button"
- onClick={() => handleLoginById(org.id)}
+ onClick={() => handleSelectOrganization(org)}
aria-label={`Login to ${org.name}`}
className="group relative z-10 flex w-full cursor-pointer items-center justify-between bg-mineshaft-700 px-4 py-3 transition-colors hover:bg-mineshaft-600"
>
<div className="flex flex-col items-start gap-1.5">
<p className="truncate transition-colors">{org.name}</p>
- {joinedAt && (
+ {org.userJoinedAt && (
<p className="text-xs text-mineshaft-400">
- Member since {format(new Date(joinedAt), "MMM d yyyy")}
+ Member since {format(new Date(org.userJoinedAt), "MMM d yyyy")}
</p>
)}
</div>
@@ -409,8 +361,8 @@ export const SelectOrgPage = () => {
) : (
<OrgRow
name={org.name}
- joinedAt={joinedAt}
- onClick={() => handleLoginById(org.id)}
+ joinedAt={org.userJoinedAt}
+ onClick={() => handleSelectOrganization(org)}
/>
)}
@@ -422,7 +374,7 @@ export const SelectOrgPage = () => {
name={sub.name}
label="Sub-organization"
joinedAt={sub.userJoinedAt}
- onClick={() => handleLoginById(sub.id)}
+ onClick={() => handleSelectOrganization(org, sub.id)}
variant="sub"
/>
))}
diff --git a/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx b/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
index 6a42e1e914..6b7ee0f1f8 100644
--- a/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
+++ b/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
@@ -16,8 +16,7 @@ import {
UnstableCard,
UnstableCardContent,
UnstableCardHeader,
- UnstableCardTitle,
- UnstableInput
+ UnstableCardTitle
} from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
import { useSendEmailVerificationCode } from "@app/hooks/api";
@@ -68,8 +67,6 @@ export const SignupSsoPage = () => {
const token = search.token as string;
const [code, setCode] = useState("");
- const [organizationName, setOrganizationName] = useState("");
- const [orgNameError, setOrgNameError] = useState(false);
const completeAccountSignup = useCompleteAccountSignup();
@@ -80,11 +77,8 @@ export const SignupSsoPage = () => {
authMethod?: string;
isEmailVerified?: boolean;
isAliasVerified?: boolean;
- organizationId?: string;
};
- const needsOrgName = !decoded.organizationId;
-
const { mutateAsync: sendEmailVerificationCode } = useSendEmailVerificationCode();
useEffect(() => {
@@ -92,16 +86,9 @@ export const SignupSsoPage = () => {
}, [token]);
const handleSubmit = async () => {
- if (needsOrgName && !organizationName.trim()) {
- setOrgNameError(true);
- return;
- }
- setOrgNameError(false);
-
const { token: accessToken } = await completeAccountSignup.mutateAsync({
type: "alias",
- code,
- organizationName: organizationName || undefined
+ code
});
SecurityClient.setSignupToken("");
@@ -112,10 +99,10 @@ export const SignupSsoPage = () => {
text: "Successfully verified",
type: "success"
});
- if (decoded.organizationId || organizationId) {
+ if (organizationId) {
navigate({
to: "/organizations/$orgId/projects",
- params: { orgId: decoded.organizationId || organizationId || "" }
+ params: { orgId: organizationId }
});
} else {
navigate({ to: "/login/select-organization" });
@@ -187,22 +174,6 @@ export const SignupSsoPage = () => {
className="code-input-v3 mt-2 mb-2"
/>
</div>
- {needsOrgName && (
- <div className="mt-4 w-full">
- <p className="mb-1 ml-1 text-sm font-medium text-label">Organization Name</p>
- <UnstableInput
- value={organizationName}
- onChange={(e) => {
- setOrganizationName(e.target.value);
- if (e.target.value.trim()) setOrgNameError(false);
- }}
- placeholder="acme"
- maxLength={64}
- className="h-10"
- />
- {orgNameError && <FieldError>Please enter an organization name.</FieldError>}
- </div>
- )}
{completeAccountSignup.isError && (
<FieldError>Oops. Your code is wrong. Please try again.</FieldError>
)}