mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-11 15:08:36 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d608df0f79 | |||
| d04740fede | |||
| b7c0669c38 |
@@ -1449,11 +1449,8 @@
|
|||||||
"actionSetResourcePincode": "Set Resource Pincode",
|
"actionSetResourcePincode": "Set Resource Pincode",
|
||||||
"actionSetResourceEmailWhitelist": "Set Resource Email Whitelist",
|
"actionSetResourceEmailWhitelist": "Set Resource Email Whitelist",
|
||||||
"actionGetResourceEmailWhitelist": "Get Resource Email Whitelist",
|
"actionGetResourceEmailWhitelist": "Get Resource Email Whitelist",
|
||||||
"actionListResourcePolicies": "List Resource Policies",
|
|
||||||
"actionCreateResourcePolicy": "Create Resource Policy",
|
|
||||||
"actionGetResourcePolicy": "Get Resource Policy",
|
"actionGetResourcePolicy": "Get Resource Policy",
|
||||||
"actionUpdateResourcePolicy": "Update Resource Policy",
|
"actionUpdateResourcePolicy": "Update Resource Policy",
|
||||||
"actionDeleteResourcePolicy": "Delete Resource Policy",
|
|
||||||
"actionSetResourcePolicyUsers": "Set Resource Policy Users",
|
"actionSetResourcePolicyUsers": "Set Resource Policy Users",
|
||||||
"actionSetResourcePolicyRoles": "Set Resource Policy Roles",
|
"actionSetResourcePolicyRoles": "Set Resource Policy Roles",
|
||||||
"actionSetResourcePolicyPassword": "Set Resource Policy Password",
|
"actionSetResourcePolicyPassword": "Set Resource Policy Password",
|
||||||
|
|||||||
Generated
+2426
-3124
File diff suppressed because it is too large
Load Diff
+70
-70
@@ -32,49 +32,49 @@
|
|||||||
"format": "prettier --write ."
|
"format": "prettier --write ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@asteasolutions/zod-to-openapi": "8.5.0",
|
"@asteasolutions/zod-to-openapi": "9.1.0",
|
||||||
"@devolutions/iron-remote-desktop": "https://static.pangolin.net/packages/devolutions-iron-remote-desktop-0.0.0.tgz",
|
"@devolutions/iron-remote-desktop": "https://static.pangolin.net/packages/devolutions-iron-remote-desktop-0.0.0.tgz",
|
||||||
"@devolutions/iron-remote-desktop-rdp": "https://static.pangolin.net/packages/devolutions-iron-remote-desktop-rdp-0.0.1.tgz",
|
"@devolutions/iron-remote-desktop-rdp": "https://static.pangolin.net/packages/devolutions-iron-remote-desktop-rdp-0.0.1.tgz",
|
||||||
"@aws-sdk/client-s3": "3.1056.0",
|
"@aws-sdk/client-s3": "3.1105.0",
|
||||||
"@headlessui/react": "2.2.10",
|
"@headlessui/react": "2.2.10",
|
||||||
"@hookform/resolvers": "5.4.0",
|
"@hookform/resolvers": "5.7.1",
|
||||||
"@monaco-editor/react": "4.7.0",
|
"@monaco-editor/react": "4.7.0",
|
||||||
"@node-rs/argon2": "2.0.2",
|
"@node-rs/argon2": "2.0.2",
|
||||||
"@novnc/novnc": "^1.7.0",
|
"@novnc/novnc": "^1.7.0",
|
||||||
"@oslojs/crypto": "1.0.1",
|
"@oslojs/crypto": "1.0.1",
|
||||||
"@oslojs/encoding": "1.1.0",
|
"@oslojs/encoding": "1.1.0",
|
||||||
"@radix-ui/react-avatar": "1.1.11",
|
"@radix-ui/react-avatar": "1.2.6",
|
||||||
"@radix-ui/react-checkbox": "1.3.3",
|
"@radix-ui/react-checkbox": "1.3.11",
|
||||||
"@radix-ui/react-collapsible": "1.1.12",
|
"@radix-ui/react-collapsible": "1.1.20",
|
||||||
"@radix-ui/react-dialog": "1.1.15",
|
"@radix-ui/react-dialog": "1.1.23",
|
||||||
"@radix-ui/react-dropdown-menu": "2.1.16",
|
"@radix-ui/react-dropdown-menu": "2.1.24",
|
||||||
"@radix-ui/react-icons": "1.3.2",
|
"@radix-ui/react-icons": "1.3.2",
|
||||||
"@radix-ui/react-label": "2.1.8",
|
"@radix-ui/react-label": "2.1.15",
|
||||||
"@radix-ui/react-popover": "1.1.15",
|
"@radix-ui/react-popover": "1.1.23",
|
||||||
"@radix-ui/react-progress": "1.1.8",
|
"@radix-ui/react-progress": "1.1.16",
|
||||||
"@radix-ui/react-radio-group": "1.3.8",
|
"@radix-ui/react-radio-group": "1.4.7",
|
||||||
"@radix-ui/react-scroll-area": "1.2.10",
|
"@radix-ui/react-scroll-area": "1.2.18",
|
||||||
"@radix-ui/react-select": "2.2.6",
|
"@radix-ui/react-select": "2.3.7",
|
||||||
"@radix-ui/react-separator": "1.1.8",
|
"@radix-ui/react-separator": "1.1.15",
|
||||||
"@radix-ui/react-slot": "1.2.4",
|
"@radix-ui/react-slot": "1.3.3",
|
||||||
"@radix-ui/react-switch": "1.2.6",
|
"@radix-ui/react-switch": "1.3.7",
|
||||||
"@radix-ui/react-tabs": "1.1.13",
|
"@radix-ui/react-tabs": "1.1.21",
|
||||||
"@radix-ui/react-toast": "1.2.15",
|
"@radix-ui/react-toast": "1.2.23",
|
||||||
"@radix-ui/react-tooltip": "1.2.8",
|
"@radix-ui/react-tooltip": "1.2.16",
|
||||||
"@react-email/body": "0.3.0",
|
"@react-email/body": "0.3.0",
|
||||||
"@react-email/components": "1.0.12",
|
"@react-email/components": "1.0.12",
|
||||||
"@react-email/render": "2.0.8",
|
"@react-email/render": "2.1.0",
|
||||||
"@react-email/tailwind": "2.0.7",
|
"@react-email/tailwind": "2.0.7",
|
||||||
"@simplewebauthn/browser": "13.3.0",
|
"@simplewebauthn/browser": "13.3.0",
|
||||||
"@simplewebauthn/server": "13.3.1",
|
"@simplewebauthn/server": "13.3.2",
|
||||||
"@tailwindcss/forms": "0.5.11",
|
"@tailwindcss/forms": "0.5.11",
|
||||||
"@tanstack/react-query": "5.100.14",
|
"@tanstack/react-query": "5.101.4",
|
||||||
"@tanstack/react-table": "8.21.3",
|
"@tanstack/react-table": "9.0.0",
|
||||||
"@xterm/addon-fit": "^0.11.0",
|
"@xterm/addon-fit": "^0.11.0",
|
||||||
"@xterm/addon-web-links": "^0.12.0",
|
"@xterm/addon-web-links": "^0.12.0",
|
||||||
"@xterm/xterm": "^6.0.0",
|
"@xterm/xterm": "^6.0.0",
|
||||||
"arctic": "3.7.0",
|
"arctic": "3.7.0",
|
||||||
"axios": "1.18.0",
|
"axios": "1.19.0",
|
||||||
"better-sqlite3": "11.9.1",
|
"better-sqlite3": "11.9.1",
|
||||||
"canvas-confetti": "1.9.4",
|
"canvas-confetti": "1.9.4",
|
||||||
"class-variance-authority": "0.7.1",
|
"class-variance-authority": "0.7.1",
|
||||||
@@ -86,61 +86,61 @@
|
|||||||
"d3": "7.9.0",
|
"d3": "7.9.0",
|
||||||
"drizzle-orm": "0.45.2",
|
"drizzle-orm": "0.45.2",
|
||||||
"express": "5.2.1",
|
"express": "5.2.1",
|
||||||
"express-rate-limit": "8.5.2",
|
"express-rate-limit": "8.6.2",
|
||||||
"glob": "13.0.6",
|
"glob": "13.0.6",
|
||||||
"helmet": "8.2.0",
|
"helmet": "8.3.0",
|
||||||
"http-errors": "2.0.1",
|
"http-errors": "2.0.1",
|
||||||
"input-otp": "1.4.2",
|
"input-otp": "1.4.2",
|
||||||
"ioredis": "5.11.0",
|
"ioredis": "6.0.0",
|
||||||
"jmespath": "0.16.0",
|
"jmespath": "0.16.0",
|
||||||
"js-yaml": "4.3.0",
|
"js-yaml": "5.2.3",
|
||||||
"jsonwebtoken": "9.0.3",
|
"jsonwebtoken": "9.0.3",
|
||||||
"lucide-react": "1.17.0",
|
"lucide-react": "1.29.0",
|
||||||
"maxmind": "5.0.6",
|
"maxmind": "5.0.7",
|
||||||
"moment": "2.30.1",
|
"moment": "2.30.1",
|
||||||
"next": "16.2.11",
|
"next": "16.3.0",
|
||||||
"next-intl": "4.13.0",
|
"next-intl": "4.13.5",
|
||||||
"next-themes": "0.4.6",
|
"next-themes": "0.4.6",
|
||||||
"nextjs-toploader": "3.9.17",
|
"nextjs-toploader": "3.9.17",
|
||||||
"node-cache": "5.1.2",
|
"node-cache": "5.1.2",
|
||||||
"nodemailer": "9.0.1",
|
"nodemailer": "9.0.4",
|
||||||
"oslo": "1.2.1",
|
"oslo": "1.2.1",
|
||||||
"pg": "8.21.0",
|
"pg": "8.22.0",
|
||||||
"posthog-node": "5.35.6",
|
"posthog-node": "5.48.1",
|
||||||
"qrcode.react": "4.2.0",
|
"qrcode.react": "4.2.0",
|
||||||
"react": "19.2.6",
|
"react": "19.2.8",
|
||||||
"react-day-picker": "9.14.0",
|
"react-day-picker": "10.0.1",
|
||||||
"react-dom": "19.2.6",
|
"react-dom": "19.2.8",
|
||||||
"react-easy-sort": "1.8.0",
|
"react-easy-sort": "1.8.0",
|
||||||
"react-hook-form": "7.76.1",
|
"react-hook-form": "7.84.0",
|
||||||
"react-icons": "5.6.0",
|
"react-icons": "5.7.0",
|
||||||
"recharts": "3.8.1",
|
"recharts": "3.10.1",
|
||||||
"reodotdev": "1.1.0",
|
"reodotdev": "1.1.0",
|
||||||
"semver": "7.8.1",
|
"semver": "7.8.5",
|
||||||
"sshpk": "1.18.0",
|
"sshpk": "1.18.0",
|
||||||
"stripe": "22.2.0",
|
"stripe": "22.4.0",
|
||||||
"swagger-ui-express": "5.0.1",
|
"swagger-ui-express": "5.0.1",
|
||||||
"tailwind-merge": "3.6.0",
|
"tailwind-merge": "3.6.0",
|
||||||
"topojson-client": "3.1.0",
|
"topojson-client": "3.1.0",
|
||||||
"tw-animate-css": "1.4.0",
|
"tw-animate-css": "1.4.0",
|
||||||
"use-debounce": "10.1.1",
|
"use-debounce": "10.1.1",
|
||||||
"uuid": "14.0.0",
|
"uuid": "14.0.1",
|
||||||
"vaul": "1.1.2",
|
"vaul": "1.1.2",
|
||||||
"visionscarto-world-atlas": "1.0.0",
|
"visionscarto-world-atlas": "1.0.0",
|
||||||
"winston": "3.19.0",
|
"winston": "3.19.0",
|
||||||
"winston-daily-rotate-file": "5.0.0",
|
"winston-daily-rotate-file": "5.0.0",
|
||||||
"ws": "8.21.0",
|
"ws": "8.21.2",
|
||||||
"yaml": "2.9.0",
|
"yaml": "2.9.0",
|
||||||
"yargs": "18.0.0",
|
"yargs": "18.1.0",
|
||||||
"zod": "4.4.3",
|
"zod": "4.4.3",
|
||||||
"zod-validation-error": "5.0.0"
|
"zod-validation-error": "5.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@dotenvx/dotenvx": "1.69.1",
|
"@dotenvx/dotenvx": "2.19.2",
|
||||||
"@esbuild-plugins/tsconfig-paths": "0.1.2",
|
"@esbuild-plugins/tsconfig-paths": "0.1.2",
|
||||||
"@react-email/ui": "^6.5.0",
|
"@react-email/ui": "^6.9.1",
|
||||||
"@tailwindcss/postcss": "4.3.0",
|
"@tailwindcss/postcss": "4.3.3",
|
||||||
"@tanstack/react-query-devtools": "5.100.14",
|
"@tanstack/react-query-devtools": "5.101.4",
|
||||||
"@types/better-sqlite3": "7.6.13",
|
"@types/better-sqlite3": "7.6.13",
|
||||||
"@types/cookie-parser": "1.4.10",
|
"@types/cookie-parser": "1.4.10",
|
||||||
"@types/cors": "2.8.19",
|
"@types/cors": "2.8.19",
|
||||||
@@ -151,14 +151,14 @@
|
|||||||
"@types/jmespath": "0.15.2",
|
"@types/jmespath": "0.15.2",
|
||||||
"@types/js-yaml": "4.0.9",
|
"@types/js-yaml": "4.0.9",
|
||||||
"@types/jsonwebtoken": "9.0.10",
|
"@types/jsonwebtoken": "9.0.10",
|
||||||
"@types/node": "25.9.1",
|
"@types/node": "26.1.2",
|
||||||
"@types/nodemailer": "8.0.0",
|
"@types/nodemailer": "8.0.1",
|
||||||
"@types/nprogress": "0.2.3",
|
"@types/nprogress": "0.2.3",
|
||||||
"@types/pg": "8.20.0",
|
"@types/pg": "8.20.4",
|
||||||
"@types/react": "19.2.15",
|
"@types/react": "19.2.18",
|
||||||
"@types/react-dom": "19.2.3",
|
"@types/react-dom": "19.2.4",
|
||||||
"@types/semver": "7.7.1",
|
"@types/semver": "7.8.0",
|
||||||
"@types/sshpk": "1.17.4",
|
"@types/sshpk": "1.17.5",
|
||||||
"@types/swagger-ui-express": "4.1.8",
|
"@types/swagger-ui-express": "4.1.8",
|
||||||
"@types/topojson-client": "3.1.5",
|
"@types/topojson-client": "3.1.5",
|
||||||
"@types/ws": "8.18.1",
|
"@types/ws": "8.18.1",
|
||||||
@@ -166,21 +166,21 @@
|
|||||||
"babel-plugin-react-compiler": "1.0.0",
|
"babel-plugin-react-compiler": "1.0.0",
|
||||||
"drizzle-kit": "0.31.10",
|
"drizzle-kit": "0.31.10",
|
||||||
"esbuild": "0.28.1",
|
"esbuild": "0.28.1",
|
||||||
"esbuild-node-externals": "1.22.0",
|
"esbuild-node-externals": "2.0.0",
|
||||||
"eslint": "10.4.0",
|
"eslint": "10.8.0",
|
||||||
"eslint-config-next": "16.2.6",
|
"eslint-config-next": "16.3.0",
|
||||||
"postcss": "8.5.15",
|
"postcss": "8.5.26",
|
||||||
"prettier": "3.8.3",
|
"prettier": "3.9.6",
|
||||||
"react-email": "6.5.0",
|
"react-email": "6.9.1",
|
||||||
"tailwindcss": "4.3.0",
|
"tailwindcss": "4.3.3",
|
||||||
"tsc-alias": "1.8.17",
|
"tsc-alias": "1.9.1",
|
||||||
"tsx": "4.22.3",
|
"tsx": "4.23.9",
|
||||||
"typescript": "6.0.3",
|
"typescript": "7.0.2",
|
||||||
"typescript-eslint": "8.60.0"
|
"typescript-eslint": "8.66.0"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"esbuild": "0.28.1",
|
"esbuild": "0.28.1",
|
||||||
"dompurify": "3.4.0",
|
"dompurify": "3.4.0",
|
||||||
"postcss": "8.5.15"
|
"postcss": "8.5.26"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,8 +95,7 @@ export const subscriptions = pgTable("subscriptions", {
|
|||||||
billingCycleAnchor: bigint("billingCycleAnchor", { mode: "number" }),
|
billingCycleAnchor: bigint("billingCycleAnchor", { mode: "number" }),
|
||||||
expiresAt: bigint("expiresAt", { mode: "number" }),
|
expiresAt: bigint("expiresAt", { mode: "number" }),
|
||||||
trial: boolean("trial").default(false),
|
trial: boolean("trial").default(false),
|
||||||
type: varchar("type", { length: 50 }), // tier1, tier2, tier3, or license
|
type: varchar("type", { length: 50 }) // tier1, tier2, tier3, or license
|
||||||
override: boolean("override").default(false)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const subscriptionItems = pgTable("subscriptionItems", {
|
export const subscriptionItems = pgTable("subscriptionItems", {
|
||||||
|
|||||||
@@ -89,8 +89,7 @@ export const subscriptions = sqliteTable("subscriptions", {
|
|||||||
expiresAt: integer("expiresAt"),
|
expiresAt: integer("expiresAt"),
|
||||||
trial: integer("trial", { mode: "boolean" }).default(false),
|
trial: integer("trial", { mode: "boolean" }).default(false),
|
||||||
billingCycleAnchor: integer("billingCycleAnchor"),
|
billingCycleAnchor: integer("billingCycleAnchor"),
|
||||||
type: text("type"), // tier1, tier2, tier3, or license
|
type: text("type") // tier1, tier2, tier3, or license
|
||||||
override: integer("override", { mode: "boolean" }).default(false)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const subscriptionItems = sqliteTable("subscriptionItems", {
|
export const subscriptionItems = sqliteTable("subscriptionItems", {
|
||||||
|
|||||||
@@ -53,15 +53,6 @@ export async function handleSubscriptionDeleted(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the subscription has been manually overridden, we lock it down
|
|
||||||
// so Stripe can no longer change (or delete) its status locally.
|
|
||||||
if (existingSubscription.override === true) {
|
|
||||||
logger.info(
|
|
||||||
`Subscription ${subscription.id} is locked (override=true). Ignoring deletion event from Stripe.`
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await db
|
await db
|
||||||
.delete(subscriptions)
|
.delete(subscriptions)
|
||||||
.where(eq(subscriptions.subscriptionId, subscription.id));
|
.where(eq(subscriptions.subscriptionId, subscription.id));
|
||||||
|
|||||||
@@ -68,27 +68,13 @@ export async function handleSubscriptionUpdated(
|
|||||||
const type = getSubType(fullSubscription);
|
const type = getSubType(fullSubscription);
|
||||||
const previousType = existingSubscription.type as SubscriptionType | null;
|
const previousType = existingSubscription.type as SubscriptionType | null;
|
||||||
|
|
||||||
// If the subscription has been manually overridden, we lock the
|
|
||||||
// status down so Stripe webhooks can no longer change it.
|
|
||||||
const isLocked = existingSubscription.override === true;
|
|
||||||
if (isLocked) {
|
|
||||||
logger.info(
|
|
||||||
`Subscription ${subscription.id} is locked (override=true). Ignoring status change from Stripe (would have been ${subscription.status}).`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const effectiveStatus = isLocked
|
|
||||||
? existingSubscription.status
|
|
||||||
: subscription.status;
|
|
||||||
|
|
||||||
await db
|
await db
|
||||||
.update(subscriptions)
|
.update(subscriptions)
|
||||||
.set({
|
.set({
|
||||||
status: effectiveStatus,
|
status: subscription.status,
|
||||||
canceledAt: isLocked
|
canceledAt: subscription.canceled_at
|
||||||
? existingSubscription.canceledAt
|
? subscription.canceled_at
|
||||||
: subscription.canceled_at
|
: null,
|
||||||
? subscription.canceled_at
|
|
||||||
: null,
|
|
||||||
updatedAt: Math.floor(Date.now() / 1000),
|
updatedAt: Math.floor(Date.now() / 1000),
|
||||||
billingCycleAnchor: subscription.billing_cycle_anchor,
|
billingCycleAnchor: subscription.billing_cycle_anchor,
|
||||||
type: type
|
type: type
|
||||||
@@ -289,23 +275,23 @@ export async function handleSubscriptionUpdated(
|
|||||||
// we only need to handle the limit lifecycle for saas subscriptions not for the licenses
|
// we only need to handle the limit lifecycle for saas subscriptions not for the licenses
|
||||||
await handleSubscriptionLifesycle(
|
await handleSubscriptionLifesycle(
|
||||||
customer.orgId,
|
customer.orgId,
|
||||||
effectiveStatus,
|
subscription.status,
|
||||||
type
|
type
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handle feature lifecycle when subscription is canceled or becomes unpaid
|
// Handle feature lifecycle when subscription is canceled or becomes unpaid
|
||||||
if (
|
if (
|
||||||
effectiveStatus === "canceled" ||
|
subscription.status === "canceled" ||
|
||||||
effectiveStatus === "unpaid" ||
|
subscription.status === "unpaid" ||
|
||||||
effectiveStatus === "incomplete_expired"
|
subscription.status === "incomplete_expired"
|
||||||
) {
|
) {
|
||||||
logger.info(
|
logger.info(
|
||||||
`Subscription ${subscription.id} for org ${customer.orgId} is ${effectiveStatus}, disabling paid features`
|
`Subscription ${subscription.id} for org ${customer.orgId} is ${subscription.status}, disabling paid features`
|
||||||
);
|
);
|
||||||
await handleTierChange(customer.orgId, null, previousType ?? undefined);
|
await handleTierChange(customer.orgId, null, previousType ?? undefined);
|
||||||
}
|
}
|
||||||
} else if (type === "license") {
|
} else if (type === "license") {
|
||||||
if (effectiveStatus === "canceled" || effectiveStatus == "unpaid" || effectiveStatus == "incomplete_expired") {
|
if (subscription.status === "canceled" || subscription.status == "unpaid" || subscription.status == "incomplete_expired") {
|
||||||
try {
|
try {
|
||||||
// WARNING:
|
// WARNING:
|
||||||
// this invalidates ALL OF THE ENTERPRISE LICENSES for this orgId
|
// this invalidates ALL OF THE ENTERPRISE LICENSES for this orgId
|
||||||
|
|||||||
@@ -726,8 +726,8 @@ authenticated.post(
|
|||||||
verifyApiKeyResourcePolicyAccess,
|
verifyApiKeyResourcePolicyAccess,
|
||||||
verifyApiKeyRoleAccess,
|
verifyApiKeyRoleAccess,
|
||||||
verifyLimits,
|
verifyLimits,
|
||||||
verifyApiKeyHasAction(ActionsEnum.setResourcePolicyUsers),
|
verifyUserHasAction(ActionsEnum.setResourcePolicyUsers),
|
||||||
verifyApiKeyHasAction(ActionsEnum.setResourcePolicyRoles),
|
verifyUserHasAction(ActionsEnum.setResourcePolicyRoles),
|
||||||
logActionAudit(ActionsEnum.setResourcePolicyUsers),
|
logActionAudit(ActionsEnum.setResourcePolicyUsers),
|
||||||
logActionAudit(ActionsEnum.setResourcePolicyRoles),
|
logActionAudit(ActionsEnum.setResourcePolicyRoles),
|
||||||
policy.setResourcePolicyAccessControl
|
policy.setResourcePolicyAccessControl
|
||||||
@@ -742,8 +742,8 @@ authenticated.put(
|
|||||||
verifyApiKeyResourcePolicyAccess,
|
verifyApiKeyResourcePolicyAccess,
|
||||||
verifyApiKeyRoleAccess,
|
verifyApiKeyRoleAccess,
|
||||||
verifyLimits,
|
verifyLimits,
|
||||||
verifyApiKeyHasAction(ActionsEnum.setResourcePolicyUsers),
|
verifyUserHasAction(ActionsEnum.setResourcePolicyUsers),
|
||||||
verifyApiKeyHasAction(ActionsEnum.setResourcePolicyRoles),
|
verifyUserHasAction(ActionsEnum.setResourcePolicyRoles),
|
||||||
logActionAudit(ActionsEnum.setResourcePolicyUsers),
|
logActionAudit(ActionsEnum.setResourcePolicyUsers),
|
||||||
logActionAudit(ActionsEnum.setResourcePolicyRoles),
|
logActionAudit(ActionsEnum.setResourcePolicyRoles),
|
||||||
policy.setResourcePolicyAccessControl
|
policy.setResourcePolicyAccessControl
|
||||||
|
|||||||
+1
-1
@@ -181,7 +181,7 @@ export default function NetworkingPage() {
|
|||||||
<SettingsSectionDescription>
|
<SettingsSectionDescription>
|
||||||
{t("remoteExitNodeNetworkingDescription")}
|
{t("remoteExitNodeNetworkingDescription")}
|
||||||
<a
|
<a
|
||||||
href="https://docs.pangolin.net/manage/remote-node/backhaul"
|
href="https://docs.pangolin.net/placeholder"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="text-primary hover:underline inline-flex items-center gap-1"
|
className="text-primary hover:underline inline-flex items-center gap-1"
|
||||||
|
|||||||
@@ -38,6 +38,18 @@ import { useEffect, useState } from "react";
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
const accessControlsFormSchema = z.object({
|
||||||
|
username: z.string(),
|
||||||
|
autoProvisioned: z.boolean(),
|
||||||
|
roles: z.array(
|
||||||
|
z.object({
|
||||||
|
id: z.string(),
|
||||||
|
text: z.string(),
|
||||||
|
isAdmin: z.boolean().optional()
|
||||||
|
})
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
export default function AccessControlsPage() {
|
export default function AccessControlsPage() {
|
||||||
const { orgUser: user, updateOrgUser } = userOrgUserContext();
|
const { orgUser: user, updateOrgUser } = userOrgUserContext();
|
||||||
const { user: sessionUser } = useUserContext();
|
const { user: sessionUser } = useUserContext();
|
||||||
@@ -57,20 +69,6 @@ export default function AccessControlsPage() {
|
|||||||
(build === "enterprise" && !isPaid) ||
|
(build === "enterprise" && !isPaid) ||
|
||||||
(build === "oss" && !isPaid));
|
(build === "oss" && !isPaid));
|
||||||
|
|
||||||
const accessControlsFormSchema = z.object({
|
|
||||||
username: z.string(),
|
|
||||||
autoProvisioned: z.boolean(),
|
|
||||||
roles: z
|
|
||||||
.array(
|
|
||||||
z.object({
|
|
||||||
id: z.string(),
|
|
||||||
text: z.string(),
|
|
||||||
isAdmin: z.boolean().optional()
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.min(1, { message: t("accessRoleSelectPlease") })
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: zodResolver(accessControlsFormSchema),
|
resolver: zodResolver(accessControlsFormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@@ -110,6 +108,15 @@ export default function AccessControlsPage() {
|
|||||||
async function executeSave() {
|
async function executeSave() {
|
||||||
const values = form.getValues();
|
const values = form.getValues();
|
||||||
|
|
||||||
|
if (values.roles.length === 0) {
|
||||||
|
toast({
|
||||||
|
variant: "destructive",
|
||||||
|
title: t("accessRoleRequired"),
|
||||||
|
description: t("accessRoleSelectPlease")
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
try {
|
try {
|
||||||
const roleIds = values.roles.map((r) => parseInt(r.id, 10));
|
const roleIds = values.roles.map((r) => parseInt(r.id, 10));
|
||||||
@@ -163,6 +170,15 @@ export default function AccessControlsPage() {
|
|||||||
|
|
||||||
const values = form.getValues();
|
const values = form.getValues();
|
||||||
|
|
||||||
|
if (values.roles.length === 0) {
|
||||||
|
toast({
|
||||||
|
variant: "destructive",
|
||||||
|
title: t("accessRoleRequired"),
|
||||||
|
description: t("accessRoleSelectPlease")
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const willHaveAdminRole = values.roles.some((r) => r.isAdmin === true);
|
const willHaveAdminRole = values.roles.some((r) => r.isAdmin === true);
|
||||||
|
|
||||||
const isRemovingOwnAdmin =
|
const isRemovingOwnAdmin =
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
InfoSections,
|
InfoSections,
|
||||||
InfoSectionTitle
|
InfoSectionTitle
|
||||||
} from "@app/components/InfoSection";
|
} from "@app/components/InfoSection";
|
||||||
import CopyToClipboard from "@app/components/CopyToClipboard";
|
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
type OrgInfoCardProps = {};
|
type OrgInfoCardProps = {};
|
||||||
@@ -27,9 +26,7 @@ export default function OrgInfoCard({}: OrgInfoCardProps) {
|
|||||||
</InfoSection>
|
</InfoSection>
|
||||||
<InfoSection>
|
<InfoSection>
|
||||||
<InfoSectionTitle>{t("orgId")}</InfoSectionTitle>
|
<InfoSectionTitle>{t("orgId")}</InfoSectionTitle>
|
||||||
<InfoSectionContent>
|
<InfoSectionContent>{org.org.orgId}</InfoSectionContent>
|
||||||
<CopyToClipboard text={org.org.orgId} />
|
|
||||||
</InfoSectionContent>
|
|
||||||
</InfoSection>
|
</InfoSection>
|
||||||
<InfoSection>
|
<InfoSection>
|
||||||
<InfoSectionTitle>{t("subnet")}</InfoSectionTitle>
|
<InfoSectionTitle>{t("subnet")}</InfoSectionTitle>
|
||||||
|
|||||||
@@ -9,15 +9,17 @@ import {
|
|||||||
FormMessage
|
FormMessage
|
||||||
} from "@app/components/ui/form";
|
} from "@app/components/ui/form";
|
||||||
|
|
||||||
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
|
import { useRef } from "react";
|
||||||
import type { FieldValues, Path, UseFormReturn } from "react-hook-form";
|
import type { FieldValues, Path, UseFormReturn } from "react-hook-form";
|
||||||
import { RolesSelector, type SelectedRole } from "./roles-selector";
|
import { RolesSelector, type SelectedRole } from "./roles-selector";
|
||||||
|
|
||||||
type OrgRolesTagFieldProps<TFieldValues extends FieldValues> = {
|
type OrgRolesTagFieldProps<TFieldValues extends FieldValues> = {
|
||||||
form: Pick<
|
form: Pick<
|
||||||
UseFormReturn<TFieldValues>,
|
UseFormReturn<TFieldValues>,
|
||||||
"control" | "getValues" | "setValue" | "clearErrors"
|
"control" | "getValues" | "setValue"
|
||||||
>;
|
>;
|
||||||
orgId: string;
|
orgId: string;
|
||||||
/** Field in the form that holds Tag[] (role tags). Default: `"roles"`. */
|
/** Field in the form that holds Tag[] (role tags). Default: `"roles"`. */
|
||||||
@@ -40,6 +42,46 @@ export default function OrgRolesTagField<TFieldValues extends FieldValues>({
|
|||||||
disabled
|
disabled
|
||||||
}: OrgRolesTagFieldProps<TFieldValues>) {
|
}: OrgRolesTagFieldProps<TFieldValues>) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const isPopoverOpenRef = useRef(false);
|
||||||
|
const lastValidRolesRef = useRef<SelectedRole[]>(
|
||||||
|
(form.getValues(name) as SelectedRole[]) ?? []
|
||||||
|
);
|
||||||
|
|
||||||
|
function validateRolesSelection() {
|
||||||
|
const current = form.getValues(name) as SelectedRole[];
|
||||||
|
|
||||||
|
if (current.length === 0 && lastValidRolesRef.current.length > 0) {
|
||||||
|
form.setValue(name, lastValidRolesRef.current as never, {
|
||||||
|
shouldDirty: true
|
||||||
|
});
|
||||||
|
toast({
|
||||||
|
variant: "destructive",
|
||||||
|
title: t("accessRoleRequired"),
|
||||||
|
description: t("accessRoleSelectPlease")
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current.length > 0) {
|
||||||
|
lastValidRolesRef.current = current;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePopoverOpenChange(open: boolean) {
|
||||||
|
isPopoverOpenRef.current = open;
|
||||||
|
|
||||||
|
if (open) {
|
||||||
|
const current = form.getValues(name) as SelectedRole[];
|
||||||
|
if (current.length > 0) {
|
||||||
|
lastValidRolesRef.current = current;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
validateRolesSelection();
|
||||||
|
}
|
||||||
|
|
||||||
function setRoleTags(nextValue: SelectedRole[]) {
|
function setRoleTags(nextValue: SelectedRole[]) {
|
||||||
const prev = form.getValues(name) as SelectedRole[];
|
const prev = form.getValues(name) as SelectedRole[];
|
||||||
@@ -57,14 +99,15 @@ export default function OrgRolesTagField<TFieldValues extends FieldValues>({
|
|||||||
form.setValue(name, [prev[prev.length - 1]] as never, {
|
form.setValue(name, [prev[prev.length - 1]] as never, {
|
||||||
shouldDirty: true
|
shouldDirty: true
|
||||||
});
|
});
|
||||||
form.clearErrors(name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
form.setValue(name, next as never, { shouldDirty: true });
|
form.setValue(name, next as never, { shouldDirty: true });
|
||||||
|
|
||||||
if (next.length > 0) {
|
if (next.length > 0 && !isPopoverOpenRef.current) {
|
||||||
form.clearErrors(name);
|
lastValidRolesRef.current = next;
|
||||||
|
} else if (!isPopoverOpenRef.current) {
|
||||||
|
validateRolesSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +117,9 @@ export default function OrgRolesTagField<TFieldValues extends FieldValues>({
|
|||||||
name={name}
|
name={name}
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const selectedRoles = (field.value ?? []) as SelectedRole[];
|
const selectedRoles = (field.value ?? []) as SelectedRole[];
|
||||||
|
if (!isPopoverOpenRef.current && selectedRoles.length > 0) {
|
||||||
|
lastValidRolesRef.current = selectedRoles;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormItem className="flex flex-col items-start">
|
<FormItem className="flex flex-col items-start">
|
||||||
@@ -83,6 +129,7 @@ export default function OrgRolesTagField<TFieldValues extends FieldValues>({
|
|||||||
orgId={orgId}
|
orgId={orgId}
|
||||||
selectedRoles={selectedRoles}
|
selectedRoles={selectedRoles}
|
||||||
onSelectRoles={setRoleTags}
|
onSelectRoles={setRoleTags}
|
||||||
|
onPopoverOpenChange={handlePopoverOpenChange}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|||||||
@@ -115,11 +115,8 @@ function getActionsCategories(root: boolean) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
"Resource Policy": {
|
"Resource Policy": {
|
||||||
[t("actionListResourcePolicies")]: "listResourcePolicies",
|
|
||||||
[t("actionCreateResourcePolicy")]: "createResourcePolicy",
|
|
||||||
[t("actionGetResourcePolicy")]: "getResourcePolicy",
|
[t("actionGetResourcePolicy")]: "getResourcePolicy",
|
||||||
[t("actionUpdateResourcePolicy")]: "updateResourcePolicy",
|
[t("actionUpdateResourcePolicy")]: "updateResourcePolicy",
|
||||||
[t("actionDeleteResourcePolicy")]: "deleteResourcePolicy",
|
|
||||||
[t("actionSetResourcePolicyUsers")]: "setResourcePolicyUsers",
|
[t("actionSetResourcePolicyUsers")]: "setResourcePolicyUsers",
|
||||||
[t("actionSetResourcePolicyRoles")]: "setResourcePolicyRoles",
|
[t("actionSetResourcePolicyRoles")]: "setResourcePolicyRoles",
|
||||||
[t("actionSetResourcePolicyPassword")]: "setResourcePolicyPassword",
|
[t("actionSetResourcePolicyPassword")]: "setResourcePolicyPassword",
|
||||||
|
|||||||
Reference in New Issue
Block a user