mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-06 12:19:50 +00:00
@@ -898,6 +898,7 @@
|
|||||||
"idpDisplayName": "A display name for this identity provider",
|
"idpDisplayName": "A display name for this identity provider",
|
||||||
"idpAutoProvisionUsers": "Auto Provision Users",
|
"idpAutoProvisionUsers": "Auto Provision Users",
|
||||||
"idpAutoProvisionUsersDescription": "When enabled, users will be automatically created in the system upon first login with the ability to map users to roles and organizations.",
|
"idpAutoProvisionUsersDescription": "When enabled, users will be automatically created in the system upon first login with the ability to map users to roles and organizations.",
|
||||||
|
"idpAutoProvisionConfigureAfterCreate": "You can configure auto provision settings once the identity provider is created.",
|
||||||
"licenseBadge": "EE",
|
"licenseBadge": "EE",
|
||||||
"idpType": "Provider Type",
|
"idpType": "Provider Type",
|
||||||
"idpTypeDescription": "Select the type of identity provider you want to configure",
|
"idpTypeDescription": "Select the type of identity provider you want to configure",
|
||||||
@@ -949,7 +950,7 @@
|
|||||||
"defaultMappingsRole": "Default Role Mapping",
|
"defaultMappingsRole": "Default Role Mapping",
|
||||||
"defaultMappingsRoleDescription": "The result of this expression must return the role name as defined in the organization as a string.",
|
"defaultMappingsRoleDescription": "The result of this expression must return the role name as defined in the organization as a string.",
|
||||||
"defaultMappingsOrg": "Default Organization Mapping",
|
"defaultMappingsOrg": "Default Organization Mapping",
|
||||||
"defaultMappingsOrgDescription": "When set, this expression must return the organization ID or true for the user to access that organization. When unset, defining an organization policy for that org is enough: the user is allowed in as long as a valid role mapping can be resolved for them within the organization.",
|
"defaultMappingsOrgDescription": "When set, this expression must return the organization ID or true for the user to access that organization. When unset, defining a role mapping is enough: the user is allowed in as long as a valid role mapping can be resolved for them within the organization.",
|
||||||
"defaultMappingsSubmit": "Save Default Mappings",
|
"defaultMappingsSubmit": "Save Default Mappings",
|
||||||
"orgPoliciesEdit": "Edit Organization Policy",
|
"orgPoliciesEdit": "Edit Organization Policy",
|
||||||
"org": "Organization",
|
"org": "Organization",
|
||||||
@@ -2026,7 +2027,7 @@
|
|||||||
},
|
},
|
||||||
"internationaldomaindetected": "International Domain Detected",
|
"internationaldomaindetected": "International Domain Detected",
|
||||||
"willbestoredas": "Will be stored as:",
|
"willbestoredas": "Will be stored as:",
|
||||||
"roleMappingDescription": "Determine how roles are assigned to users when they sign in when Auto Provision is enabled.",
|
"roleMappingDescription": "Determine how roles are assigned to users when they sign in with this identity provider.",
|
||||||
"selectRole": "Select a Role",
|
"selectRole": "Select a Role",
|
||||||
"roleMappingExpression": "Expression",
|
"roleMappingExpression": "Expression",
|
||||||
"selectRolePlaceholder": "Choose a role",
|
"selectRolePlaceholder": "Choose a role",
|
||||||
@@ -2899,5 +2900,22 @@
|
|||||||
"httpDestUpdatedSuccess": "Destination updated successfully",
|
"httpDestUpdatedSuccess": "Destination updated successfully",
|
||||||
"httpDestCreatedSuccess": "Destination created successfully",
|
"httpDestCreatedSuccess": "Destination created successfully",
|
||||||
"httpDestUpdateFailed": "Failed to update destination",
|
"httpDestUpdateFailed": "Failed to update destination",
|
||||||
"httpDestCreateFailed": "Failed to create destination"
|
"httpDestCreateFailed": "Failed to create destination",
|
||||||
|
"idpAddActionCreateNew": "Create new identity provider",
|
||||||
|
"idpAddActionImportFromOrg": "Import from another organization",
|
||||||
|
"idpImportDialogTitle": "Import Identity Provider",
|
||||||
|
"idpImportDialogDescription": "Choose an identity provider from an organization where you are an admin. It will be linked to this organization.",
|
||||||
|
"idpImportSearchPlaceholder": "Search by organization or provider name...",
|
||||||
|
"idpImportEmpty": "No identity providers found.",
|
||||||
|
"idpImportedDescription": "Identity provider imported successfully.",
|
||||||
|
"idpDeleteGlobalQuestion": "Are you sure you want to permanently delete this identity provider?",
|
||||||
|
"idpDeleteGlobalDescription": "This will permanently delete the identity provider from all organizations it is associated with.",
|
||||||
|
"idpUnassociateTitle": "Unassociate Identity Provider",
|
||||||
|
"idpUnassociateQuestion": "Are you sure you want to unassociate this identity provider from this organization?",
|
||||||
|
"idpUnassociateDescription": "All users associated with this identity provider will be removed from this organization, but the identity provider will still continue to exist for other associated organizations.",
|
||||||
|
"idpUnassociateConfirm": "Confirm Unassociate Identity Provider",
|
||||||
|
"idpUnassociateWarning": "This cannot be undone for this organization.",
|
||||||
|
"idpUnassociatedDescription": "Identity provider unassociated from this organization successfully",
|
||||||
|
"idpUnassociateMenu": "Unassociate",
|
||||||
|
"idpDeleteAllOrgsMenu": "Delete"
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
public/idp/openid.png
Normal file
BIN
public/idp/openid.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
@@ -19,6 +19,7 @@ export class TraefikConfigManager {
|
|||||||
private timeoutId: NodeJS.Timeout | null = null;
|
private timeoutId: NodeJS.Timeout | null = null;
|
||||||
private lastCertificateFetch: Date | null = null;
|
private lastCertificateFetch: Date | null = null;
|
||||||
private lastKnownDomains = new Set<string>();
|
private lastKnownDomains = new Set<string>();
|
||||||
|
private pendingDeletion = new Map<string, number>(); // domain -> cycles remaining before delete
|
||||||
private lastLocalCertificateState = new Map<
|
private lastLocalCertificateState = new Map<
|
||||||
string,
|
string,
|
||||||
{
|
{
|
||||||
@@ -1004,33 +1005,62 @@ export class TraefikConfigManager {
|
|||||||
|
|
||||||
const dirName = dirent.name;
|
const dirName = dirent.name;
|
||||||
// Only delete if NO current domain is exactly the same or ends with `.${dirName}`
|
// Only delete if NO current domain is exactly the same or ends with `.${dirName}`
|
||||||
const shouldDelete = !Array.from(currentActiveDomains).some(
|
const isUnused = !Array.from(currentActiveDomains).some(
|
||||||
(domain) =>
|
(domain) =>
|
||||||
domain === dirName || domain.endsWith(`.${dirName}`)
|
domain === dirName || domain.endsWith(`.${dirName}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (shouldDelete) {
|
if (!isUnused) {
|
||||||
const domainDir = path.join(certsPath, dirName);
|
// Domain is still active — remove from pending deletion if it was queued
|
||||||
logger.info(
|
if (this.pendingDeletion.has(dirName)) {
|
||||||
`Cleaning up unused certificate directory: ${dirName}`
|
logger.info(
|
||||||
);
|
`Certificate ${dirName} is active again, cancelling pending deletion`
|
||||||
fs.rmSync(domainDir, { recursive: true, force: true });
|
|
||||||
|
|
||||||
// Remove from local state tracking
|
|
||||||
this.lastLocalCertificateState.delete(dirName);
|
|
||||||
|
|
||||||
// Remove from dynamic config
|
|
||||||
const certFilePath = path.join(domainDir, "cert.pem");
|
|
||||||
const keyFilePath = path.join(domainDir, "key.pem");
|
|
||||||
const before = dynamicConfig.tls.certificates.length;
|
|
||||||
dynamicConfig.tls.certificates =
|
|
||||||
dynamicConfig.tls.certificates.filter(
|
|
||||||
(entry: any) =>
|
|
||||||
entry.certFile !== certFilePath &&
|
|
||||||
entry.keyFile !== keyFilePath
|
|
||||||
);
|
);
|
||||||
if (dynamicConfig.tls.certificates.length !== before) {
|
this.pendingDeletion.delete(dirName);
|
||||||
configChanged = true;
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Domain is unused — add to pending deletion or decrement its counter
|
||||||
|
if (!this.pendingDeletion.has(dirName)) {
|
||||||
|
const graceCycles = 3;
|
||||||
|
logger.info(
|
||||||
|
`Certificate ${dirName} is no longer in use. Will delete after ${graceCycles} more cycles.`
|
||||||
|
);
|
||||||
|
this.pendingDeletion.set(dirName, graceCycles);
|
||||||
|
} else {
|
||||||
|
const remaining = this.pendingDeletion.get(dirName)! - 1;
|
||||||
|
if (remaining > 0) {
|
||||||
|
logger.info(
|
||||||
|
`Certificate ${dirName} pending deletion: ${remaining} cycle(s) remaining`
|
||||||
|
);
|
||||||
|
this.pendingDeletion.set(dirName, remaining);
|
||||||
|
} else {
|
||||||
|
// Grace period expired — actually delete now
|
||||||
|
this.pendingDeletion.delete(dirName);
|
||||||
|
|
||||||
|
const domainDir = path.join(certsPath, dirName);
|
||||||
|
logger.info(
|
||||||
|
`Cleaning up unused certificate directory: ${dirName}`
|
||||||
|
);
|
||||||
|
fs.rmSync(domainDir, { recursive: true, force: true });
|
||||||
|
|
||||||
|
// Remove from local state tracking
|
||||||
|
this.lastLocalCertificateState.delete(dirName);
|
||||||
|
|
||||||
|
// Remove from dynamic config
|
||||||
|
const certFilePath = path.join(domainDir, "cert.pem");
|
||||||
|
const keyFilePath = path.join(domainDir, "key.pem");
|
||||||
|
const before = dynamicConfig.tls.certificates.length;
|
||||||
|
dynamicConfig.tls.certificates =
|
||||||
|
dynamicConfig.tls.certificates.filter(
|
||||||
|
(entry: any) =>
|
||||||
|
entry.certFile !== certFilePath &&
|
||||||
|
entry.keyFile !== keyFilePath
|
||||||
|
);
|
||||||
|
if (dynamicConfig.tls.certificates.length !== before) {
|
||||||
|
configChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ import {
|
|||||||
verifyRoleAccess,
|
verifyRoleAccess,
|
||||||
verifyUserAccess,
|
verifyUserAccess,
|
||||||
verifyUserCanSetUserOrgRoles,
|
verifyUserCanSetUserOrgRoles,
|
||||||
verifySiteProvisioningKeyAccess
|
verifySiteProvisioningKeyAccess,
|
||||||
|
verifyIsLoggedInUser,
|
||||||
|
verifyAdmin
|
||||||
} from "@server/middlewares";
|
} from "@server/middlewares";
|
||||||
import { ActionsEnum } from "@server/auth/actions";
|
import { ActionsEnum } from "@server/auth/actions";
|
||||||
import {
|
import {
|
||||||
@@ -87,6 +89,7 @@ authenticated.put(
|
|||||||
"/org/:orgId/idp/oidc",
|
"/org/:orgId/idp/oidc",
|
||||||
verifyValidLicense,
|
verifyValidLicense,
|
||||||
verifyValidSubscription(tierMatrix.orgOidc),
|
verifyValidSubscription(tierMatrix.orgOidc),
|
||||||
|
orgIdp.requireOrgIdentityProviderMode,
|
||||||
verifyOrgAccess,
|
verifyOrgAccess,
|
||||||
verifyLimits,
|
verifyLimits,
|
||||||
verifyUserHasAction(ActionsEnum.createIdp),
|
verifyUserHasAction(ActionsEnum.createIdp),
|
||||||
@@ -94,10 +97,23 @@ authenticated.put(
|
|||||||
orgIdp.createOrgOidcIdp
|
orgIdp.createOrgOidcIdp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.post(
|
||||||
|
"/org/:orgId/idp/:idpId/import",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.orgOidc),
|
||||||
|
orgIdp.requireOrgIdentityProviderMode,
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyLimits,
|
||||||
|
verifyAdmin,
|
||||||
|
logActionAudit(ActionsEnum.createIdp),
|
||||||
|
orgIdp.importOrgIdp
|
||||||
|
);
|
||||||
|
|
||||||
authenticated.post(
|
authenticated.post(
|
||||||
"/org/:orgId/idp/:idpId/oidc",
|
"/org/:orgId/idp/:idpId/oidc",
|
||||||
verifyValidLicense,
|
verifyValidLicense,
|
||||||
verifyValidSubscription(tierMatrix.orgOidc),
|
verifyValidSubscription(tierMatrix.orgOidc),
|
||||||
|
orgIdp.requireOrgIdentityProviderMode,
|
||||||
verifyOrgAccess,
|
verifyOrgAccess,
|
||||||
verifyIdpAccess,
|
verifyIdpAccess,
|
||||||
verifyLimits,
|
verifyLimits,
|
||||||
@@ -109,6 +125,7 @@ authenticated.post(
|
|||||||
authenticated.delete(
|
authenticated.delete(
|
||||||
"/org/:orgId/idp/:idpId",
|
"/org/:orgId/idp/:idpId",
|
||||||
verifyValidLicense,
|
verifyValidLicense,
|
||||||
|
orgIdp.requireOrgIdentityProviderMode,
|
||||||
verifyOrgAccess,
|
verifyOrgAccess,
|
||||||
verifyIdpAccess,
|
verifyIdpAccess,
|
||||||
verifyUserHasAction(ActionsEnum.deleteIdp),
|
verifyUserHasAction(ActionsEnum.deleteIdp),
|
||||||
@@ -116,6 +133,17 @@ authenticated.delete(
|
|||||||
orgIdp.deleteOrgIdp
|
orgIdp.deleteOrgIdp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.delete(
|
||||||
|
"/org/:orgId/idp/:idpId/association",
|
||||||
|
verifyValidLicense,
|
||||||
|
orgIdp.requireOrgIdentityProviderMode,
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyIdpAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.deleteIdp),
|
||||||
|
logActionAudit(ActionsEnum.deleteIdp),
|
||||||
|
orgIdp.unassociateOrgIdp
|
||||||
|
);
|
||||||
|
|
||||||
authenticated.get(
|
authenticated.get(
|
||||||
"/org/:orgId/idp/:idpId",
|
"/org/:orgId/idp/:idpId",
|
||||||
verifyValidLicense,
|
verifyValidLicense,
|
||||||
@@ -125,16 +153,14 @@ authenticated.get(
|
|||||||
orgIdp.getOrgIdp
|
orgIdp.getOrgIdp
|
||||||
);
|
);
|
||||||
|
|
||||||
authenticated.get(
|
|
||||||
"/org/:orgId/idp",
|
|
||||||
verifyValidLicense,
|
|
||||||
verifyOrgAccess,
|
|
||||||
verifyUserHasAction(ActionsEnum.listIdps),
|
|
||||||
orgIdp.listOrgIdps
|
|
||||||
);
|
|
||||||
|
|
||||||
authenticated.get("/org/:orgId/idp", orgIdp.listOrgIdps); // anyone can see this; it's just a list of idp names and ids
|
authenticated.get("/org/:orgId/idp", orgIdp.listOrgIdps); // anyone can see this; it's just a list of idp names and ids
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/user/:userId/admin-org-idps",
|
||||||
|
verifyIsLoggedInUser,
|
||||||
|
orgIdp.listUserAdminOrgIdps
|
||||||
|
);
|
||||||
|
|
||||||
authenticated.get(
|
authenticated.get(
|
||||||
"/org/:orgId/certificate/:domainId/:domain",
|
"/org/:orgId/certificate/:domainId/:domain",
|
||||||
verifyValidLicense,
|
verifyValidLicense,
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import config from "@server/lib/config";
|
|||||||
import { CreateOrgIdpResponse } from "@server/routers/orgIdp/types";
|
import { CreateOrgIdpResponse } from "@server/routers/orgIdp/types";
|
||||||
import { isSubscribed } from "#private/lib/isSubscribed";
|
import { isSubscribed } from "#private/lib/isSubscribed";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import privateConfig from "#private/lib/config";
|
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
|
||||||
const paramsSchema = z.strictObject({ orgId: z.string().nonempty() });
|
const paramsSchema = z.strictObject({ orgId: z.string().nonempty() });
|
||||||
@@ -45,6 +44,7 @@ const bodySchema = z.strictObject({
|
|||||||
autoProvision: z.boolean().optional(),
|
autoProvision: z.boolean().optional(),
|
||||||
variant: z.enum(["oidc", "google", "azure"]).optional().default("oidc"),
|
variant: z.enum(["oidc", "google", "azure"]).optional().default("oidc"),
|
||||||
roleMapping: z.string().optional(),
|
roleMapping: z.string().optional(),
|
||||||
|
orgMapping: z.string().nullish(),
|
||||||
tags: z.string().optional()
|
tags: z.string().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -94,18 +94,6 @@ export async function createOrgOidcIdp(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
privateConfig.getRawPrivateConfig().app.identity_provider_mode !==
|
|
||||||
"org"
|
|
||||||
) {
|
|
||||||
return next(
|
|
||||||
createHttpError(
|
|
||||||
HttpCode.BAD_REQUEST,
|
|
||||||
"Organization-specific IdP creation is not allowed in the current identity provider mode. Set app.identity_provider_mode to 'org' in the private configuration to enable this feature."
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
clientId,
|
clientId,
|
||||||
clientSecret,
|
clientSecret,
|
||||||
@@ -118,6 +106,7 @@ export async function createOrgOidcIdp(
|
|||||||
name,
|
name,
|
||||||
variant,
|
variant,
|
||||||
roleMapping,
|
roleMapping,
|
||||||
|
orgMapping: orgMappingBody,
|
||||||
tags
|
tags
|
||||||
} = parsedBody.data;
|
} = parsedBody.data;
|
||||||
|
|
||||||
@@ -169,7 +158,7 @@ export async function createOrgOidcIdp(
|
|||||||
idpId: idpRes.idpId,
|
idpId: idpRes.idpId,
|
||||||
orgId: orgId,
|
orgId: orgId,
|
||||||
roleMapping: roleMapping || null,
|
roleMapping: roleMapping || null,
|
||||||
orgMapping: `'${orgId}'`
|
orgMapping: orgMappingBody
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import { fromError } from "zod-validation-error";
|
|||||||
import { idp, idpOidcConfig, idpOrg } from "@server/db";
|
import { idp, idpOidcConfig, idpOrg } from "@server/db";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { OpenAPITags, registry } from "@server/openApi";
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
import privateConfig from "#private/lib/config";
|
|
||||||
|
|
||||||
const paramsSchema = z
|
const paramsSchema = z
|
||||||
.object({
|
.object({
|
||||||
@@ -60,18 +59,6 @@ export async function deleteOrgIdp(
|
|||||||
|
|
||||||
const { idpId } = parsedParams.data;
|
const { idpId } = parsedParams.data;
|
||||||
|
|
||||||
if (
|
|
||||||
privateConfig.getRawPrivateConfig().app.identity_provider_mode !==
|
|
||||||
"org"
|
|
||||||
) {
|
|
||||||
return next(
|
|
||||||
createHttpError(
|
|
||||||
HttpCode.BAD_REQUEST,
|
|
||||||
"Organization-specific IdP creation is not allowed in the current identity provider mode. Set app.identity_provider_mode to 'org' in the private configuration to enable this feature."
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if IDP exists
|
// Check if IDP exists
|
||||||
const [existingIdp] = await db
|
const [existingIdp] = await db
|
||||||
.select()
|
.select()
|
||||||
|
|||||||
212
server/private/routers/orgIdp/importOrgIdp.ts
Normal file
212
server/private/routers/orgIdp/importOrgIdp.ts
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025-2026 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { db } from "@server/db";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
|
import { idp, idpOrg, orgs, roles, userOrgs } from "@server/db";
|
||||||
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
|
import { CreateOrgIdpResponse } from "@server/routers/orgIdp/types";
|
||||||
|
import { generateOidcRedirectUrl } from "@server/lib/idp/generateRedirectUrl";
|
||||||
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
|
const paramsSchema = z.strictObject({
|
||||||
|
orgId: z.string().nonempty(),
|
||||||
|
idpId: z.coerce.number<number>().int().positive()
|
||||||
|
});
|
||||||
|
|
||||||
|
const bodySchema = z.strictObject({
|
||||||
|
sourceOrgId: z.string().nonempty()
|
||||||
|
});
|
||||||
|
|
||||||
|
async function userIsOrgAdmin(
|
||||||
|
userId: string,
|
||||||
|
orgId: string,
|
||||||
|
session: Request["session"]
|
||||||
|
): Promise<boolean> {
|
||||||
|
const [userOrgRow] = await db
|
||||||
|
.select()
|
||||||
|
.from(userOrgs)
|
||||||
|
.where(and(eq(userOrgs.userId, userId), eq(userOrgs.orgId, orgId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!userOrgRow) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const policyCheck = await checkOrgAccessPolicy({
|
||||||
|
orgId,
|
||||||
|
userId,
|
||||||
|
session
|
||||||
|
});
|
||||||
|
if (!policyCheck.allowed || policyCheck.error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const roleIds = await getUserOrgRoleIds(userId, orgId);
|
||||||
|
if (roleIds.length === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [adminRole] = await db
|
||||||
|
.select()
|
||||||
|
.from(roles)
|
||||||
|
.where(and(inArray(roles.roleId, roleIds), eq(roles.isAdmin, true)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
return !!adminRole;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function importOrgIdp(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = paramsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { orgId: targetOrgId, idpId } = parsedParams.data;
|
||||||
|
|
||||||
|
const parsedBody = bodySchema.safeParse(req.body);
|
||||||
|
if (!parsedBody.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedBody.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { sourceOrgId } = parsedBody.data;
|
||||||
|
|
||||||
|
if (sourceOrgId === targetOrgId) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"Source and target organization must be different"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const userId = req.user!.userId;
|
||||||
|
|
||||||
|
const sourceLinked = await db
|
||||||
|
.select()
|
||||||
|
.from(idpOrg)
|
||||||
|
.where(and(eq(idpOrg.idpId, idpId), eq(idpOrg.orgId, sourceOrgId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (sourceLinked.length === 0) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.NOT_FOUND,
|
||||||
|
"IdP not found for the source organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const sourceAdmin = await userIsOrgAdmin(
|
||||||
|
userId,
|
||||||
|
sourceOrgId,
|
||||||
|
req.session
|
||||||
|
);
|
||||||
|
if (!sourceAdmin) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"You must be an organization admin in the source organization where this IdP is linked"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [targetOrg] = await db
|
||||||
|
.select({ orgId: orgs.orgId })
|
||||||
|
.from(orgs)
|
||||||
|
.where(eq(orgs.orgId, targetOrgId))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!targetOrg) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.NOT_FOUND,
|
||||||
|
"Target organization not found"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [existingIdp] = await db
|
||||||
|
.select()
|
||||||
|
.from(idp)
|
||||||
|
.where(eq(idp.idpId, idpId))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!existingIdp) {
|
||||||
|
return next(createHttpError(HttpCode.NOT_FOUND, "IdP not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
const alreadyTarget = await db
|
||||||
|
.select()
|
||||||
|
.from(idpOrg)
|
||||||
|
.where(and(eq(idpOrg.idpId, idpId), eq(idpOrg.orgId, targetOrgId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (alreadyTarget.length > 0) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.CONFLICT,
|
||||||
|
"This IdP is already linked to the target organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.insert(idpOrg).values({
|
||||||
|
idpId,
|
||||||
|
orgId: targetOrgId,
|
||||||
|
roleMapping: null,
|
||||||
|
orgMapping: null
|
||||||
|
});
|
||||||
|
|
||||||
|
const redirectUrl = await generateOidcRedirectUrl(idpId, targetOrgId);
|
||||||
|
|
||||||
|
return response<CreateOrgIdpResponse>(res, {
|
||||||
|
data: {
|
||||||
|
idpId,
|
||||||
|
redirectUrl
|
||||||
|
},
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Org IdP imported successfully",
|
||||||
|
status: HttpCode.CREATED
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export * from "./createOrgOidcIdp";
|
export * from "./createOrgOidcIdp";
|
||||||
|
export * from "./importOrgIdp";
|
||||||
export * from "./getOrgIdp";
|
export * from "./getOrgIdp";
|
||||||
export * from "./listOrgIdps";
|
export * from "./listOrgIdps";
|
||||||
|
export * from "./listUserAdminOrgIdps";
|
||||||
export * from "./updateOrgOidcIdp";
|
export * from "./updateOrgOidcIdp";
|
||||||
export * from "./deleteOrgIdp";
|
export * from "./deleteOrgIdp";
|
||||||
|
export * from "./unassociateOrgIdp";
|
||||||
|
export * from "./requireOrgIdentityProviderMode";
|
||||||
|
|||||||
160
server/private/routers/orgIdp/listUserAdminOrgIdps.ts
Normal file
160
server/private/routers/orgIdp/listUserAdminOrgIdps.ts
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025-2026 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { db, idpOidcConfig } from "@server/db";
|
||||||
|
import { idp, idpOrg, orgs, roles, userOrgRoles } from "@server/db";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import { and, eq, inArray, sql } from "drizzle-orm";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
|
import { ListUserAdminOrgIdpsResponse } from "@server/routers/orgIdp/types";
|
||||||
|
|
||||||
|
const querySchema = z.strictObject({
|
||||||
|
limit: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.default("1000")
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().nonnegative()),
|
||||||
|
offset: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.default("0")
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().nonnegative())
|
||||||
|
});
|
||||||
|
|
||||||
|
const paramsSchema = z.strictObject({
|
||||||
|
userId: z.string().nonempty()
|
||||||
|
});
|
||||||
|
|
||||||
|
async function getOrgIdsWhereUserIsAdmin(userId: string): Promise<string[]> {
|
||||||
|
const rows = await db
|
||||||
|
.select({ orgId: userOrgRoles.orgId })
|
||||||
|
.from(userOrgRoles)
|
||||||
|
.innerJoin(roles, eq(userOrgRoles.roleId, roles.roleId))
|
||||||
|
.where(and(eq(userOrgRoles.userId, userId), eq(roles.isAdmin, true)));
|
||||||
|
return [...new Set(rows.map((r) => r.orgId))];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function queryIdpsForOrgs(
|
||||||
|
orgIds: string[],
|
||||||
|
limit: number,
|
||||||
|
offset: number
|
||||||
|
) {
|
||||||
|
return db
|
||||||
|
.select({
|
||||||
|
idpId: idp.idpId,
|
||||||
|
orgId: idpOrg.orgId,
|
||||||
|
orgName: orgs.name,
|
||||||
|
name: idp.name,
|
||||||
|
type: idp.type,
|
||||||
|
variant: idpOidcConfig.variant,
|
||||||
|
tags: idp.tags
|
||||||
|
})
|
||||||
|
.from(idpOrg)
|
||||||
|
.where(inArray(idpOrg.orgId, orgIds))
|
||||||
|
.innerJoin(orgs, eq(orgs.orgId, idpOrg.orgId))
|
||||||
|
.innerJoin(idp, eq(idp.idpId, idpOrg.idpId))
|
||||||
|
.innerJoin(idpOidcConfig, eq(idpOidcConfig.idpId, idpOrg.idpId))
|
||||||
|
.orderBy(sql`idp.name DESC`)
|
||||||
|
.limit(limit)
|
||||||
|
.offset(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function countIdpsForOrgs(orgIds: string[]) {
|
||||||
|
const [{ count }] = await db
|
||||||
|
.select({ count: sql<number>`count(*)` })
|
||||||
|
.from(idpOrg)
|
||||||
|
.innerJoin(idp, eq(idp.idpId, idpOrg.idpId))
|
||||||
|
.innerJoin(idpOidcConfig, eq(idpOidcConfig.idpId, idpOrg.idpId))
|
||||||
|
.where(inArray(idpOrg.orgId, orgIds));
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listUserAdminOrgIdps(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = paramsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const { userId } = parsedParams.data;
|
||||||
|
|
||||||
|
const parsedQuery = querySchema.safeParse(req.query);
|
||||||
|
if (!parsedQuery.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedQuery.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const { limit, offset } = parsedQuery.data;
|
||||||
|
|
||||||
|
const adminOrgIds = await getOrgIdsWhereUserIsAdmin(userId);
|
||||||
|
|
||||||
|
if (adminOrgIds.length === 0) {
|
||||||
|
return response<ListUserAdminOrgIdpsResponse>(res, {
|
||||||
|
data: {
|
||||||
|
idps: [],
|
||||||
|
pagination: {
|
||||||
|
total: 0,
|
||||||
|
limit,
|
||||||
|
offset
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Org Idps retrieved successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = await queryIdpsForOrgs(adminOrgIds, limit, offset);
|
||||||
|
const total = await countIdpsForOrgs(adminOrgIds);
|
||||||
|
|
||||||
|
return response<ListUserAdminOrgIdpsResponse>(res, {
|
||||||
|
data: {
|
||||||
|
idps: list,
|
||||||
|
pagination: {
|
||||||
|
total,
|
||||||
|
limit,
|
||||||
|
offset
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Org Idps retrieved successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025-2026 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import privateConfig from "#private/lib/config";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
|
||||||
|
export function requireOrgIdentityProviderMode(
|
||||||
|
_req: Request,
|
||||||
|
_res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): void {
|
||||||
|
if (privateConfig.getRawPrivateConfig().app.identity_provider_mode !== "org") {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"Organization-specific IdP creation is not allowed in the current identity provider mode. Set app.identity_provider_mode to 'org' in the private configuration to enable this feature."
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return next();
|
||||||
|
}
|
||||||
96
server/private/routers/orgIdp/unassociateOrgIdp.ts
Normal file
96
server/private/routers/orgIdp/unassociateOrgIdp.ts
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025-2026 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { db, idpOrg } from "@server/db";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import { and, eq, sql } from "drizzle-orm";
|
||||||
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
|
|
||||||
|
const paramsSchema = z
|
||||||
|
.object({
|
||||||
|
orgId: z.string().nonempty(),
|
||||||
|
idpId: z.coerce.number<number>().int().positive()
|
||||||
|
})
|
||||||
|
.strict();
|
||||||
|
|
||||||
|
export async function unassociateOrgIdp(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = paramsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { orgId, idpId } = parsedParams.data;
|
||||||
|
|
||||||
|
const [association] = await db
|
||||||
|
.select()
|
||||||
|
.from(idpOrg)
|
||||||
|
.where(and(eq(idpOrg.idpId, idpId), eq(idpOrg.orgId, orgId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!association) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.NOT_FOUND,
|
||||||
|
`IdP with ID ${idpId} is not associated with organization ${orgId}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [{ count }] = await db
|
||||||
|
.select({ count: sql<number>`count(*)` })
|
||||||
|
.from(idpOrg)
|
||||||
|
.where(eq(idpOrg.idpId, idpId));
|
||||||
|
|
||||||
|
if (count <= 1) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"This is the last organization associated with this identity provider. Delete it instead."
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await db
|
||||||
|
.delete(idpOrg)
|
||||||
|
.where(and(eq(idpOrg.idpId, idpId), eq(idpOrg.orgId, orgId)));
|
||||||
|
|
||||||
|
return response<null>(res, {
|
||||||
|
data: null,
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Org IdP unassociated successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,6 @@ import { encrypt } from "@server/lib/crypto";
|
|||||||
import config from "@server/lib/config";
|
import config from "@server/lib/config";
|
||||||
import { isSubscribed } from "#private/lib/isSubscribed";
|
import { isSubscribed } from "#private/lib/isSubscribed";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import privateConfig from "#private/lib/config";
|
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
|
||||||
const paramsSchema = z
|
const paramsSchema = z
|
||||||
@@ -48,6 +47,7 @@ const bodySchema = z.strictObject({
|
|||||||
scopes: z.string().optional(),
|
scopes: z.string().optional(),
|
||||||
autoProvision: z.boolean().optional(),
|
autoProvision: z.boolean().optional(),
|
||||||
roleMapping: z.string().optional(),
|
roleMapping: z.string().optional(),
|
||||||
|
orgMapping: z.string().nullish(),
|
||||||
tags: z.string().optional()
|
tags: z.string().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -99,18 +99,6 @@ export async function updateOrgOidcIdp(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
privateConfig.getRawPrivateConfig().app.identity_provider_mode !==
|
|
||||||
"org"
|
|
||||||
) {
|
|
||||||
return next(
|
|
||||||
createHttpError(
|
|
||||||
HttpCode.BAD_REQUEST,
|
|
||||||
"Organization-specific IdP creation is not allowed in the current identity provider mode. Set app.identity_provider_mode to 'org' in the private configuration to enable this feature."
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { idpId, orgId } = parsedParams.data;
|
const { idpId, orgId } = parsedParams.data;
|
||||||
const {
|
const {
|
||||||
clientId,
|
clientId,
|
||||||
@@ -123,6 +111,7 @@ export async function updateOrgOidcIdp(
|
|||||||
namePath,
|
namePath,
|
||||||
name,
|
name,
|
||||||
roleMapping,
|
roleMapping,
|
||||||
|
orgMapping,
|
||||||
tags
|
tags
|
||||||
} = parsedBody.data;
|
} = parsedBody.data;
|
||||||
|
|
||||||
@@ -218,13 +207,20 @@ export async function updateOrgOidcIdp(
|
|||||||
.where(eq(idpOidcConfig.idpId, idpId));
|
.where(eq(idpOidcConfig.idpId, idpId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const idpOrgPolicyPatch: {
|
||||||
|
roleMapping?: string;
|
||||||
|
orgMapping?: string | null;
|
||||||
|
} = {};
|
||||||
if (roleMapping !== undefined) {
|
if (roleMapping !== undefined) {
|
||||||
// Update IdP-org policy
|
idpOrgPolicyPatch.roleMapping = roleMapping;
|
||||||
|
}
|
||||||
|
if (orgMapping !== undefined) {
|
||||||
|
idpOrgPolicyPatch.orgMapping = orgMapping;
|
||||||
|
}
|
||||||
|
if (Object.keys(idpOrgPolicyPatch).length > 0) {
|
||||||
await trx
|
await trx
|
||||||
.update(idpOrg)
|
.update(idpOrg)
|
||||||
.set({
|
.set(idpOrgPolicyPatch)
|
||||||
roleMapping
|
|
||||||
})
|
|
||||||
.where(
|
.where(
|
||||||
and(eq(idpOrg.idpId, idpId), eq(idpOrg.orgId, orgId))
|
and(eq(idpOrg.idpId, idpId), eq(idpOrg.orgId, orgId))
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { db, orgs, userOrgs, users } from "@server/db";
|
import { db, orgs, userOrgs, users } from "@server/db";
|
||||||
import { eq, and, inArray } from "drizzle-orm";
|
import { eq, and, inArray, not } from "drizzle-orm";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
@@ -17,11 +17,10 @@ import { verifyTotpCode } from "@server/auth/totp";
|
|||||||
import { calculateUserClientsForOrgs } from "@server/lib/calculateUserClientsForOrgs";
|
import { calculateUserClientsForOrgs } from "@server/lib/calculateUserClientsForOrgs";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { getOrgTierData } from "#dynamic/lib/billing";
|
import { getOrgTierData } from "#dynamic/lib/billing";
|
||||||
import {
|
import { deleteOrgById, sendTerminationMessages } from "@server/lib/deleteOrg";
|
||||||
deleteOrgById,
|
|
||||||
sendTerminationMessages
|
|
||||||
} from "@server/lib/deleteOrg";
|
|
||||||
import { UserType } from "@server/types/UserTypes";
|
import { UserType } from "@server/types/UserTypes";
|
||||||
|
import { usageService } from "@server/lib/billing/usageService";
|
||||||
|
import { FeatureId } from "@server/lib/billing";
|
||||||
|
|
||||||
const deleteMyAccountBody = z.strictObject({
|
const deleteMyAccountBody = z.strictObject({
|
||||||
password: z.string().optional(),
|
password: z.string().optional(),
|
||||||
@@ -98,9 +97,9 @@ export async function deleteMyAccount(
|
|||||||
and(eq(userOrgs.userId, userId), eq(userOrgs.isOwner, true))
|
and(eq(userOrgs.userId, userId), eq(userOrgs.isOwner, true))
|
||||||
);
|
);
|
||||||
|
|
||||||
const orgIds = ownedOrgsRows.map((r) => r.orgId);
|
const ownedOrgIds = ownedOrgsRows.map((r) => r.orgId);
|
||||||
|
|
||||||
if (build === "saas" && orgIds.length > 0) {
|
if (build === "saas" && ownedOrgIds.length > 0) {
|
||||||
const primaryOrgId = ownedOrgsRows.find(
|
const primaryOrgId = ownedOrgsRows.find(
|
||||||
(r) => r.isBillingOrg && r.isOwner
|
(r) => r.isBillingOrg && r.isOwner
|
||||||
)?.orgId;
|
)?.orgId;
|
||||||
@@ -119,14 +118,14 @@ export async function deleteMyAccount(
|
|||||||
|
|
||||||
if (!password) {
|
if (!password) {
|
||||||
const orgsWithNames =
|
const orgsWithNames =
|
||||||
orgIds.length > 0
|
ownedOrgIds.length > 0
|
||||||
? await db
|
? await db
|
||||||
.select({
|
.select({
|
||||||
orgId: orgs.orgId,
|
orgId: orgs.orgId,
|
||||||
name: orgs.name
|
name: orgs.name
|
||||||
})
|
})
|
||||||
.from(orgs)
|
.from(orgs)
|
||||||
.where(inArray(orgs.orgId, orgIds))
|
.where(inArray(orgs.orgId, ownedOrgIds))
|
||||||
: [];
|
: [];
|
||||||
return response<DeleteMyAccountPreviewResponse>(res, {
|
return response<DeleteMyAccountPreviewResponse>(res, {
|
||||||
data: {
|
data: {
|
||||||
@@ -206,9 +205,23 @@ export async function deleteMyAccount(
|
|||||||
olmsToTerminate: allOlmsToTerminate
|
olmsToTerminate: allOlmsToTerminate
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const otherOrgsTheUserWasIn = await db
|
||||||
|
.select()
|
||||||
|
.from(userOrgs)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(userOrgs.userId, userId),
|
||||||
|
not(inArray(userOrgs.orgId, ownedOrgIds))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
await db.transaction(async (trx) => {
|
await db.transaction(async (trx) => {
|
||||||
await trx.delete(users).where(eq(users.userId, userId));
|
await trx.delete(users).where(eq(users.userId, userId));
|
||||||
await calculateUserClientsForOrgs(userId, trx);
|
await calculateUserClientsForOrgs(userId, trx);
|
||||||
|
// loop through the other orgs and decrement the count
|
||||||
|
for (const userOrg of otherOrgsTheUserWasIn) {
|
||||||
|
await usageService.add(userOrg.orgId, FeatureId.USERS, -1, trx);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -233,10 +246,7 @@ export async function deleteMyAccount(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
HttpCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"An error occurred"
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,3 +25,22 @@ export type ListOrgIdpsResponse = {
|
|||||||
offset: number;
|
offset: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ListUserAdminOrgIdpsEntry = {
|
||||||
|
idpId: number;
|
||||||
|
orgId: string;
|
||||||
|
orgName: string;
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
variant: string;
|
||||||
|
tags: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ListUserAdminOrgIdpsResponse = {
|
||||||
|
idps: ListUserAdminOrgIdpsEntry[];
|
||||||
|
pagination: {
|
||||||
|
total: number;
|
||||||
|
limit: number;
|
||||||
|
offset: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ import type { ListRolesResponse } from "@server/routers/role";
|
|||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Approvals"
|
||||||
|
};
|
||||||
|
|
||||||
export interface ApprovalFeedPageProps {
|
export interface ApprovalFeedPageProps {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ import { getTranslations } from "next-intl/server";
|
|||||||
import { getCachedOrgUser } from "@app/lib/api/getCachedOrgUser";
|
import { getCachedOrgUser } from "@app/lib/api/getCachedOrgUser";
|
||||||
import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Billing"
|
||||||
|
};
|
||||||
|
|
||||||
type BillingSettingsProps = {
|
type BillingSettingsProps = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ export default function GeneralPage() {
|
|||||||
emailPath: z.string().nullable().optional(),
|
emailPath: z.string().nullable().optional(),
|
||||||
namePath: z.string().nullable().optional(),
|
namePath: z.string().nullable().optional(),
|
||||||
scopes: z.string().min(1, { message: t("idpScopeRequired") }),
|
scopes: z.string().min(1, { message: t("idpScopeRequired") }),
|
||||||
autoProvision: z.boolean().default(false)
|
autoProvision: z.boolean().default(false),
|
||||||
|
orgMapping: z.string().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Google form schema (simplified)
|
// Google form schema (simplified)
|
||||||
@@ -109,7 +110,8 @@ export default function GeneralPage() {
|
|||||||
.min(1, { message: t("idpClientSecretRequired") }),
|
.min(1, { message: t("idpClientSecretRequired") }),
|
||||||
roleMapping: z.string().nullable().optional(),
|
roleMapping: z.string().nullable().optional(),
|
||||||
roleId: z.number().nullable().optional(),
|
roleId: z.number().nullable().optional(),
|
||||||
autoProvision: z.boolean().default(false)
|
autoProvision: z.boolean().default(false),
|
||||||
|
orgMapping: z.string().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Azure form schema (simplified with tenant ID)
|
// Azure form schema (simplified with tenant ID)
|
||||||
@@ -122,7 +124,8 @@ export default function GeneralPage() {
|
|||||||
tenantId: z.string().min(1, { message: t("idpTenantIdRequired") }),
|
tenantId: z.string().min(1, { message: t("idpTenantIdRequired") }),
|
||||||
roleMapping: z.string().nullable().optional(),
|
roleMapping: z.string().nullable().optional(),
|
||||||
roleId: z.number().nullable().optional(),
|
roleId: z.number().nullable().optional(),
|
||||||
autoProvision: z.boolean().default(false)
|
autoProvision: z.boolean().default(false),
|
||||||
|
orgMapping: z.string().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
type OidcFormValues = z.infer<typeof OidcFormSchema>;
|
type OidcFormValues = z.infer<typeof OidcFormSchema>;
|
||||||
@@ -160,7 +163,8 @@ export default function GeneralPage() {
|
|||||||
autoProvision: true,
|
autoProvision: true,
|
||||||
roleMapping: null,
|
roleMapping: null,
|
||||||
roleId: null,
|
roleId: null,
|
||||||
tenantId: ""
|
tenantId: "",
|
||||||
|
orgMapping: ""
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -227,7 +231,8 @@ export default function GeneralPage() {
|
|||||||
clientSecret: data.idpOidcConfig.clientSecret,
|
clientSecret: data.idpOidcConfig.clientSecret,
|
||||||
autoProvision: data.idp.autoProvision,
|
autoProvision: data.idp.autoProvision,
|
||||||
roleMapping: roleMapping || null,
|
roleMapping: roleMapping || null,
|
||||||
roleId: null
|
roleId: null,
|
||||||
|
orgMapping: data.idpOrg?.orgMapping ?? ""
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add variant-specific fields
|
// Add variant-specific fields
|
||||||
@@ -344,12 +349,14 @@ export default function GeneralPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build payload based on variant
|
// Build payload based on variant
|
||||||
|
const orgMappingTrimmed = data.orgMapping?.trim() ?? "";
|
||||||
let payload: any = {
|
let payload: any = {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
clientId: data.clientId,
|
clientId: data.clientId,
|
||||||
clientSecret: data.clientSecret,
|
clientSecret: data.clientSecret,
|
||||||
autoProvision: data.autoProvision,
|
autoProvision: data.autoProvision,
|
||||||
roleMapping: roleMappingExpression
|
roleMapping: roleMappingExpression,
|
||||||
|
orgMapping: orgMappingTrimmed === "" ? null : orgMappingTrimmed
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add variant-specific fields
|
// Add variant-specific fields
|
||||||
@@ -532,6 +539,10 @@ export default function GeneralPage() {
|
|||||||
}
|
}
|
||||||
rawExpression={rawRoleExpression}
|
rawExpression={rawRoleExpression}
|
||||||
onRawExpressionChange={setRawRoleExpression}
|
onRawExpressionChange={setRawRoleExpression}
|
||||||
|
orgMappingField={{
|
||||||
|
control: form.control,
|
||||||
|
name: "orgMapping"
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ import { authCookieHeader } from "@app/lib/api/cookies";
|
|||||||
import { HorizontalTabs, TabItem } from "@app/components/HorizontalTabs";
|
import { HorizontalTabs, TabItem } from "@app/components/HorizontalTabs";
|
||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Identity Provider"
|
||||||
|
};
|
||||||
|
|
||||||
interface SettingsLayoutProps {
|
interface SettingsLayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Identity Provider"
|
||||||
|
};
|
||||||
|
|
||||||
export default async function IdpPage(props: {
|
export default async function IdpPage(props: {
|
||||||
params: Promise<{ orgId: string; idpId: string }>;
|
params: Promise<{ orgId: string; idpId: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
10
src/app/[orgId]/settings/(private)/idp/create/layout.tsx
Normal file
10
src/app/[orgId]/settings/(private)/idp/create/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Create Identity Provider"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -91,7 +91,8 @@ export default function Page() {
|
|||||||
tenantId: z.string().optional(),
|
tenantId: z.string().optional(),
|
||||||
autoProvision: z.boolean().default(false),
|
autoProvision: z.boolean().default(false),
|
||||||
roleMapping: z.string().nullable().optional(),
|
roleMapping: z.string().nullable().optional(),
|
||||||
roleId: z.number().nullable().optional()
|
roleId: z.number().nullable().optional(),
|
||||||
|
orgMapping: z.string().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
type CreateIdpFormValues = z.infer<typeof createIdpFormSchema>;
|
type CreateIdpFormValues = z.infer<typeof createIdpFormSchema>;
|
||||||
@@ -112,7 +113,8 @@ export default function Page() {
|
|||||||
tenantId: "",
|
tenantId: "",
|
||||||
autoProvision: false,
|
autoProvision: false,
|
||||||
roleMapping: null,
|
roleMapping: null,
|
||||||
roleId: null
|
roleId: null,
|
||||||
|
orgMapping: ""
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -177,7 +179,7 @@ export default function Page() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = {
|
const payload: Record<string, unknown> = {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
clientId: data.clientId,
|
clientId: data.clientId,
|
||||||
clientSecret: data.clientSecret,
|
clientSecret: data.clientSecret,
|
||||||
@@ -191,6 +193,10 @@ export default function Page() {
|
|||||||
scopes: data.scopes,
|
scopes: data.scopes,
|
||||||
variant: data.type
|
variant: data.type
|
||||||
};
|
};
|
||||||
|
const trimmedOrgMapping = data.orgMapping?.trim();
|
||||||
|
if (trimmedOrgMapping) {
|
||||||
|
payload.orgMapping = trimmedOrgMapping;
|
||||||
|
}
|
||||||
|
|
||||||
// Use the appropriate endpoint based on provider type
|
// Use the appropriate endpoint based on provider type
|
||||||
const endpoint = "oidc";
|
const endpoint = "oidc";
|
||||||
@@ -336,6 +342,10 @@ export default function Page() {
|
|||||||
}
|
}
|
||||||
rawExpression={rawRoleExpression}
|
rawExpression={rawRoleExpression}
|
||||||
onRawExpressionChange={setRawRoleExpression}
|
onRawExpressionChange={setRawRoleExpression}
|
||||||
|
orgMappingField={{
|
||||||
|
control: form.control,
|
||||||
|
name: "orgMapping"
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ import { getTranslations } from "next-intl/server";
|
|||||||
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
||||||
import { IdpGlobalModeBanner } from "@app/components/IdpGlobalModeBanner";
|
import { IdpGlobalModeBanner } from "@app/components/IdpGlobalModeBanner";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Identity Providers"
|
||||||
|
};
|
||||||
|
|
||||||
type OrgIdpPageProps = {
|
type OrgIdpPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import { internal } from "@app/lib/api";
|
|||||||
import { authCookieHeader } from "@app/lib/api/cookies";
|
import { authCookieHeader } from "@app/lib/api/cookies";
|
||||||
import { ListGeneratedLicenseKeysResponse } from "@server/routers/generatedLicense/types";
|
import { ListGeneratedLicenseKeysResponse } from "@server/routers/generatedLicense/types";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Enterprise Licenses"
|
||||||
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Remote Exit Node"
|
||||||
|
};
|
||||||
|
|
||||||
export default async function RemoteExitNodePage(props: {
|
export default async function RemoteExitNodePage(props: {
|
||||||
params: Promise<{ orgId: string; remoteExitNodeId: string }>;
|
params: Promise<{ orgId: string; remoteExitNodeId: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Create Remote Exit Node"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -7,6 +7,11 @@ import ExitNodesTable, {
|
|||||||
} from "@app/components/ExitNodesTable";
|
} from "@app/components/ExitNodesTable";
|
||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Remote Exit Nodes"
|
||||||
|
};
|
||||||
|
|
||||||
type RemoteExitNodesPageProps = {
|
type RemoteExitNodesPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import UserProvider from "@app/providers/UserProvider";
|
|||||||
import { verifySession } from "@app/lib/auth/verifySession";
|
import { verifySession } from "@app/lib/auth/verifySession";
|
||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Invitations"
|
||||||
|
};
|
||||||
|
|
||||||
type InvitationsPageProps = {
|
type InvitationsPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Access"
|
||||||
|
};
|
||||||
|
|
||||||
type AccessPageProps = {
|
type AccessPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import RolesTable, { type RoleRow } from "@app/components/RolesTable";
|
|||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Roles"
|
||||||
|
};
|
||||||
|
|
||||||
type RolesPageProps = {
|
type RolesPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import { HorizontalTabs } from "@app/components/HorizontalTabs";
|
|||||||
import { cache } from "react";
|
import { cache } from "react";
|
||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "User"
|
||||||
|
};
|
||||||
|
|
||||||
interface UserLayoutProps {
|
interface UserLayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "User"
|
||||||
|
};
|
||||||
|
|
||||||
export default async function UserPage(props: {
|
export default async function UserPage(props: {
|
||||||
params: Promise<{ orgId: string; userId: string }>;
|
params: Promise<{ orgId: string; userId: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
10
src/app/[orgId]/settings/access/users/create/layout.tsx
Normal file
10
src/app/[orgId]/settings/access/users/create/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Create User"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -46,7 +46,7 @@ import { Checkbox } from "@app/components/ui/checkbox";
|
|||||||
import { ListIdpsResponse } from "@server/routers/idp";
|
import { ListIdpsResponse } from "@server/routers/idp";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import Image from "next/image";
|
import IdpTypeIcon from "@app/components/IdpTypeIcon";
|
||||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import OrgRolesTagField from "@app/components/OrgRolesTagField";
|
import OrgRolesTagField from "@app/components/OrgRolesTagField";
|
||||||
@@ -152,31 +152,8 @@ export default function Page() {
|
|||||||
|
|
||||||
const getIdpIcon = (variant: string | null) => {
|
const getIdpIcon = (variant: string | null) => {
|
||||||
if (!variant) return null;
|
if (!variant) return null;
|
||||||
|
const type = variant.toLowerCase();
|
||||||
switch (variant.toLowerCase()) {
|
return <IdpTypeIcon type={type} size={24} />;
|
||||||
case "google":
|
|
||||||
return (
|
|
||||||
<Image
|
|
||||||
src="/idp/google.png"
|
|
||||||
alt={t("idpGoogleAlt")}
|
|
||||||
width={24}
|
|
||||||
height={24}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
case "azure":
|
|
||||||
return (
|
|
||||||
<Image
|
|
||||||
src="/idp/azure.png"
|
|
||||||
alt={t("idpAzureAlt")}
|
|
||||||
width={24}
|
|
||||||
height={24}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const validFor = [
|
const validFor = [
|
||||||
@@ -340,15 +317,16 @@ export default function Page() {
|
|||||||
|
|
||||||
const roleIds = values.roles.map((r) => parseInt(r.id, 10));
|
const roleIds = values.roles.map((r) => parseInt(r.id, 10));
|
||||||
|
|
||||||
const res = await api.post<AxiosResponse<InviteUserResponse>>(
|
const res = await api
|
||||||
`/org/${orgId}/create-invite`,
|
.post<AxiosResponse<InviteUserResponse>>(
|
||||||
{
|
`/org/${orgId}/create-invite`,
|
||||||
email: values.email,
|
{
|
||||||
roleIds,
|
email: values.email,
|
||||||
validHours: parseInt(values.validForHours),
|
roleIds,
|
||||||
sendEmail
|
validHours: parseInt(values.validForHours),
|
||||||
}
|
sendEmail
|
||||||
)
|
}
|
||||||
|
)
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
if (e.response?.status === 409) {
|
if (e.response?.status === 409) {
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import UserProvider from "@app/providers/UserProvider";
|
|||||||
import { verifySession } from "@app/lib/auth/verifySession";
|
import { verifySession } from "@app/lib/auth/verifySession";
|
||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Users"
|
||||||
|
};
|
||||||
|
|
||||||
type UsersPageProps = {
|
type UsersPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ import { GetApiKeyResponse } from "@server/routers/apiKeys";
|
|||||||
import ApiKeyProvider from "@app/providers/ApiKeyProvider";
|
import ApiKeyProvider from "@app/providers/ApiKeyProvider";
|
||||||
import { HorizontalTabs } from "@app/components/HorizontalTabs";
|
import { HorizontalTabs } from "@app/components/HorizontalTabs";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "API Key"
|
||||||
|
};
|
||||||
|
|
||||||
interface SettingsLayoutProps {
|
interface SettingsLayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "API Key"
|
||||||
|
};
|
||||||
|
|
||||||
export default async function ApiKeysPage(props: {
|
export default async function ApiKeysPage(props: {
|
||||||
params: Promise<{ orgId: string; apiKeyId: string }>;
|
params: Promise<{ orgId: string; apiKeyId: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
10
src/app/[orgId]/settings/api-keys/create/layout.tsx
Normal file
10
src/app/[orgId]/settings/api-keys/create/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Create API Key"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -2,11 +2,14 @@ import { internal } from "@app/lib/api";
|
|||||||
import { authCookieHeader } from "@app/lib/api/cookies";
|
import { authCookieHeader } from "@app/lib/api/cookies";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import OrgApiKeysTable, {
|
import OrgApiKeysTable, { OrgApiKeyRow } from "@app/components/OrgApiKeysTable";
|
||||||
OrgApiKeyRow
|
|
||||||
} from "@app/components/OrgApiKeysTable";
|
|
||||||
import { ListOrgApiKeysResponse } from "@server/routers/apiKeys";
|
import { ListOrgApiKeysResponse } from "@server/routers/apiKeys";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "API Keys"
|
||||||
|
};
|
||||||
|
|
||||||
type ApiKeyPageProps = {
|
type ApiKeyPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type BluePrintsPageProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Blueprint Detail"
|
title: "Edit Blueprint"
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function BluePrintDetailPage(props: BluePrintsPageProps) {
|
export default async function BluePrintDetailPage(props: BluePrintsPageProps) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export interface CreateBlueprintPageProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Create blueprint"
|
title: "Create Blueprint"
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function CreateBlueprintPage(
|
export default async function CreateBlueprintPage(
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import { GetClientResponse } from "@server/routers/client";
|
|||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Machine Client"
|
||||||
|
};
|
||||||
|
|
||||||
type SettingsLayoutProps = {
|
type SettingsLayoutProps = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Machine Client"
|
||||||
|
};
|
||||||
|
|
||||||
export default async function ClientPage(props: {
|
export default async function ClientPage(props: {
|
||||||
params: Promise<{ orgId: string; niceId: number | string }>;
|
params: Promise<{ orgId: string; niceId: number | string }>;
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
10
src/app/[orgId]/settings/clients/machine/create/layout.tsx
Normal file
10
src/app/[orgId]/settings/clients/machine/create/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Create Machine Client"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -8,6 +8,11 @@ import { ListClientsResponse } from "@server/routers/client";
|
|||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import type { Pagination } from "@server/types/Pagination";
|
import type { Pagination } from "@server/types/Pagination";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Machine Clients"
|
||||||
|
};
|
||||||
|
|
||||||
type ClientsPageProps = {
|
type ClientsPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Clients"
|
||||||
|
};
|
||||||
|
|
||||||
type ClientsPageProps = {
|
type ClientsPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
searchParams: Promise<{ view?: string }>;
|
searchParams: Promise<{ view?: string }>;
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import { GetClientResponse } from "@server/routers/client";
|
|||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "User Device"
|
||||||
|
};
|
||||||
|
|
||||||
type SettingsLayoutProps = {
|
type SettingsLayoutProps = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "User Device"
|
||||||
|
};
|
||||||
|
|
||||||
export default async function ClientPage(props: {
|
export default async function ClientPage(props: {
|
||||||
params: Promise<{ orgId: string; niceId: number | string }>;
|
params: Promise<{ orgId: string; niceId: number | string }>;
|
||||||
}) {
|
}) {
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
redirect(
|
redirect(`/${params.orgId}/settings/clients/user/${params.niceId}/general`);
|
||||||
`/${params.orgId}/settings/clients/user/${params.niceId}/general`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ import { type ListUserDevicesResponse } from "@server/routers/client";
|
|||||||
import type { Pagination } from "@server/types/Pagination";
|
import type { Pagination } from "@server/types/Pagination";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "User Devices"
|
||||||
|
};
|
||||||
|
|
||||||
type ClientsPageProps = {
|
type ClientsPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import { GetDNSRecordsResponse } from "@server/routers/domain";
|
|||||||
import DNSRecordsTable from "@app/components/DNSRecordTable";
|
import DNSRecordsTable from "@app/components/DNSRecordTable";
|
||||||
import DomainCertForm from "@app/components/DomainCertForm";
|
import DomainCertForm from "@app/components/DomainCertForm";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Domain"
|
||||||
|
};
|
||||||
|
|
||||||
interface DomainSettingsPageProps {
|
interface DomainSettingsPageProps {
|
||||||
params: Promise<{ domainId: string; orgId: string }>;
|
params: Promise<{ domainId: string; orgId: string }>;
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import OrgProvider from "@app/providers/OrgProvider";
|
|||||||
import { ListDomainsResponse } from "@server/routers/domain";
|
import { ListDomainsResponse } from "@server/routers/domain";
|
||||||
import { toUnicode } from "punycode";
|
import { toUnicode } from "punycode";
|
||||||
import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Domains"
|
||||||
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
GetLoginPageResponse
|
GetLoginPageResponse
|
||||||
} from "@server/routers/loginPage/types";
|
} from "@server/routers/loginPage/types";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export interface AuthPageProps {
|
export interface AuthPageProps {
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import { getCachedOrg } from "@app/lib/api/getCachedOrg";
|
|||||||
import { getCachedOrgUser } from "@app/lib/api/getCachedOrgUser";
|
import { getCachedOrgUser } from "@app/lib/api/getCachedOrgUser";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { pullEnv } from "@app/lib/pullEnv";
|
import { pullEnv } from "@app/lib/pullEnv";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Organization"
|
||||||
|
};
|
||||||
|
|
||||||
type GeneralSettingsProps = {
|
type GeneralSettingsProps = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
10
src/app/[orgId]/settings/logs/access/layout.tsx
Normal file
10
src/app/[orgId]/settings/logs/access/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Access Logs"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
10
src/app/[orgId]/settings/logs/action/layout.tsx
Normal file
10
src/app/[orgId]/settings/logs/action/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Action Logs"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -2,6 +2,11 @@ import { LogAnalyticsData } from "@app/components/LogAnalyticsData";
|
|||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
import { Suspense } from "react";
|
import { Suspense } from "react";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Log Analytics"
|
||||||
|
};
|
||||||
|
|
||||||
export interface AnalyticsPageProps {
|
export interface AnalyticsPageProps {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
10
src/app/[orgId]/settings/logs/connection/layout.tsx
Normal file
10
src/app/[orgId]/settings/logs/connection/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Connection Logs"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Logs"
|
||||||
|
};
|
||||||
|
|
||||||
export default function GeneralPage() {
|
export default function GeneralPage() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/app/[orgId]/settings/logs/request/layout.tsx
Normal file
10
src/app/[orgId]/settings/logs/request/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Request Logs"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
10
src/app/[orgId]/settings/logs/streaming/layout.tsx
Normal file
10
src/app/[orgId]/settings/logs/streaming/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Streaming Logs"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Settings"
|
||||||
|
};
|
||||||
|
|
||||||
type OrgPageProps = {
|
type OrgPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ import DismissableBanner from "@app/components/DismissableBanner";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { ArrowRight, Plug } from "lucide-react";
|
import { ArrowRight, Plug } from "lucide-react";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Provisioning Keys"
|
||||||
|
};
|
||||||
|
|
||||||
type ProvisioningKeysPageProps = {
|
type ProvisioningKeysPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Provisioning"
|
||||||
|
};
|
||||||
|
|
||||||
type ProvisioningPageProps = {
|
type ProvisioningPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
};
|
};
|
||||||
@@ -7,4 +12,4 @@ type ProvisioningPageProps = {
|
|||||||
export default async function ProvisioningPage(props: ProvisioningPageProps) {
|
export default async function ProvisioningPage(props: ProvisioningPageProps) {
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
redirect(`/${params.orgId}/settings/provisioning/keys`);
|
redirect(`/${params.orgId}/settings/provisioning/keys`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ import { Button } from "@app/components/ui/button";
|
|||||||
import { ArrowRight, Plug } from "lucide-react";
|
import { ArrowRight, Plug } from "lucide-react";
|
||||||
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
|
||||||
import { TierFeature, tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { TierFeature, tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Pending Sites"
|
||||||
|
};
|
||||||
|
|
||||||
type PendingSitesPageProps = {
|
type PendingSitesPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -10,8 +10,13 @@ import type { ListResourcesResponse } from "@server/routers/resource";
|
|||||||
import type { ListAllSiteResourcesByOrgResponse } from "@server/routers/siteResource";
|
import type { ListAllSiteResourcesByOrgResponse } from "@server/routers/siteResource";
|
||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Private Resources"
|
||||||
|
};
|
||||||
|
|
||||||
export interface ClientResourcesPageProps {
|
export interface ClientResourcesPageProps {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
searchParams: Promise<Record<string, string>>;
|
searchParams: Promise<Record<string, string>>;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Public Resources"
|
||||||
|
};
|
||||||
|
|
||||||
export interface ResourcesPageProps {
|
export interface ResourcesPageProps {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ import OrgProvider from "@app/providers/OrgProvider";
|
|||||||
import { cache } from "react";
|
import { cache } from "react";
|
||||||
import ResourceInfoBox from "@app/components/ResourceInfoBox";
|
import ResourceInfoBox from "@app/components/ResourceInfoBox";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Public Resource"
|
||||||
|
};
|
||||||
|
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Proxy Resource"
|
||||||
|
};
|
||||||
|
|
||||||
export default async function ResourcePage(props: {
|
export default async function ResourcePage(props: {
|
||||||
params: Promise<{ niceId: string; orgId: string }>;
|
params: Promise<{ niceId: string; orgId: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
10
src/app/[orgId]/settings/resources/proxy/create/layout.tsx
Normal file
10
src/app/[orgId]/settings/resources/proxy/create/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Create Public Resource"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -13,6 +13,11 @@ import { getTranslations } from "next-intl/server";
|
|||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { toUnicode } from "punycode";
|
import { toUnicode } from "punycode";
|
||||||
import { cache } from "react";
|
import { cache } from "react";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Proxy Resources"
|
||||||
|
};
|
||||||
|
|
||||||
export interface ProxyResourcesPageProps {
|
export interface ProxyResourcesPageProps {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -7,10 +7,13 @@ import { cache } from "react";
|
|||||||
import { GetOrgResponse } from "@server/routers/org";
|
import { GetOrgResponse } from "@server/routers/org";
|
||||||
import OrgProvider from "@app/providers/OrgProvider";
|
import OrgProvider from "@app/providers/OrgProvider";
|
||||||
import { ListAccessTokensResponse } from "@server/routers/accessToken";
|
import { ListAccessTokensResponse } from "@server/routers/accessToken";
|
||||||
import ShareLinksTable, {
|
import ShareLinksTable, { ShareLinkRow } from "@app/components/ShareLinksTable";
|
||||||
ShareLinkRow
|
|
||||||
} from "@app/components/ShareLinksTable";
|
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Shareable Links"
|
||||||
|
};
|
||||||
|
|
||||||
type ShareLinksPageProps = {
|
type ShareLinksPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ import { HorizontalTabs } from "@app/components/HorizontalTabs";
|
|||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import SiteInfoCard from "@app/components/SiteInfoCard";
|
import SiteInfoCard from "@app/components/SiteInfoCard";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Site"
|
||||||
|
};
|
||||||
|
|
||||||
interface SettingsLayoutProps {
|
interface SettingsLayoutProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Site"
|
||||||
|
};
|
||||||
|
|
||||||
export default async function SitePage(props: {
|
export default async function SitePage(props: {
|
||||||
params: Promise<{ orgId: string; niceId: string }>;
|
params: Promise<{ orgId: string; niceId: string }>;
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
10
src/app/[orgId]/settings/sites/create/layout.tsx
Normal file
10
src/app/[orgId]/settings/sites/create/layout.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Create Site"
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Layout({ children }: { children: ReactNode }) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
@@ -161,16 +161,13 @@ export default function Page() {
|
|||||||
description: t("siteNewtTunnelDescription"),
|
description: t("siteNewtTunnelDescription"),
|
||||||
disabled: true
|
disabled: true
|
||||||
},
|
},
|
||||||
...(env.flags.disableBasicWireguardSites
|
...(env.flags.disableBasicWireguardSites || build == "saas"
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
id: "wireguard" as SiteType,
|
id: "wireguard" as SiteType,
|
||||||
title: t("siteWg"),
|
title: t("siteWg"),
|
||||||
description:
|
description: t("siteWgDescription"),
|
||||||
build == "saas"
|
|
||||||
? t("siteWgDescriptionSaas")
|
|
||||||
: t("siteWgDescription"),
|
|
||||||
disabled: true
|
disabled: true
|
||||||
}
|
}
|
||||||
]),
|
]),
|
||||||
@@ -426,9 +423,22 @@ export default function Page() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
setRemoteExitNodeOptions(exitNodeOptions);
|
setRemoteExitNodeOptions(exitNodeOptions);
|
||||||
|
|
||||||
|
if (exitNodeOptions.length === 0) {
|
||||||
|
// No remote exit nodes available — remove local option and default to newt
|
||||||
|
setTunnelTypes((prev: any) =>
|
||||||
|
prev.filter((item: any) => item.id !== "local")
|
||||||
|
);
|
||||||
|
form.setValue("method", "newt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch remote exit nodes:", error);
|
console.error("Failed to fetch remote exit nodes:", error);
|
||||||
|
// If fetch fails, no remote exit nodes available — remove local option and default to newt
|
||||||
|
setTunnelTypes((prev: any) =>
|
||||||
|
prev.filter((item: any) => item.id !== "local")
|
||||||
|
);
|
||||||
|
form.setValue("method", "newt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,13 @@ import { AxiosResponse } from "axios";
|
|||||||
import SitesTable, { SiteRow } from "@app/components/SitesTable";
|
import SitesTable, { SiteRow } from "@app/components/SitesTable";
|
||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import SitesBanner from "@app/components/SitesBanner";
|
import SitesBanner from "@app/components/SitesBanner";
|
||||||
|
import type { Metadata } from "next";
|
||||||
import { getTranslations } from "next-intl/server";
|
import { getTranslations } from "next-intl/server";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Sites"
|
||||||
|
};
|
||||||
|
|
||||||
type SitesPageProps = {
|
type SitesPageProps = {
|
||||||
params: Promise<{ orgId: string }>;
|
params: Promise<{ orgId: string }>;
|
||||||
searchParams: Promise<Record<string, string>>;
|
searchParams: Promise<Record<string, string>>;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
FormDescription,
|
|
||||||
FormField,
|
FormField,
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
@@ -63,7 +62,7 @@ import {
|
|||||||
SettingsSectionForm
|
SettingsSectionForm
|
||||||
} from "@app/components/Settings";
|
} from "@app/components/Settings";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import RoleMappingConfigFields from "@app/components/RoleMappingConfigFields";
|
import AutoProvisionConfigWidget from "@app/components/AutoProvisionConfigWidget";
|
||||||
import {
|
import {
|
||||||
compileRoleMappingExpression,
|
compileRoleMappingExpression,
|
||||||
createMappingBuilderRule,
|
createMappingBuilderRule,
|
||||||
@@ -499,9 +498,17 @@ export default function PoliciesPage() {
|
|||||||
id="policy-default-mappings-form"
|
id="policy-default-mappings-form"
|
||||||
className="space-y-6"
|
className="space-y-6"
|
||||||
>
|
>
|
||||||
<RoleMappingConfigFields
|
<AutoProvisionConfigWidget
|
||||||
fieldIdPrefix="admin-idp-default-role"
|
showAutoProvisionSwitch={false}
|
||||||
showFreeformRoleNamesHint={true}
|
autoProvision={true}
|
||||||
|
onAutoProvisionChange={() => {}}
|
||||||
|
orgMappingField={{
|
||||||
|
control: defaultMappingsForm.control,
|
||||||
|
name: "defaultOrgMapping",
|
||||||
|
labelKey: "defaultMappingsOrg"
|
||||||
|
}}
|
||||||
|
roleMappingFieldIdPrefix="admin-idp-default-role"
|
||||||
|
showFreeformRoleNamesHint
|
||||||
roleMappingMode={defaultRoleMappingMode}
|
roleMappingMode={defaultRoleMappingMode}
|
||||||
onRoleMappingModeChange={
|
onRoleMappingModeChange={
|
||||||
setDefaultRoleMappingMode
|
setDefaultRoleMappingMode
|
||||||
@@ -528,27 +535,6 @@ export default function PoliciesPage() {
|
|||||||
setDefaultRawRoleExpression
|
setDefaultRawRoleExpression
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={defaultMappingsForm.control}
|
|
||||||
name="defaultOrgMapping"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>
|
|
||||||
{t("defaultMappingsOrg")}
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormDescription>
|
|
||||||
{t(
|
|
||||||
"defaultMappingsOrgDescription"
|
|
||||||
)}
|
|
||||||
</FormDescription>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
<SettingsSectionFooter>
|
<SettingsSectionFooter>
|
||||||
@@ -687,9 +673,15 @@ export default function PoliciesPage() {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<RoleMappingConfigFields
|
<AutoProvisionConfigWidget
|
||||||
fieldIdPrefix="admin-idp-policy-role"
|
showAutoProvisionSwitch={false}
|
||||||
showFreeformRoleNamesHint={false}
|
autoProvision={true}
|
||||||
|
onAutoProvisionChange={() => {}}
|
||||||
|
orgMappingField={{
|
||||||
|
control: form.control,
|
||||||
|
name: "orgMapping"
|
||||||
|
}}
|
||||||
|
roleMappingFieldIdPrefix="admin-idp-policy-role"
|
||||||
roleMappingMode={policyRoleMappingMode}
|
roleMappingMode={policyRoleMappingMode}
|
||||||
onRoleMappingModeChange={
|
onRoleMappingModeChange={
|
||||||
setPolicyRoleMappingMode
|
setPolicyRoleMappingMode
|
||||||
@@ -716,27 +708,6 @@ export default function PoliciesPage() {
|
|||||||
setPolicyRawRoleExpression
|
setPolicyRawRoleExpression
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="orgMapping"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>
|
|
||||||
{t("orgMappingPathOptional")}
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormDescription>
|
|
||||||
{t(
|
|
||||||
"defaultMappingsOrgDescription"
|
|
||||||
)}
|
|
||||||
</FormDescription>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</CredenzaBody>
|
</CredenzaBody>
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import {
|
|||||||
import HeaderTitle from "@app/components/SettingsSectionTitle";
|
import HeaderTitle from "@app/components/SettingsSectionTitle";
|
||||||
import IdpAutoProvisionUsersDescription from "@app/components/IdpAutoProvisionUsersDescription";
|
import IdpAutoProvisionUsersDescription from "@app/components/IdpAutoProvisionUsersDescription";
|
||||||
import { SwitchInput } from "@app/components/SwitchInput";
|
import { SwitchInput } from "@app/components/SwitchInput";
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
|
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { Input } from "@app/components/ui/input";
|
import { Input } from "@app/components/ui/input";
|
||||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
@@ -34,7 +33,6 @@ import { createApiClient, formatAxiosError } from "@app/lib/api";
|
|||||||
import { applyOidcIdpProviderType } from "@app/lib/idp/oidcIdpProviderDefaults";
|
import { applyOidcIdpProviderType } from "@app/lib/idp/oidcIdpProviderDefaults";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import { InfoIcon } from "lucide-react";
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -220,23 +218,6 @@ export default function Page() {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="flex items-start mb-0">
|
|
||||||
<SwitchInput
|
|
||||||
id="auto-provision-toggle"
|
|
||||||
label={t(
|
|
||||||
"idpAutoProvisionUsers"
|
|
||||||
)}
|
|
||||||
defaultChecked={form.getValues(
|
|
||||||
"autoProvision"
|
|
||||||
)}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
form.setValue(
|
|
||||||
"autoProvision",
|
|
||||||
checked
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</SettingsSectionForm>
|
</SettingsSectionForm>
|
||||||
@@ -244,6 +225,32 @@ export default function Page() {
|
|||||||
</SettingsSectionBody>
|
</SettingsSectionBody>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|
||||||
|
<SettingsSection>
|
||||||
|
<SettingsSectionHeader>
|
||||||
|
<SettingsSectionTitle>
|
||||||
|
{t("idpAutoProvisionUsers")}
|
||||||
|
</SettingsSectionTitle>
|
||||||
|
<SettingsSectionDescription>
|
||||||
|
<IdpAutoProvisionUsersDescription />
|
||||||
|
</SettingsSectionDescription>
|
||||||
|
</SettingsSectionHeader>
|
||||||
|
<SettingsSectionBody>
|
||||||
|
<div className="space-y-2">
|
||||||
|
<SwitchInput
|
||||||
|
id="auto-provision-toggle"
|
||||||
|
label={t("idpAutoProvisionUsers")}
|
||||||
|
defaultChecked={form.getValues("autoProvision")}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
form.setValue("autoProvision", checked);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t("idpAutoProvisionConfigureAfterCreate")}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</SettingsSectionBody>
|
||||||
|
</SettingsSection>
|
||||||
|
|
||||||
<fieldset
|
<fieldset
|
||||||
disabled={templatesLocked}
|
disabled={templatesLocked}
|
||||||
className="min-w-0 border-0 p-0 m-0 disabled:pointer-events-none disabled:opacity-60"
|
className="min-w-0 border-0 p-0 m-0 disabled:pointer-events-none disabled:opacity-60"
|
||||||
|
|||||||
@@ -352,20 +352,6 @@ export default function LicensePage() {
|
|||||||
}
|
}
|
||||||
description={t("licenseBannerDescription")}
|
description={t("licenseBannerDescription")}
|
||||||
>
|
>
|
||||||
<Link
|
|
||||||
href={ENTERPRISE_PRICING_URL}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="default"
|
|
||||||
size="sm"
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
{t("licenseBannerGetLicense")}
|
|
||||||
<ArrowRight className="w-4 h-4" />
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
<Link
|
<Link
|
||||||
href={ENTERPRISE_DOCS_URL}
|
href={ENTERPRISE_DOCS_URL}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -380,6 +366,20 @@ export default function LicensePage() {
|
|||||||
<ExternalLink className="w-4 h-4" />
|
<ExternalLink className="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link
|
||||||
|
href={ENTERPRISE_PRICING_URL}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="gap-2 hover:bg-primary/10 hover:border-primary/50 transition-colors"
|
||||||
|
>
|
||||||
|
{t("licenseBannerGetLicense")}
|
||||||
|
<ArrowRight className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
</DismissableBanner>
|
</DismissableBanner>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,33 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import IdpAutoProvisionUsersDescription from "@app/components/IdpAutoProvisionUsersDescription";
|
import { HorizontalTabs } from "@app/components/HorizontalTabs";
|
||||||
import { FormDescription } from "@app/components/ui/form";
|
import RoleMappingConfigFields from "@app/components/RoleMappingConfigFields";
|
||||||
import { SwitchInput } from "@app/components/SwitchInput";
|
import { SwitchInput } from "@app/components/SwitchInput";
|
||||||
import { useTranslations } from "next-intl";
|
import {
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage
|
||||||
|
} from "@app/components/ui/form";
|
||||||
|
import { Input } from "@app/components/ui/input";
|
||||||
|
import { MappingBuilderRule, RoleMappingMode } from "@app/lib/idpRoleMapping";
|
||||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import { MappingBuilderRule, RoleMappingMode } from "@app/lib/idpRoleMapping";
|
import { useTranslations } from "next-intl";
|
||||||
import RoleMappingConfigFields from "@app/components/RoleMappingConfigFields";
|
import type { Control } from "react-hook-form";
|
||||||
|
|
||||||
type Role = {
|
type Role = {
|
||||||
roleId: number;
|
roleId: number;
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type IdpOrgMappingFieldBinding = {
|
||||||
|
control: unknown;
|
||||||
|
name: string;
|
||||||
|
labelKey?: string;
|
||||||
|
};
|
||||||
|
|
||||||
type AutoProvisionConfigWidgetProps = {
|
type AutoProvisionConfigWidgetProps = {
|
||||||
autoProvision: boolean;
|
autoProvision: boolean;
|
||||||
onAutoProvisionChange: (checked: boolean) => void;
|
onAutoProvisionChange: (checked: boolean) => void;
|
||||||
@@ -28,6 +42,11 @@ type AutoProvisionConfigWidgetProps = {
|
|||||||
onMappingBuilderRulesChange: (rules: MappingBuilderRule[]) => void;
|
onMappingBuilderRulesChange: (rules: MappingBuilderRule[]) => void;
|
||||||
rawExpression: string;
|
rawExpression: string;
|
||||||
onRawExpressionChange: (expression: string) => void;
|
onRawExpressionChange: (expression: string) => void;
|
||||||
|
orgMappingField: IdpOrgMappingFieldBinding;
|
||||||
|
showAutoProvisionSwitch?: boolean;
|
||||||
|
roleMappingFieldIdPrefix?: string;
|
||||||
|
showFreeformRoleNamesHint?: boolean;
|
||||||
|
autoProvisionSwitchId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function AutoProvisionConfigWidget({
|
export default function AutoProvisionConfigWidget({
|
||||||
@@ -43,41 +62,95 @@ export default function AutoProvisionConfigWidget({
|
|||||||
mappingBuilderRules,
|
mappingBuilderRules,
|
||||||
onMappingBuilderRulesChange,
|
onMappingBuilderRulesChange,
|
||||||
rawExpression,
|
rawExpression,
|
||||||
onRawExpressionChange
|
onRawExpressionChange,
|
||||||
|
orgMappingField,
|
||||||
|
showAutoProvisionSwitch = true,
|
||||||
|
roleMappingFieldIdPrefix = "org-idp-auto-provision",
|
||||||
|
showFreeformRoleNamesHint = false,
|
||||||
|
autoProvisionSwitchId = "auto-provision-toggle"
|
||||||
}: AutoProvisionConfigWidgetProps) {
|
}: AutoProvisionConfigWidgetProps) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const { isPaidUser } = usePaidStatus();
|
const { isPaidUser } = usePaidStatus();
|
||||||
|
|
||||||
|
const showMappingTabs = showAutoProvisionSwitch === false || autoProvision;
|
||||||
|
|
||||||
|
const orgMappingLabelKey =
|
||||||
|
orgMappingField.labelKey ?? "orgMappingPathOptional";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="mb-4">
|
{showAutoProvisionSwitch && (
|
||||||
<SwitchInput
|
<div className="mb-4">
|
||||||
id="auto-provision-toggle"
|
<SwitchInput
|
||||||
label={t("idpAutoProvisionUsers")}
|
id={autoProvisionSwitchId}
|
||||||
defaultChecked={autoProvision}
|
label={t("idpAutoProvisionUsers")}
|
||||||
onCheckedChange={onAutoProvisionChange}
|
defaultChecked={autoProvision}
|
||||||
disabled={!isPaidUser(tierMatrix.autoProvisioning)}
|
onCheckedChange={onAutoProvisionChange}
|
||||||
/>
|
disabled={!isPaidUser(tierMatrix.autoProvisioning)}
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{autoProvision && (
|
{showMappingTabs && (
|
||||||
<RoleMappingConfigFields
|
<HorizontalTabs
|
||||||
fieldIdPrefix="org-idp-auto-provision"
|
clientSide
|
||||||
showFreeformRoleNamesHint={false}
|
defaultTab={0}
|
||||||
roleMappingMode={roleMappingMode}
|
items={[
|
||||||
onRoleMappingModeChange={onRoleMappingModeChange}
|
{ title: t("roleMapping"), href: "#" },
|
||||||
roles={roles}
|
{ title: t("orgMapping"), href: "#" }
|
||||||
fixedRoleNames={fixedRoleNames}
|
]}
|
||||||
onFixedRoleNamesChange={onFixedRoleNamesChange}
|
>
|
||||||
mappingBuilderClaimPath={mappingBuilderClaimPath}
|
<div className="space-y-4 mt-4 p-1">
|
||||||
onMappingBuilderClaimPathChange={
|
<RoleMappingConfigFields
|
||||||
onMappingBuilderClaimPathChange
|
fieldIdPrefix={roleMappingFieldIdPrefix}
|
||||||
}
|
showFreeformRoleNamesHint={
|
||||||
mappingBuilderRules={mappingBuilderRules}
|
showFreeformRoleNamesHint
|
||||||
onMappingBuilderRulesChange={onMappingBuilderRulesChange}
|
}
|
||||||
rawExpression={rawExpression}
|
roleMappingMode={roleMappingMode}
|
||||||
onRawExpressionChange={onRawExpressionChange}
|
onRoleMappingModeChange={onRoleMappingModeChange}
|
||||||
/>
|
roles={roles}
|
||||||
|
fixedRoleNames={fixedRoleNames}
|
||||||
|
onFixedRoleNamesChange={onFixedRoleNamesChange}
|
||||||
|
mappingBuilderClaimPath={mappingBuilderClaimPath}
|
||||||
|
onMappingBuilderClaimPathChange={
|
||||||
|
onMappingBuilderClaimPathChange
|
||||||
|
}
|
||||||
|
mappingBuilderRules={mappingBuilderRules}
|
||||||
|
onMappingBuilderRulesChange={
|
||||||
|
onMappingBuilderRulesChange
|
||||||
|
}
|
||||||
|
rawExpression={rawExpression}
|
||||||
|
onRawExpressionChange={onRawExpressionChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-4 mt-4 p-1">
|
||||||
|
<div className="space-y-4">
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t("defaultMappingsOrgDescription")}
|
||||||
|
</p>
|
||||||
|
<FormField
|
||||||
|
control={
|
||||||
|
orgMappingField.control as Control<any>
|
||||||
|
}
|
||||||
|
name={orgMappingField.name}
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>
|
||||||
|
{t(orgMappingLabelKey)}
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
placeholder="e.g., ends_with(email, '@organization.com')"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</HorizontalTabs>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { Alert, AlertDescription } from "@app/components/ui/alert";
|
import { Alert, AlertDescription } from "@app/components/ui/alert";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import Image from "next/image";
|
import IdpTypeIcon from "@app/components/IdpTypeIcon";
|
||||||
import {
|
import {
|
||||||
generateOidcUrlProxy,
|
generateOidcUrlProxy,
|
||||||
type GenerateOidcUrlResponse
|
type GenerateOidcUrlResponse
|
||||||
@@ -135,24 +135,7 @@ export default function IdpLoginButtons({
|
|||||||
disabled={loading}
|
disabled={loading}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
>
|
>
|
||||||
{effectiveType === "google" && (
|
<IdpTypeIcon type={effectiveType} size={16} />
|
||||||
<Image
|
|
||||||
src="/idp/google.png"
|
|
||||||
alt="Google"
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{effectiveType === "azure" && (
|
|
||||||
<Image
|
|
||||||
src="/idp/azure.png"
|
|
||||||
alt="Azure"
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<span>{idp.name}</span>
|
<span>{idp.name}</span>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Badge } from "@app/components/ui/badge";
|
import { Badge } from "@app/components/ui/badge";
|
||||||
import Image from "next/image";
|
import IdpTypeIcon from "@app/components/IdpTypeIcon";
|
||||||
|
|
||||||
type IdpTypeBadgeProps = {
|
type IdpTypeBadgeProps = {
|
||||||
type: string;
|
type: string;
|
||||||
@@ -29,34 +29,8 @@ export default function IdpTypeBadge({
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
className="inline-flex items-center space-x-1 w-fit"
|
className="inline-flex items-center space-x-1 w-fit"
|
||||||
>
|
>
|
||||||
{effectiveType === "google" && (
|
<IdpTypeIcon type={effectiveType} size={16} />
|
||||||
<>
|
<span>{effectiveName}</span>
|
||||||
<Image
|
|
||||||
src="/idp/google.png"
|
|
||||||
alt="Google"
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
<span>{effectiveName}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{effectiveType === "azure" && (
|
|
||||||
<>
|
|
||||||
<Image
|
|
||||||
src="/idp/azure.png"
|
|
||||||
alt="Azure"
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
<span>{effectiveName}</span>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{effectiveType === "oidc" && <span>{effectiveName}</span>}
|
|
||||||
{!["google", "azure", "oidc"].includes(effectiveType) && (
|
|
||||||
<span>{effectiveName}</span>
|
|
||||||
)}
|
|
||||||
</Badge>
|
</Badge>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
53
src/components/IdpTypeIcon.tsx
Normal file
53
src/components/IdpTypeIcon.tsx
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { cn } from "@app/lib/cn";
|
||||||
|
import Image from "next/image";
|
||||||
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
type?: string | null;
|
||||||
|
variant?: string | null;
|
||||||
|
size?: number;
|
||||||
|
className?: string;
|
||||||
|
alt?: string;
|
||||||
|
fallback?: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function IdpTypeIcon({
|
||||||
|
type,
|
||||||
|
variant,
|
||||||
|
size = 16,
|
||||||
|
className,
|
||||||
|
alt,
|
||||||
|
fallback = null
|
||||||
|
}: Props) {
|
||||||
|
const effectiveType = (variant || type || "").toLowerCase();
|
||||||
|
|
||||||
|
let src: string | null = null;
|
||||||
|
let defaultAlt = "";
|
||||||
|
|
||||||
|
if (effectiveType === "google") {
|
||||||
|
src = "/idp/google.png";
|
||||||
|
defaultAlt = "Google";
|
||||||
|
} else if (effectiveType === "azure") {
|
||||||
|
src = "/idp/azure.png";
|
||||||
|
defaultAlt = "Azure";
|
||||||
|
} else if (effectiveType === "oidc") {
|
||||||
|
src = "/idp/openid.png";
|
||||||
|
defaultAlt = "OAuth2/OIDC";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!src) {
|
||||||
|
return <>{fallback}</>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Image
|
||||||
|
src={src}
|
||||||
|
alt={alt ?? defaultAlt}
|
||||||
|
width={size}
|
||||||
|
height={size}
|
||||||
|
className={cn("shrink-0 rounded", className)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -24,10 +24,8 @@ import dynamic from "next/dynamic";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { FaGithub } from "react-icons/fa";
|
|
||||||
import SidebarLicenseButton from "./SidebarLicenseButton";
|
import SidebarLicenseButton from "./SidebarLicenseButton";
|
||||||
import { SidebarSupportButton } from "./SidebarSupportButton";
|
import { SidebarSupportButton } from "./SidebarSupportButton";
|
||||||
import { is } from "drizzle-orm";
|
|
||||||
|
|
||||||
const ProductUpdates = dynamic(() => import("./ProductUpdates"), {
|
const ProductUpdates = dynamic(() => import("./ProductUpdates"), {
|
||||||
ssr: false
|
ssr: false
|
||||||
@@ -223,11 +221,11 @@ export function LayoutSidebar({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="pt-1 flex flex-col shrink-0 gap-2 w-full border-t border-border">
|
<div className="pt-1 flex flex-col shrink-0 gap-2 w-full border-t border-border">
|
||||||
{canShowProductUpdates && (
|
{canShowProductUpdates ? (
|
||||||
<div className="px-4">
|
<div className="px-4">
|
||||||
<ProductUpdates isCollapsed={isSidebarCollapsed} />
|
<ProductUpdates isCollapsed={isSidebarCollapsed} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
) : <div className="mt-0.2"></div>}
|
||||||
|
|
||||||
{build === "enterprise" && (
|
{build === "enterprise" && (
|
||||||
<div className="px-4">
|
<div className="px-4">
|
||||||
@@ -291,7 +289,6 @@ export function LayoutSidebar({
|
|||||||
: build === "enterprise"
|
: build === "enterprise"
|
||||||
? t("enterpriseEdition")
|
? t("enterpriseEdition")
|
||||||
: "Pangolin Cloud"}
|
: "Pangolin Cloud"}
|
||||||
<FaGithub size={12} />
|
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
{build === "enterprise" &&
|
{build === "enterprise" &&
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import { LockIcon } from "lucide-react";
|
|||||||
import SecurityKeyAuthButton from "@app/components/SecurityKeyAuthButton";
|
import SecurityKeyAuthButton from "@app/components/SecurityKeyAuthButton";
|
||||||
import { createApiClient } from "@app/lib/api";
|
import { createApiClient } from "@app/lib/api";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Image from "next/image";
|
|
||||||
import { GenerateOidcUrlResponse } from "@server/routers/idp";
|
import { GenerateOidcUrlResponse } from "@server/routers/idp";
|
||||||
import { Separator } from "./ui/separator";
|
import { Separator } from "./ui/separator";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
@@ -37,6 +36,7 @@ import {
|
|||||||
} from "@app/actions/server";
|
} from "@app/actions/server";
|
||||||
import { redirect as redirectTo } from "next/navigation";
|
import { redirect as redirectTo } from "next/navigation";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
|
import IdpTypeIcon from "@app/components/IdpTypeIcon";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { loadReoScript } from "reodotdev";
|
import { loadReoScript } from "reodotdev";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
@@ -393,24 +393,7 @@ export default function LoginForm({
|
|||||||
loginWithIdp(idp.idpId);
|
loginWithIdp(idp.idpId);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{effectiveType === "google" && (
|
<IdpTypeIcon type={effectiveType} size={16} />
|
||||||
<Image
|
|
||||||
src="/idp/google.png"
|
|
||||||
alt="Google"
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{effectiveType === "azure" && (
|
|
||||||
<Image
|
|
||||||
src="/idp/azure.png"
|
|
||||||
alt="Azure"
|
|
||||||
width={16}
|
|
||||||
height={16}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<span>{idp.name}</span>
|
<span>{idp.name}</span>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { ColumnDef } from "@tanstack/react-table";
|
||||||
import { DataTable } from "@app/components/ui/data-table";
|
import {
|
||||||
|
DataTable,
|
||||||
|
type DataTableAddAction
|
||||||
|
} from "@app/components/ui/data-table";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
interface DataTableProps<TData, TValue> {
|
interface DataTableProps<TData, TValue> {
|
||||||
columns: ColumnDef<TData, TValue>[];
|
columns: ColumnDef<TData, TValue>[];
|
||||||
data: TData[];
|
data: TData[];
|
||||||
onAdd?: () => void;
|
onAdd?: () => void;
|
||||||
|
addActions?: DataTableAddAction[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function IdpDataTable<TData, TValue>({
|
export function IdpDataTable<TData, TValue>({
|
||||||
columns,
|
columns,
|
||||||
data,
|
data,
|
||||||
onAdd
|
onAdd,
|
||||||
|
addActions
|
||||||
}: DataTableProps<TData, TValue>) {
|
}: DataTableProps<TData, TValue>) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
|
||||||
@@ -27,6 +32,7 @@ export function IdpDataTable<TData, TValue>({
|
|||||||
searchColumn="name"
|
searchColumn="name"
|
||||||
addButtonText={t("idpAdd")}
|
addButtonText={t("idpAdd")}
|
||||||
onAdd={onAdd}
|
onAdd={onAdd}
|
||||||
|
addActions={addActions}
|
||||||
enableColumnVisibility={true}
|
enableColumnVisibility={true}
|
||||||
stickyRightColumn="actions"
|
stickyRightColumn="actions"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -4,13 +4,37 @@ import { ColumnDef } from "@tanstack/react-table";
|
|||||||
import { ExtendedColumnDef } from "@app/components/ui/data-table";
|
import { ExtendedColumnDef } from "@app/components/ui/data-table";
|
||||||
import { IdpDataTable } from "@app/components/OrgIdpDataTable";
|
import { IdpDataTable } from "@app/components/OrgIdpDataTable";
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { ArrowRight, ArrowUpDown, MoreHorizontal } from "lucide-react";
|
import {
|
||||||
import { useState } from "react";
|
Command,
|
||||||
|
CommandEmpty,
|
||||||
|
CommandGroup,
|
||||||
|
CommandInput,
|
||||||
|
CommandItem,
|
||||||
|
CommandList
|
||||||
|
} from "@app/components/ui/command";
|
||||||
|
import {
|
||||||
|
Credenza,
|
||||||
|
CredenzaBody,
|
||||||
|
CredenzaClose,
|
||||||
|
CredenzaContent,
|
||||||
|
CredenzaDescription,
|
||||||
|
CredenzaFooter,
|
||||||
|
CredenzaHeader,
|
||||||
|
CredenzaTitle
|
||||||
|
} from "@app/components/Credenza";
|
||||||
|
import {
|
||||||
|
ArrowRight,
|
||||||
|
ArrowUpDown,
|
||||||
|
KeyRound,
|
||||||
|
MoreHorizontal
|
||||||
|
} from "lucide-react";
|
||||||
|
import { useMemo, useState } from "react";
|
||||||
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
||||||
import { toast } from "@app/hooks/useToast";
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { formatAxiosError } from "@app/lib/api";
|
import { formatAxiosError } from "@app/lib/api";
|
||||||
import { createApiClient } from "@app/lib/api";
|
import { createApiClient } from "@app/lib/api";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
|
import { useUserContext } from "@app/hooks/useUserContext";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@@ -21,6 +45,13 @@ import {
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import IdpTypeBadge from "@app/components/IdpTypeBadge";
|
import IdpTypeBadge from "@app/components/IdpTypeBadge";
|
||||||
|
import IdpTypeIcon from "@app/components/IdpTypeIcon";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useDebounce } from "use-debounce";
|
||||||
|
import type { ListUserAdminOrgIdpsResponse } from "@server/routers/orgIdp/types";
|
||||||
|
import { cn } from "@app/lib/cn";
|
||||||
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
|
|
||||||
export type IdpRow = {
|
export type IdpRow = {
|
||||||
idpId: number;
|
idpId: number;
|
||||||
@@ -29,6 +60,15 @@ export type IdpRow = {
|
|||||||
variant?: string;
|
variant?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type AdminIdpRow = ListUserAdminOrgIdpsResponse["idps"][number];
|
||||||
|
|
||||||
|
function IdpImportRowIcon({
|
||||||
|
type,
|
||||||
|
variant
|
||||||
|
}: Pick<AdminIdpRow, "type" | "variant">) {
|
||||||
|
return <IdpTypeIcon type={type} variant={variant} size={20} />;
|
||||||
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
idps: IdpRow[];
|
idps: IdpRow[];
|
||||||
orgId: string;
|
orgId: string;
|
||||||
@@ -37,10 +77,51 @@ type Props = {
|
|||||||
export default function IdpTable({ idps, orgId }: Props) {
|
export default function IdpTable({ idps, orgId }: Props) {
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||||
const [selectedIdp, setSelectedIdp] = useState<IdpRow | null>(null);
|
const [selectedIdp, setSelectedIdp] = useState<IdpRow | null>(null);
|
||||||
|
const [isUnassociateModalOpen, setIsUnassociateModalOpen] = useState(false);
|
||||||
|
const [selectedUnassociateIdp, setSelectedUnassociateIdp] =
|
||||||
|
useState<IdpRow | null>(null);
|
||||||
|
const [importDialogOpen, setImportDialogOpen] = useState(false);
|
||||||
|
const [importSearchQuery, setImportSearchQuery] = useState("");
|
||||||
|
const [importSubmitting, setImportSubmitting] = useState(false);
|
||||||
|
const [debouncedImportSearch] = useDebounce(importSearchQuery, 150);
|
||||||
|
|
||||||
const api = createApiClient(useEnvContext());
|
const api = createApiClient(useEnvContext());
|
||||||
|
const { user } = useUserContext();
|
||||||
|
const { isPaidUser } = usePaidStatus();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
|
||||||
|
const canImportOrgOidcIdp = isPaidUser(tierMatrix.orgOidc);
|
||||||
|
|
||||||
|
const { data: adminIdpsRaw = [] } = useQuery({
|
||||||
|
queryKey: ["admin-org-idps", user.userId],
|
||||||
|
queryFn: async () => {
|
||||||
|
const res = await api.get<{
|
||||||
|
data: ListUserAdminOrgIdpsResponse;
|
||||||
|
}>(`/user/${user.userId}/admin-org-idps`);
|
||||||
|
return res.data.data.idps;
|
||||||
|
},
|
||||||
|
enabled: importDialogOpen && !!user?.userId
|
||||||
|
});
|
||||||
|
|
||||||
|
const importableIdps = useMemo(() => {
|
||||||
|
const localIds = new Set(idps.map((i) => i.idpId));
|
||||||
|
return adminIdpsRaw.filter(
|
||||||
|
(row) => row.orgId !== orgId && !localIds.has(row.idpId)
|
||||||
|
);
|
||||||
|
}, [adminIdpsRaw, orgId, idps]);
|
||||||
|
|
||||||
|
const shownImportIdps = useMemo(() => {
|
||||||
|
const q = debouncedImportSearch.trim().toLowerCase();
|
||||||
|
if (!q) {
|
||||||
|
return importableIdps;
|
||||||
|
}
|
||||||
|
return importableIdps.filter((row) => {
|
||||||
|
const hay = `${row.orgName} ${row.name}`.toLowerCase();
|
||||||
|
return hay.includes(q);
|
||||||
|
});
|
||||||
|
}, [importableIdps, debouncedImportSearch]);
|
||||||
|
|
||||||
const deleteIdp = async (idpId: number) => {
|
const deleteIdp = async (idpId: number) => {
|
||||||
try {
|
try {
|
||||||
await api.delete(`/org/${orgId}/idp/${idpId}`);
|
await api.delete(`/org/${orgId}/idp/${idpId}`);
|
||||||
@@ -59,6 +140,49 @@ export default function IdpTable({ idps, orgId }: Props) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const importIdp = async (row: AdminIdpRow) => {
|
||||||
|
setImportSubmitting(true);
|
||||||
|
try {
|
||||||
|
await api.post(`/org/${orgId}/idp/${row.idpId}/import`, {
|
||||||
|
sourceOrgId: row.orgId
|
||||||
|
});
|
||||||
|
toast({
|
||||||
|
title: t("success"),
|
||||||
|
description: t("idpImportedDescription")
|
||||||
|
});
|
||||||
|
setImportDialogOpen(false);
|
||||||
|
setImportSearchQuery("");
|
||||||
|
router.refresh();
|
||||||
|
router.push(`/${orgId}/settings/idp/${row.idpId}/general`);
|
||||||
|
} catch (e) {
|
||||||
|
toast({
|
||||||
|
title: t("error"),
|
||||||
|
description: formatAxiosError(e),
|
||||||
|
variant: "destructive"
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setImportSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const unassociateIdp = async (idpId: number) => {
|
||||||
|
try {
|
||||||
|
await api.delete(`/org/${orgId}/idp/${idpId}/association`);
|
||||||
|
toast({
|
||||||
|
title: t("success"),
|
||||||
|
description: t("idpUnassociatedDescription")
|
||||||
|
});
|
||||||
|
setIsUnassociateModalOpen(false);
|
||||||
|
router.refresh();
|
||||||
|
} catch (e) {
|
||||||
|
toast({
|
||||||
|
title: t("error"),
|
||||||
|
description: formatAxiosError(e),
|
||||||
|
variant: "destructive"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const columns: ExtendedColumnDef<IdpRow>[] = [
|
const columns: ExtendedColumnDef<IdpRow>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: "idpId",
|
accessorKey: "idpId",
|
||||||
@@ -142,6 +266,14 @@ export default function IdpTable({ idps, orgId }: Props) {
|
|||||||
{t("viewSettings")}
|
{t("viewSettings")}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</Link>
|
</Link>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedUnassociateIdp(siteRow);
|
||||||
|
setIsUnassociateModalOpen(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("idpUnassociateMenu")}
|
||||||
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSelectedIdp(siteRow);
|
setSelectedIdp(siteRow);
|
||||||
@@ -149,7 +281,7 @@ export default function IdpTable({ idps, orgId }: Props) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className="text-red-500">
|
<span className="text-red-500">
|
||||||
{t("delete")}
|
{t("idpDeleteAllOrgsMenu")}
|
||||||
</span>
|
</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
@@ -179,8 +311,8 @@ export default function IdpTable({ idps, orgId }: Props) {
|
|||||||
}}
|
}}
|
||||||
dialog={
|
dialog={
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<p>{t("idpQuestionRemove")}</p>
|
<p>{t("idpDeleteGlobalQuestion")}</p>
|
||||||
<p>{t("idpMessageRemove")}</p>
|
<p>{t("idpDeleteGlobalDescription")}</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
buttonText={t("idpConfirmDelete")}
|
buttonText={t("idpConfirmDelete")}
|
||||||
@@ -189,11 +321,126 @@ export default function IdpTable({ idps, orgId }: Props) {
|
|||||||
title={t("idpDelete")}
|
title={t("idpDelete")}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{selectedUnassociateIdp && (
|
||||||
|
<ConfirmDeleteDialog
|
||||||
|
open={isUnassociateModalOpen}
|
||||||
|
setOpen={(val) => {
|
||||||
|
setIsUnassociateModalOpen(val);
|
||||||
|
setSelectedUnassociateIdp(null);
|
||||||
|
}}
|
||||||
|
dialog={
|
||||||
|
<div className="space-y-2">
|
||||||
|
<p>{t("idpUnassociateQuestion")}</p>
|
||||||
|
<p>{t("idpUnassociateDescription")}</p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
buttonText={t("idpUnassociateConfirm")}
|
||||||
|
onConfirm={async () =>
|
||||||
|
unassociateIdp(selectedUnassociateIdp.idpId)
|
||||||
|
}
|
||||||
|
string={selectedUnassociateIdp.name}
|
||||||
|
title={t("idpUnassociateTitle")}
|
||||||
|
warningText={t("idpUnassociateWarning")}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Credenza
|
||||||
|
open={importDialogOpen}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
setImportDialogOpen(open);
|
||||||
|
if (!open) {
|
||||||
|
setImportSearchQuery("");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CredenzaContent className="sm:max-w-lg">
|
||||||
|
<CredenzaHeader>
|
||||||
|
<CredenzaTitle>
|
||||||
|
{t("idpImportDialogTitle")}
|
||||||
|
</CredenzaTitle>
|
||||||
|
<CredenzaDescription>
|
||||||
|
{t("idpImportDialogDescription")}
|
||||||
|
</CredenzaDescription>
|
||||||
|
</CredenzaHeader>
|
||||||
|
<CredenzaBody
|
||||||
|
className={cn(
|
||||||
|
importSubmitting && "pointer-events-none opacity-60"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Command shouldFilter={false}>
|
||||||
|
<CommandInput
|
||||||
|
placeholder={t("idpImportSearchPlaceholder")}
|
||||||
|
value={importSearchQuery}
|
||||||
|
onValueChange={setImportSearchQuery}
|
||||||
|
/>
|
||||||
|
<CommandList>
|
||||||
|
<CommandEmpty>
|
||||||
|
{t("idpImportEmpty")}
|
||||||
|
</CommandEmpty>
|
||||||
|
<CommandGroup>
|
||||||
|
{shownImportIdps.map((row) => (
|
||||||
|
<CommandItem
|
||||||
|
key={`${row.idpId}:${row.orgId}`}
|
||||||
|
className="items-start gap-3 py-2.5"
|
||||||
|
value={`${row.idpId}:${row.orgId}:${row.orgName}:${row.name}`}
|
||||||
|
disabled={!canImportOrgOidcIdp}
|
||||||
|
onSelect={() => {
|
||||||
|
if (!canImportOrgOidcIdp) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void importIdp(row);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="mt-0.5 shrink-0">
|
||||||
|
<IdpImportRowIcon
|
||||||
|
type={row.type}
|
||||||
|
variant={row.variant}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0 flex-1 text-left">
|
||||||
|
<div className="truncate font-medium leading-tight">
|
||||||
|
{row.orgName}
|
||||||
|
</div>
|
||||||
|
<div className="truncate text-sm leading-tight text-muted-foreground">
|
||||||
|
{row.name}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CommandItem>
|
||||||
|
))}
|
||||||
|
</CommandGroup>
|
||||||
|
</CommandList>
|
||||||
|
</Command>
|
||||||
|
</CredenzaBody>
|
||||||
|
<CredenzaFooter>
|
||||||
|
<CredenzaClose asChild>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
disabled={importSubmitting}
|
||||||
|
>
|
||||||
|
{t("cancel")}
|
||||||
|
</Button>
|
||||||
|
</CredenzaClose>
|
||||||
|
</CredenzaFooter>
|
||||||
|
</CredenzaContent>
|
||||||
|
</Credenza>
|
||||||
|
|
||||||
<IdpDataTable
|
<IdpDataTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={idps}
|
data={idps}
|
||||||
onAdd={() => router.push(`/${orgId}/settings/idp/create`)}
|
addActions={[
|
||||||
|
{
|
||||||
|
label: t("idpAddActionCreateNew"),
|
||||||
|
onSelect: () => {
|
||||||
|
router.push(`/${orgId}/settings/idp/create`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("idpAddActionImportFromOrg"),
|
||||||
|
onSelect: () => {
|
||||||
|
setImportDialogOpen(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import { useEnvContext } from "@app/hooks/useEnvContext";
|
|||||||
import { Tier } from "@server/types/Tiers";
|
import { Tier } from "@server/types/Tiers";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
|
|
||||||
const TIER_ORDER: Tier[] = ["tier1", "tier2", "tier3", "enterprise"];
|
// const TIER_ORDER: Tier[] = ["tier1", "tier2", "tier3", "enterprise"];
|
||||||
|
const TIER_ORDER: Tier[] = ["tier2", "tier3", "enterprise"];
|
||||||
|
|
||||||
const TIER_TRANSLATION_KEYS: Record<
|
const TIER_TRANSLATION_KEYS: Record<
|
||||||
Tier,
|
Tier,
|
||||||
|
|||||||
@@ -103,29 +103,27 @@ export default function ProductUpdates({
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<small
|
{filteredUpdates.length > 1 && (
|
||||||
className={cn(
|
<small
|
||||||
"text-xs text-muted-foreground flex items-center gap-1 mt-2 empty:mt-0",
|
className={cn(
|
||||||
showMoreUpdatesText
|
"text-xs text-muted-foreground flex items-center gap-1 mt-2",
|
||||||
? "animate-in fade-in duration-300"
|
showMoreUpdatesText
|
||||||
: "opacity-0"
|
? "animate-in fade-in duration-300"
|
||||||
)}
|
: "opacity-0"
|
||||||
>
|
)}
|
||||||
{filteredUpdates.length > 1 && (
|
>
|
||||||
<>
|
<BellIcon className="flex-none size-3" />
|
||||||
<BellIcon className="flex-none size-3" />
|
<span>
|
||||||
<span>
|
{showNewVersionPopup
|
||||||
{showNewVersionPopup
|
? t("productUpdateMoreInfo", {
|
||||||
? t("productUpdateMoreInfo", {
|
noOfUpdates: filteredUpdates.length
|
||||||
noOfUpdates: filteredUpdates.length
|
})
|
||||||
})
|
: t("productUpdateInfo", {
|
||||||
: t("productUpdateInfo", {
|
noOfUpdates: filteredUpdates.length
|
||||||
noOfUpdates: filteredUpdates.length
|
})}
|
||||||
})}
|
</span>
|
||||||
</span>
|
</small>
|
||||||
</>
|
)}
|
||||||
)}
|
|
||||||
</small>
|
|
||||||
<ProductUpdatesListPopup
|
<ProductUpdatesListPopup
|
||||||
updates={filteredUpdates}
|
updates={filteredUpdates}
|
||||||
show={filteredUpdates.length > 0}
|
show={filteredUpdates.length > 0}
|
||||||
@@ -378,7 +376,7 @@ function NewVersionAvailable({
|
|||||||
<span>
|
<span>
|
||||||
{t("pangolinUpdateAvailableReleaseNotes")}
|
{t("pangolinUpdateAvailableReleaseNotes")}
|
||||||
</span>
|
</span>
|
||||||
<ArrowRight className="flex-none size-3 transition-transform duration-300 ease-in-out group-hover:translate-x-1" />
|
<ArrowRight className="flex-none size-3" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -79,10 +79,7 @@ export default function RoleMappingConfigFields({
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (!supportsMultipleRolesPerUser && mappingBuilderRules.length > 1) {
|
||||||
!supportsMultipleRolesPerUser &&
|
|
||||||
mappingBuilderRules.length > 1
|
|
||||||
) {
|
|
||||||
onMappingBuilderRulesChange([mappingBuilderRules[0]]);
|
onMappingBuilderRulesChange([mappingBuilderRules[0]]);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
@@ -95,11 +92,7 @@ export default function RoleMappingConfigFields({
|
|||||||
if (!supportsMultipleRolesPerUser && fixedRoleNames.length > 1) {
|
if (!supportsMultipleRolesPerUser && fixedRoleNames.length > 1) {
|
||||||
onFixedRoleNamesChange([fixedRoleNames[0]]);
|
onFixedRoleNamesChange([fixedRoleNames[0]]);
|
||||||
}
|
}
|
||||||
}, [
|
}, [supportsMultipleRolesPerUser, fixedRoleNames, onFixedRoleNamesChange]);
|
||||||
supportsMultipleRolesPerUser,
|
|
||||||
fixedRoleNames,
|
|
||||||
onFixedRoleNamesChange
|
|
||||||
]);
|
|
||||||
|
|
||||||
const fixedRadioId = `${fieldIdPrefix}-fixed-roles-mode`;
|
const fixedRadioId = `${fieldIdPrefix}-fixed-roles-mode`;
|
||||||
const builderRadioId = `${fieldIdPrefix}-mapping-builder-mode`;
|
const builderRadioId = `${fieldIdPrefix}-mapping-builder-mode`;
|
||||||
@@ -116,7 +109,6 @@ export default function RoleMappingConfigFields({
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<FormLabel className="mb-2">{t("roleMapping")}</FormLabel>
|
|
||||||
<FormDescription className="mb-4">
|
<FormDescription className="mb-4">
|
||||||
{t("roleMappingDescription")}
|
{t("roleMappingDescription")}
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
@@ -272,7 +264,9 @@ export default function RoleMappingConfigFields({
|
|||||||
supportsMultipleRolesPerUser={
|
supportsMultipleRolesPerUser={
|
||||||
supportsMultipleRolesPerUser
|
supportsMultipleRolesPerUser
|
||||||
}
|
}
|
||||||
showRemoveButton={mappingBuilderShowsRemoveColumn}
|
showRemoveButton={
|
||||||
|
mappingBuilderShowsRemoveColumn
|
||||||
|
}
|
||||||
rule={rule}
|
rule={rule}
|
||||||
onChange={(nextRule) => {
|
onChange={(nextRule) => {
|
||||||
const nextRules = mappingBuilderRules.map(
|
const nextRules = mappingBuilderRules.map(
|
||||||
@@ -390,12 +384,10 @@ function BuilderRuleRow({
|
|||||||
text: name
|
text: name
|
||||||
}))}
|
}))}
|
||||||
setTags={(nextTags) => {
|
setTags={(nextTags) => {
|
||||||
const prevRoleTags = rule.roleNames.map(
|
const prevRoleTags = rule.roleNames.map((name) => ({
|
||||||
(name) => ({
|
id: name,
|
||||||
id: name,
|
text: name
|
||||||
text: name
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
const next =
|
const next =
|
||||||
typeof nextTags === "function"
|
typeof nextTags === "function"
|
||||||
? nextTags(prevRoleTags)
|
? nextTags(prevRoleTags)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
} from "@app/components/StrategySelect";
|
} from "@app/components/StrategySelect";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
import type { IdpOidcProviderType } from "@app/lib/idp/oidcIdpProviderDefaults";
|
import type { IdpOidcProviderType } from "@app/lib/idp/oidcIdpProviderDefaults";
|
||||||
|
import IdpTypeIcon from "@app/components/IdpTypeIcon";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import Image from "next/image";
|
|
||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -32,7 +32,8 @@ export function OidcIdpProviderTypeSelect({ value, onTypeChange }: Props) {
|
|||||||
{
|
{
|
||||||
id: "oidc",
|
id: "oidc",
|
||||||
title: "OAuth2/OIDC",
|
title: "OAuth2/OIDC",
|
||||||
description: t("idpOidcDescription")
|
description: t("idpOidcDescription"),
|
||||||
|
icon: <IdpTypeIcon type="oidc" size={24} />
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
if (hideTemplates) {
|
if (hideTemplates) {
|
||||||
@@ -44,29 +45,13 @@ export function OidcIdpProviderTypeSelect({ value, onTypeChange }: Props) {
|
|||||||
id: "google",
|
id: "google",
|
||||||
title: t("idpGoogleTitle"),
|
title: t("idpGoogleTitle"),
|
||||||
description: t("idpGoogleDescription"),
|
description: t("idpGoogleDescription"),
|
||||||
icon: (
|
icon: <IdpTypeIcon type="google" size={24} />
|
||||||
<Image
|
|
||||||
src="/idp/google.png"
|
|
||||||
alt={t("idpGoogleAlt")}
|
|
||||||
width={24}
|
|
||||||
height={24}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "azure",
|
id: "azure",
|
||||||
title: t("idpAzureTitle"),
|
title: t("idpAzureTitle"),
|
||||||
description: t("idpAzureDescription"),
|
description: t("idpAzureDescription"),
|
||||||
icon: (
|
icon: <IdpTypeIcon type="azure" size={24} />
|
||||||
<Image
|
|
||||||
src="/idp/azure.png"
|
|
||||||
alt={t("idpAzureAlt")}
|
|
||||||
width={24}
|
|
||||||
height={24}
|
|
||||||
className="rounded"
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}, [hideTemplates, t]);
|
}, [hideTemplates, t]);
|
||||||
|
|||||||
@@ -18,12 +18,14 @@ import {
|
|||||||
TableRow
|
TableRow
|
||||||
} from "@/components/ui/table";
|
} from "@/components/ui/table";
|
||||||
import { DataTablePagination } from "@app/components/DataTablePagination";
|
import { DataTablePagination } from "@app/components/DataTablePagination";
|
||||||
|
import type { DataTableAddAction } from "@app/components/ui/data-table";
|
||||||
import { Button } from "@app/components/ui/button";
|
import { Button } from "@app/components/ui/button";
|
||||||
import { Card, CardContent, CardHeader } from "@app/components/ui/card";
|
import { Card, CardContent, CardHeader } from "@app/components/ui/card";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuCheckboxItem,
|
DropdownMenuCheckboxItem,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
DropdownMenuLabel,
|
DropdownMenuLabel,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger
|
DropdownMenuTrigger
|
||||||
@@ -31,7 +33,14 @@ import {
|
|||||||
import { Input } from "@app/components/ui/input";
|
import { Input } from "@app/components/ui/input";
|
||||||
import { useStoredColumnVisibility } from "@app/hooks/useStoredColumnVisibility";
|
import { useStoredColumnVisibility } from "@app/hooks/useStoredColumnVisibility";
|
||||||
|
|
||||||
import { Columns, Filter, Plus, RefreshCw, Search } from "lucide-react";
|
import {
|
||||||
|
ChevronDown,
|
||||||
|
Columns,
|
||||||
|
Filter,
|
||||||
|
Plus,
|
||||||
|
RefreshCw,
|
||||||
|
Search
|
||||||
|
} from "lucide-react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
|
|
||||||
@@ -67,6 +76,8 @@ type ControlledDataTableProps<TData, TValue> = {
|
|||||||
tableId: string;
|
tableId: string;
|
||||||
addButtonText?: string;
|
addButtonText?: string;
|
||||||
onAdd?: () => void;
|
onAdd?: () => void;
|
||||||
|
addActions?: DataTableAddAction[];
|
||||||
|
addButtonDisabled?: boolean;
|
||||||
onRefresh?: () => void;
|
onRefresh?: () => void;
|
||||||
isRefreshing?: boolean;
|
isRefreshing?: boolean;
|
||||||
refreshButtonDisabled?: boolean;
|
refreshButtonDisabled?: boolean;
|
||||||
@@ -90,6 +101,8 @@ export function ControlledDataTable<TData, TValue>({
|
|||||||
rows,
|
rows,
|
||||||
addButtonText,
|
addButtonText,
|
||||||
onAdd,
|
onAdd,
|
||||||
|
addActions,
|
||||||
|
addButtonDisabled = false,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
isRefreshing,
|
isRefreshing,
|
||||||
refreshButtonDisabled = false,
|
refreshButtonDisabled = false,
|
||||||
@@ -348,16 +361,49 @@ export function ControlledDataTable<TData, TValue>({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{onAdd && addButtonText && (
|
{addActions && addActions.length > 0 && addButtonText ? (
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<DropdownMenu>
|
||||||
onClick={onAdd}
|
<DropdownMenuTrigger asChild>
|
||||||
loading={isNavigatingToAddPage}
|
<Button
|
||||||
>
|
disabled={
|
||||||
<Plus className="mr-2 h-4 w-4" />
|
addButtonDisabled ||
|
||||||
{addButtonText}
|
isNavigatingToAddPage
|
||||||
</Button>
|
}
|
||||||
|
>
|
||||||
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
|
{addButtonText}
|
||||||
|
<ChevronDown className="ml-2 h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end">
|
||||||
|
{addActions.map((action, i) => (
|
||||||
|
<DropdownMenuItem
|
||||||
|
key={i}
|
||||||
|
onSelect={() =>
|
||||||
|
action.onSelect()
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{action.label}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
))}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
onAdd &&
|
||||||
|
addButtonText && (
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
onClick={onAdd}
|
||||||
|
loading={isNavigatingToAddPage}
|
||||||
|
disabled={addButtonDisabled}
|
||||||
|
>
|
||||||
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
|
{addButtonText}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import { Button } from "@app/components/ui/button";
|
|||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { Input } from "@app/components/ui/input";
|
import { Input } from "@app/components/ui/input";
|
||||||
import { DataTablePagination } from "@app/components/DataTablePagination";
|
import { DataTablePagination } from "@app/components/DataTablePagination";
|
||||||
import { Plus, Search, RefreshCw, Columns, Filter } from "lucide-react";
|
import { ChevronDown, Plus, Search, RefreshCw, Columns, Filter } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -46,6 +46,7 @@ import {
|
|||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuCheckboxItem,
|
DropdownMenuCheckboxItem,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
DropdownMenuLabel,
|
DropdownMenuLabel,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger
|
DropdownMenuTrigger
|
||||||
@@ -165,12 +166,20 @@ export type DataTablePaginationState = PaginationState & {
|
|||||||
|
|
||||||
export type DataTablePaginationUpdateFn = (newPage: PaginationState) => void;
|
export type DataTablePaginationUpdateFn = (newPage: PaginationState) => void;
|
||||||
|
|
||||||
|
/** When set (non-empty), replaces the single add button with a dropdown; `onAdd` is not used. */
|
||||||
|
export type DataTableAddAction = {
|
||||||
|
label: string;
|
||||||
|
onSelect: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
type DataTableProps<TData, TValue> = {
|
type DataTableProps<TData, TValue> = {
|
||||||
columns: ExtendedColumnDef<TData, TValue>[];
|
columns: ExtendedColumnDef<TData, TValue>[];
|
||||||
data: TData[];
|
data: TData[];
|
||||||
title?: string;
|
title?: string;
|
||||||
addButtonText?: string;
|
addButtonText?: string;
|
||||||
onAdd?: () => void;
|
onAdd?: () => void;
|
||||||
|
/** Prefer over `onAdd` when non-empty. */
|
||||||
|
addActions?: DataTableAddAction[];
|
||||||
addButtonDisabled?: boolean;
|
addButtonDisabled?: boolean;
|
||||||
onRefresh?: () => void;
|
onRefresh?: () => void;
|
||||||
isRefreshing?: boolean;
|
isRefreshing?: boolean;
|
||||||
@@ -205,6 +214,7 @@ export function DataTable<TData, TValue>({
|
|||||||
title,
|
title,
|
||||||
addButtonText,
|
addButtonText,
|
||||||
onAdd,
|
onAdd,
|
||||||
|
addActions,
|
||||||
addButtonDisabled = false,
|
addButtonDisabled = false,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
isRefreshing,
|
isRefreshing,
|
||||||
@@ -637,13 +647,45 @@ export function DataTable<TData, TValue>({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{onAdd && addButtonText && (
|
{addActions && addActions.length > 0 && addButtonText ? (
|
||||||
<div>
|
<div>
|
||||||
<Button onClick={onAdd} disabled={addButtonDisabled}>
|
<DropdownMenu>
|
||||||
<Plus className="mr-2 h-4 w-4" />
|
<DropdownMenuTrigger asChild>
|
||||||
{addButtonText}
|
<Button
|
||||||
</Button>
|
disabled={addButtonDisabled}
|
||||||
|
>
|
||||||
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
|
{addButtonText}
|
||||||
|
<ChevronDown className="ml-2 h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end">
|
||||||
|
{addActions.map((action, i) => (
|
||||||
|
<DropdownMenuItem
|
||||||
|
key={i}
|
||||||
|
onSelect={() =>
|
||||||
|
action.onSelect()
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{action.label}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
))}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
onAdd &&
|
||||||
|
addButtonText && (
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
onClick={onAdd}
|
||||||
|
disabled={addButtonDisabled}
|
||||||
|
>
|
||||||
|
<Plus className="mr-2 h-4 w-4" />
|
||||||
|
{addButtonText}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|||||||
Reference in New Issue
Block a user