mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-01 00:41:55 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a1934d4289 |
@@ -16,7 +16,7 @@ experimental:
|
|||||||
version: "{{.BadgerVersion}}"
|
version: "{{.BadgerVersion}}"
|
||||||
crowdsec: # CrowdSec plugin configuration added
|
crowdsec: # CrowdSec plugin configuration added
|
||||||
moduleName: "github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin"
|
moduleName: "github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin"
|
||||||
version: "v1.7.1"
|
version: "v1.4.4"
|
||||||
|
|
||||||
log:
|
log:
|
||||||
level: "INFO"
|
level: "INFO"
|
||||||
|
|||||||
@@ -1573,8 +1573,6 @@
|
|||||||
"search": "Search…",
|
"search": "Search…",
|
||||||
"searchPlaceholder": "Search...",
|
"searchPlaceholder": "Search...",
|
||||||
"emptySearchOptions": "No options found",
|
"emptySearchOptions": "No options found",
|
||||||
"ipFilterSearchPlaceholder": "Enter an IP address…",
|
|
||||||
"ipFilterEmptyMessage": "Enter an IP address to filter by",
|
|
||||||
"create": "Create",
|
"create": "Create",
|
||||||
"orgs": "Organizations",
|
"orgs": "Organizations",
|
||||||
"loginError": "An unexpected error occurred. Please try again.",
|
"loginError": "An unexpected error occurred. Please try again.",
|
||||||
@@ -2598,7 +2596,6 @@
|
|||||||
"createDomainType": "Type:",
|
"createDomainType": "Type:",
|
||||||
"createDomainName": "Name:",
|
"createDomainName": "Name:",
|
||||||
"createDomainValue": "Value:",
|
"createDomainValue": "Value:",
|
||||||
"multiSelectFilterCount": "{count} selected",
|
|
||||||
"createDomainCnameRecords": "CNAME Records",
|
"createDomainCnameRecords": "CNAME Records",
|
||||||
"createDomainARecords": "A Records",
|
"createDomainARecords": "A Records",
|
||||||
"createDomainRecordNumber": "Record {number}",
|
"createDomainRecordNumber": "Record {number}",
|
||||||
|
|||||||
Generated
+2048
-3382
File diff suppressed because it is too large
Load Diff
+75
-75
@@ -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",
|
||||||
"@aws-sdk/client-s3": "3.1056.0",
|
"@aws-sdk/client-s3": "3.1120.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",
|
||||||
"@headlessui/react": "2.2.10",
|
"@headlessui/react": "2.2.10",
|
||||||
"@hookform/resolvers": "5.4.0",
|
"@hookform/resolvers": "5.9.1",
|
||||||
"@monaco-editor/react": "4.7.0",
|
"@monaco-editor/react": "4.7.0",
|
||||||
"@node-rs/argon2": "2.0.2",
|
"@node-rs/argon2": "2.1.0",
|
||||||
"@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.3",
|
||||||
"@tailwindcss/forms": "0.5.11",
|
"@tailwindcss/forms": "0.5.11",
|
||||||
"@tanstack/react-query": "5.100.14",
|
"@tanstack/react-query": "5.102.8",
|
||||||
"@tanstack/react-table": "8.21.3",
|
"@tanstack/react-table": "9.2.3",
|
||||||
"@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.20.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,62 +86,62 @@
|
|||||||
"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",
|
||||||
"gpt-tokenizer": "^3.4.0",
|
"gpt-tokenizer": "^4.0.0",
|
||||||
"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.5.0",
|
||||||
"ioredis": "5.11.0",
|
"ioredis": "6.0.0",
|
||||||
"jmespath": "0.16.0",
|
"jmespath": "0.16.0",
|
||||||
"js-yaml": "4.3.1",
|
"js-yaml": "5.4.1",
|
||||||
"jsonwebtoken": "9.0.3",
|
"jsonwebtoken": "9.0.3",
|
||||||
"lucide-react": "1.17.0",
|
"lucide-react": "1.34.0",
|
||||||
"maxmind": "5.0.6",
|
"maxmind": "5.0.7",
|
||||||
"moment": "2.30.1",
|
"moment": "2.30.1",
|
||||||
"next": "16.3.1",
|
"next": "16.3.3",
|
||||||
"next-intl": "4.13.0",
|
"next-intl": "4.14.0",
|
||||||
"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.6",
|
||||||
"oslo": "1.2.1",
|
"oslo": "1.2.1",
|
||||||
"pg": "8.21.0",
|
"pg": "8.23.0",
|
||||||
"posthog-node": "5.35.6",
|
"posthog-node": "5.51.4",
|
||||||
"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.86.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.6.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.2",
|
||||||
"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.3",
|
||||||
"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.22.0",
|
||||||
"@esbuild-plugins/tsconfig-paths": "0.1.2",
|
"@esbuild-plugins/tsconfig-paths": "0.1.2",
|
||||||
"@react-email/ui": "^6.9.2",
|
"@react-email/ui": "^6.9.3",
|
||||||
"@tailwindcss/postcss": "4.3.0",
|
"@tailwindcss/postcss": "4.3.3",
|
||||||
"@tanstack/react-query-devtools": "5.100.14",
|
"@tanstack/react-query-devtools": "5.102.8",
|
||||||
"@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",
|
||||||
@@ -152,36 +152,36 @@
|
|||||||
"@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.4.0",
|
||||||
"@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.23.1",
|
||||||
"@types/react": "19.2.15",
|
"@types/react": "19.2.18",
|
||||||
"@types/react-dom": "19.2.3",
|
"@types/react-dom": "19.2.5",
|
||||||
"@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",
|
||||||
"@types/yargs": "17.0.35",
|
"@types/yargs": "17.0.35",
|
||||||
"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.0",
|
"esbuild": "0.28.2",
|
||||||
"esbuild-node-externals": "1.22.0",
|
"esbuild-node-externals": "2.0.0",
|
||||||
"eslint": "10.4.0",
|
"eslint": "10.9.1",
|
||||||
"eslint-config-next": "16.2.6",
|
"eslint-config-next": "16.3.3",
|
||||||
"postcss": "8.5.23",
|
"postcss": "8.5.26",
|
||||||
"prettier": "3.8.3",
|
"prettier": "3.9.6",
|
||||||
"react-email": "6.5.0",
|
"react-email": "6.9.3",
|
||||||
"tailwindcss": "4.3.0",
|
"tailwindcss": "4.3.3",
|
||||||
"tsc-alias": "1.8.17",
|
"tsc-alias": "1.9.2",
|
||||||
"tsx": "4.22.3",
|
"tsx": "4.23.12",
|
||||||
"typescript": "6.0.3",
|
"typescript": "7.0.2",
|
||||||
"typescript-eslint": "8.60.0"
|
"typescript-eslint": "8.68.0"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"esbuild": "0.28.0",
|
"esbuild": "0.28.2",
|
||||||
"dompurify": "3.4.0",
|
"dompurify": "3.4.0",
|
||||||
"postcss": "8.5.23"
|
"postcss": "8.5.26"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,20 +262,16 @@ export const resourceAiModels = pgTable(
|
|||||||
(t) => [primaryKey({ columns: [t.resourceId, t.modelId] })]
|
(t) => [primaryKey({ columns: [t.resourceId, t.modelId] })]
|
||||||
);
|
);
|
||||||
|
|
||||||
export const labels = pgTable(
|
export const labels = pgTable("labels", {
|
||||||
"labels",
|
labelId: serial("labelId").primaryKey(),
|
||||||
{
|
name: varchar("name").notNull(),
|
||||||
labelId: serial("labelId").primaryKey(),
|
color: varchar("color").notNull(),
|
||||||
name: varchar("name").notNull(),
|
orgId: varchar("orgId")
|
||||||
color: varchar("color").notNull(),
|
.references(() => orgs.orgId, {
|
||||||
orgId: varchar("orgId")
|
onDelete: "cascade"
|
||||||
.references(() => orgs.orgId, {
|
})
|
||||||
onDelete: "cascade"
|
.notNull()
|
||||||
})
|
});
|
||||||
.notNull()
|
|
||||||
},
|
|
||||||
(t) => [index("idx_labels_orgid").on(t.orgId)]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const launcherViews = pgTable("launcherViews", {
|
export const launcherViews = pgTable("launcherViews", {
|
||||||
viewId: serial("viewId").primaryKey(),
|
viewId: serial("viewId").primaryKey(),
|
||||||
@@ -697,19 +693,15 @@ export const twoFactorBackupCodes = pgTable("twoFactorBackupCodes", {
|
|||||||
codeHash: varchar("codeHash").notNull()
|
codeHash: varchar("codeHash").notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const sessions = pgTable(
|
export const sessions = pgTable("session", {
|
||||||
"session",
|
sessionId: varchar("id").primaryKey(),
|
||||||
{
|
userId: varchar("userId")
|
||||||
sessionId: varchar("id").primaryKey(),
|
.notNull()
|
||||||
userId: varchar("userId")
|
.references(() => users.userId, { onDelete: "cascade" }),
|
||||||
.notNull()
|
expiresAt: bigint("expiresAt", { mode: "number" }).notNull(),
|
||||||
.references(() => users.userId, { onDelete: "cascade" }),
|
issuedAt: bigint("issuedAt", { mode: "number" }),
|
||||||
expiresAt: bigint("expiresAt", { mode: "number" }).notNull(),
|
deviceAuthUsed: boolean("deviceAuthUsed").notNull().default(false)
|
||||||
issuedAt: bigint("issuedAt", { mode: "number" }),
|
});
|
||||||
deviceAuthUsed: boolean("deviceAuthUsed").notNull().default(false)
|
|
||||||
},
|
|
||||||
(t) => [index("idx_sessions_userid").on(t.userId)]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const newtSessions = pgTable("newtSession", {
|
export const newtSessions = pgTable("newtSession", {
|
||||||
sessionId: varchar("id").primaryKey(),
|
sessionId: varchar("id").primaryKey(),
|
||||||
@@ -719,26 +711,19 @@ export const newtSessions = pgTable("newtSession", {
|
|||||||
expiresAt: bigint("expiresAt", { mode: "number" }).notNull()
|
expiresAt: bigint("expiresAt", { mode: "number" }).notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const userOrgs = pgTable(
|
export const userOrgs = pgTable("userOrgs", {
|
||||||
"userOrgs",
|
userId: varchar("userId")
|
||||||
{
|
.notNull()
|
||||||
userId: varchar("userId")
|
.references(() => users.userId, { onDelete: "cascade" }),
|
||||||
.notNull()
|
orgId: varchar("orgId")
|
||||||
.references(() => users.userId, { onDelete: "cascade" }),
|
.references(() => orgs.orgId, {
|
||||||
orgId: varchar("orgId")
|
onDelete: "cascade"
|
||||||
.references(() => orgs.orgId, {
|
})
|
||||||
onDelete: "cascade"
|
.notNull(),
|
||||||
})
|
isOwner: boolean("isOwner").notNull().default(false),
|
||||||
.notNull(),
|
autoProvisioned: boolean("autoProvisioned").default(false),
|
||||||
isOwner: boolean("isOwner").notNull().default(false),
|
pamUsername: varchar("pamUsername") // cleaned username for ssh and such
|
||||||
autoProvisioned: boolean("autoProvisioned").default(false),
|
});
|
||||||
pamUsername: varchar("pamUsername") // cleaned username for ssh and such
|
|
||||||
},
|
|
||||||
(t) => [
|
|
||||||
index("idx_userOrgs_userid").on(t.userId),
|
|
||||||
index("idx_userOrgs_orgid").on(t.orgId)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const emailVerificationCodes = pgTable("emailVerificationCodes", {
|
export const emailVerificationCodes = pgTable("emailVerificationCodes", {
|
||||||
codeId: serial("id").primaryKey(),
|
codeId: serial("id").primaryKey(),
|
||||||
@@ -766,26 +751,22 @@ export const actions = pgTable("actions", {
|
|||||||
description: varchar("description")
|
description: varchar("description")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const roles = pgTable(
|
export const roles = pgTable("roles", {
|
||||||
"roles",
|
roleId: serial("roleId").primaryKey(),
|
||||||
{
|
orgId: varchar("orgId")
|
||||||
roleId: serial("roleId").primaryKey(),
|
.references(() => orgs.orgId, {
|
||||||
orgId: varchar("orgId")
|
onDelete: "cascade"
|
||||||
.references(() => orgs.orgId, {
|
})
|
||||||
onDelete: "cascade"
|
.notNull(),
|
||||||
})
|
isAdmin: boolean("isAdmin"),
|
||||||
.notNull(),
|
name: varchar("name").notNull(),
|
||||||
isAdmin: boolean("isAdmin"),
|
description: varchar("description"),
|
||||||
name: varchar("name").notNull(),
|
requireDeviceApproval: boolean("requireDeviceApproval").default(false),
|
||||||
description: varchar("description"),
|
sshSudoMode: varchar("sshSudoMode", { length: 32 }).default("full"), // "none" | "full" | "commands"
|
||||||
requireDeviceApproval: boolean("requireDeviceApproval").default(false),
|
sshSudoCommands: text("sshSudoCommands").default("[]"),
|
||||||
sshSudoMode: varchar("sshSudoMode", { length: 32 }).default("full"), // "none" | "full" | "commands"
|
sshCreateHomeDir: boolean("sshCreateHomeDir").default(true),
|
||||||
sshSudoCommands: text("sshSudoCommands").default("[]"),
|
sshUnixGroups: text("sshUnixGroups").default("[]")
|
||||||
sshCreateHomeDir: boolean("sshCreateHomeDir").default(true),
|
});
|
||||||
sshUnixGroups: text("sshUnixGroups").default("[]")
|
|
||||||
},
|
|
||||||
(t) => [index("idx_roles_orgid").on(t.orgId)]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const userOrgRoles = pgTable(
|
export const userOrgRoles = pgTable(
|
||||||
"userOrgRoles",
|
"userOrgRoles",
|
||||||
@@ -1428,10 +1409,7 @@ export const olms = pgTable(
|
|||||||
}),
|
}),
|
||||||
archived: boolean("archived").notNull().default(false)
|
archived: boolean("archived").notNull().default(false)
|
||||||
},
|
},
|
||||||
(t) => [
|
(t) => [index("idx_olms_clientid").on(t.clientId)]
|
||||||
index("idx_olms_clientid").on(t.clientId),
|
|
||||||
index("idx_olms_userid").on(t.userId)
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export const currentFingerprint = pgTable("currentFingerprint", {
|
export const currentFingerprint = pgTable("currentFingerprint", {
|
||||||
|
|||||||
+266
-335
@@ -99,147 +99,131 @@ export const orgDomains = sqliteTable("orgDomains", {
|
|||||||
.references(() => domains.domainId, { onDelete: "cascade" })
|
.references(() => domains.domainId, { onDelete: "cascade" })
|
||||||
});
|
});
|
||||||
|
|
||||||
export const sites = sqliteTable(
|
export const sites = sqliteTable("sites", {
|
||||||
"sites",
|
siteId: integer("siteId").primaryKey({ autoIncrement: true }),
|
||||||
{
|
orgId: text("orgId")
|
||||||
siteId: integer("siteId").primaryKey({ autoIncrement: true }),
|
.references(() => orgs.orgId, {
|
||||||
orgId: text("orgId")
|
onDelete: "cascade"
|
||||||
.references(() => orgs.orgId, {
|
|
||||||
onDelete: "cascade"
|
|
||||||
})
|
|
||||||
.notNull(),
|
|
||||||
niceId: text("niceId").notNull(),
|
|
||||||
exitNodeId: integer("exitNode").references(() => exitNodes.exitNodeId, {
|
|
||||||
onDelete: "set null"
|
|
||||||
}),
|
|
||||||
networkId: integer("networkId").references(() => networks.networkId, {
|
|
||||||
onDelete: "set null"
|
|
||||||
}),
|
|
||||||
name: text("name").notNull(),
|
|
||||||
pubKey: text("pubKey"),
|
|
||||||
exitNodeSubnet: text("exitNodeSubnet"),
|
|
||||||
megabytesIn: integer("bytesIn").default(0),
|
|
||||||
megabytesOut: integer("bytesOut").default(0),
|
|
||||||
lastBandwidthUpdate: text("lastBandwidthUpdate"),
|
|
||||||
type: text("type").notNull(), // "newt" or "wireguard"
|
|
||||||
online: integer("online", { mode: "boolean" }).notNull().default(false),
|
|
||||||
lastPing: integer("lastPing"),
|
|
||||||
|
|
||||||
// exit node stuff that is how to connect to the site when it has a wg server
|
|
||||||
address: text("address"), // this is the address of the wireguard interface in newt
|
|
||||||
endpoint: text("endpoint"), // this is how to reach gerbil externally - gets put into the wireguard config
|
|
||||||
localEndpoints: text("localEndpoints"), // JSON encoded list of string ips on the local machine to try to connect to
|
|
||||||
publicKey: text("publicKey"), // TODO: Fix typo in publicKey
|
|
||||||
lastHolePunch: integer("lastHolePunch"),
|
|
||||||
listenPort: integer("listenPort"),
|
|
||||||
dockerSocketEnabled: integer("dockerSocketEnabled", { mode: "boolean" })
|
|
||||||
.notNull()
|
|
||||||
.default(true),
|
|
||||||
autoUpdateEnabled: integer("autoUpdateEnabled", { mode: "boolean" })
|
|
||||||
.notNull()
|
|
||||||
.default(false),
|
|
||||||
autoUpdateOverrideOrg: integer("autoUpdateOverrideOrg", {
|
|
||||||
mode: "boolean"
|
|
||||||
})
|
})
|
||||||
.notNull()
|
.notNull(),
|
||||||
.default(false),
|
niceId: text("niceId").notNull(),
|
||||||
status: text("status")
|
exitNodeId: integer("exitNode").references(() => exitNodes.exitNodeId, {
|
||||||
.$type<"pending" | "approved">()
|
onDelete: "set null"
|
||||||
.default("approved")
|
}),
|
||||||
},
|
networkId: integer("networkId").references(() => networks.networkId, {
|
||||||
(table) => [
|
onDelete: "set null"
|
||||||
index("idx_sites_orgId").on(table.orgId)
|
}),
|
||||||
]
|
name: text("name").notNull(),
|
||||||
);
|
pubKey: text("pubKey"),
|
||||||
|
exitNodeSubnet: text("exitNodeSubnet"),
|
||||||
|
megabytesIn: integer("bytesIn").default(0),
|
||||||
|
megabytesOut: integer("bytesOut").default(0),
|
||||||
|
lastBandwidthUpdate: text("lastBandwidthUpdate"),
|
||||||
|
type: text("type").notNull(), // "newt" or "wireguard"
|
||||||
|
online: integer("online", { mode: "boolean" }).notNull().default(false),
|
||||||
|
lastPing: integer("lastPing"),
|
||||||
|
|
||||||
export const resources = sqliteTable(
|
// exit node stuff that is how to connect to the site when it has a wg server
|
||||||
"resources",
|
address: text("address"), // this is the address of the wireguard interface in newt
|
||||||
{
|
endpoint: text("endpoint"), // this is how to reach gerbil externally - gets put into the wireguard config
|
||||||
resourceId: integer("resourceId").primaryKey({ autoIncrement: true }),
|
localEndpoints: text("localEndpoints"), // JSON encoded list of string ips on the local machine to try to connect to
|
||||||
resourcePolicyId: integer("resourcePolicyId").references(
|
publicKey: text("publicKey"), // TODO: Fix typo in publicKey
|
||||||
() => resourcePolicies.resourcePolicyId,
|
lastHolePunch: integer("lastHolePunch"),
|
||||||
{ onDelete: "set null" }
|
listenPort: integer("listenPort"),
|
||||||
),
|
dockerSocketEnabled: integer("dockerSocketEnabled", { mode: "boolean" })
|
||||||
defaultResourcePolicyId: integer("defaultResourcePolicyId").references(
|
.notNull()
|
||||||
() => resourcePolicies.resourcePolicyId,
|
.default(true),
|
||||||
{
|
autoUpdateEnabled: integer("autoUpdateEnabled", { mode: "boolean" })
|
||||||
onDelete: "restrict"
|
.notNull()
|
||||||
}
|
.default(false),
|
||||||
),
|
autoUpdateOverrideOrg: integer("autoUpdateOverrideOrg", {
|
||||||
resourceGuid: text("resourceGuid", { length: 36 })
|
mode: "boolean"
|
||||||
.unique()
|
})
|
||||||
.notNull()
|
.notNull()
|
||||||
.$defaultFn(() => randomUUID()),
|
.default(false),
|
||||||
orgId: text("orgId")
|
status: text("status").$type<"pending" | "approved">().default("approved")
|
||||||
.references(() => orgs.orgId, {
|
});
|
||||||
onDelete: "cascade"
|
|
||||||
})
|
export const resources = sqliteTable("resources", {
|
||||||
.notNull(),
|
resourceId: integer("resourceId").primaryKey({ autoIncrement: true }),
|
||||||
niceId: text("niceId").notNull(),
|
resourcePolicyId: integer("resourcePolicyId").references(
|
||||||
name: text("name").notNull(),
|
() => resourcePolicies.resourcePolicyId,
|
||||||
subdomain: text("subdomain"),
|
{ onDelete: "set null" }
|
||||||
fullDomain: text("fullDomain"),
|
),
|
||||||
domainId: text("domainId").references(() => domains.domainId, {
|
defaultResourcePolicyId: integer("defaultResourcePolicyId").references(
|
||||||
onDelete: "set null"
|
() => resourcePolicies.resourcePolicyId,
|
||||||
}),
|
{
|
||||||
ssl: integer("ssl", { mode: "boolean" }).notNull().default(false),
|
onDelete: "restrict"
|
||||||
blockAccess: integer("blockAccess", { mode: "boolean" })
|
}
|
||||||
.notNull()
|
),
|
||||||
.default(false),
|
resourceGuid: text("resourceGuid", { length: 36 })
|
||||||
proxyPort: integer("proxyPort"),
|
.unique()
|
||||||
sso: integer("sso", { mode: "boolean" }),
|
.notNull()
|
||||||
emailWhitelistEnabled: integer("emailWhitelistEnabled", {
|
.$defaultFn(() => randomUUID()),
|
||||||
mode: "boolean"
|
orgId: text("orgId")
|
||||||
}),
|
.references(() => orgs.orgId, {
|
||||||
applyRules: integer("applyRules", { mode: "boolean" }),
|
onDelete: "cascade"
|
||||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
|
||||||
stickySession: integer("stickySession", { mode: "boolean" })
|
|
||||||
.notNull()
|
|
||||||
.default(false),
|
|
||||||
tlsServerName: text("tlsServerName"),
|
|
||||||
setHostHeader: text("setHostHeader"),
|
|
||||||
enableProxy: integer("enableProxy", { mode: "boolean" }).default(true),
|
|
||||||
skipToIdpId: integer("skipToIdpId").references(() => idp.idpId, {
|
|
||||||
onDelete: "set null"
|
|
||||||
}),
|
|
||||||
headers: text("headers"), // comma-separated list of headers to add to the request
|
|
||||||
proxyProtocol: integer("proxyProtocol", { mode: "boolean" })
|
|
||||||
.notNull()
|
|
||||||
.default(false),
|
|
||||||
proxyProtocolVersion: integer("proxyProtocolVersion").default(1),
|
|
||||||
maintenanceModeEnabled: integer("maintenanceModeEnabled", {
|
|
||||||
mode: "boolean"
|
|
||||||
})
|
})
|
||||||
.notNull()
|
.notNull(),
|
||||||
.default(false),
|
niceId: text("niceId").notNull(),
|
||||||
maintenanceModeType: text("maintenanceModeType", {
|
name: text("name").notNull(),
|
||||||
enum: ["forced", "automatic"]
|
subdomain: text("subdomain"),
|
||||||
}).default("forced"), // "forced" = always show, "automatic" = only when down
|
fullDomain: text("fullDomain"),
|
||||||
maintenanceTitle: text("maintenanceTitle"),
|
domainId: text("domainId").references(() => domains.domainId, {
|
||||||
maintenanceMessage: text("maintenanceMessage"),
|
onDelete: "set null"
|
||||||
maintenanceEstimatedTime: text("maintenanceEstimatedTime"),
|
}),
|
||||||
postAuthPath: text("postAuthPath"),
|
ssl: integer("ssl", { mode: "boolean" }).notNull().default(false),
|
||||||
health: text("health").default("unknown"), // "healthy", "unhealthy", "unknown"
|
blockAccess: integer("blockAccess", { mode: "boolean" })
|
||||||
wildcard: integer("wildcard", { mode: "boolean" }).notNull().default(false),
|
.notNull()
|
||||||
mode: text("mode")
|
.default(false),
|
||||||
.default("http")
|
proxyPort: integer("proxyPort"),
|
||||||
.$type<"rdp" | "ssh" | "http" | "vnc" | "inference" | "tcp" | "udp">()
|
sso: integer("sso", { mode: "boolean" }),
|
||||||
.notNull(), // rdp, ssh, http, vnc, inference
|
emailWhitelistEnabled: integer("emailWhitelistEnabled", {
|
||||||
pamMode: text("pamMode")
|
mode: "boolean"
|
||||||
.$type<"passthrough" | "push">()
|
}),
|
||||||
.default("passthrough"),
|
applyRules: integer("applyRules", { mode: "boolean" }),
|
||||||
authDaemonMode: text("authDaemonMode")
|
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||||
.$type<"site" | "remote" | "native">()
|
stickySession: integer("stickySession", { mode: "boolean" })
|
||||||
.default("site"),
|
.notNull()
|
||||||
authDaemonPort: integer("authDaemonPort").default(22123),
|
.default(false),
|
||||||
status: text("status")
|
tlsServerName: text("tlsServerName"),
|
||||||
.$type<"pending" | "approved">()
|
setHostHeader: text("setHostHeader"),
|
||||||
.default("approved")
|
enableProxy: integer("enableProxy", { mode: "boolean" }).default(true),
|
||||||
},
|
skipToIdpId: integer("skipToIdpId").references(() => idp.idpId, {
|
||||||
(table) => [
|
onDelete: "set null"
|
||||||
index("idx_resources_orgId").on(table.orgId)
|
}),
|
||||||
]
|
headers: text("headers"), // comma-separated list of headers to add to the request
|
||||||
);
|
proxyProtocol: integer("proxyProtocol", { mode: "boolean" })
|
||||||
|
.notNull()
|
||||||
|
.default(false),
|
||||||
|
proxyProtocolVersion: integer("proxyProtocolVersion").default(1),
|
||||||
|
maintenanceModeEnabled: integer("maintenanceModeEnabled", {
|
||||||
|
mode: "boolean"
|
||||||
|
})
|
||||||
|
.notNull()
|
||||||
|
.default(false),
|
||||||
|
maintenanceModeType: text("maintenanceModeType", {
|
||||||
|
enum: ["forced", "automatic"]
|
||||||
|
}).default("forced"), // "forced" = always show, "automatic" = only when down
|
||||||
|
maintenanceTitle: text("maintenanceTitle"),
|
||||||
|
maintenanceMessage: text("maintenanceMessage"),
|
||||||
|
maintenanceEstimatedTime: text("maintenanceEstimatedTime"),
|
||||||
|
postAuthPath: text("postAuthPath"),
|
||||||
|
health: text("health").default("unknown"), // "healthy", "unhealthy", "unknown"
|
||||||
|
wildcard: integer("wildcard", { mode: "boolean" }).notNull().default(false),
|
||||||
|
mode: text("mode")
|
||||||
|
.default("http")
|
||||||
|
.$type<"rdp" | "ssh" | "http" | "vnc" | "inference" | "tcp" | "udp">()
|
||||||
|
.notNull(), // rdp, ssh, http, vnc, inference
|
||||||
|
pamMode: text("pamMode")
|
||||||
|
.$type<"passthrough" | "push">()
|
||||||
|
.default("passthrough"),
|
||||||
|
authDaemonMode: text("authDaemonMode")
|
||||||
|
.$type<"site" | "remote" | "native">()
|
||||||
|
.default("site"),
|
||||||
|
authDaemonPort: integer("authDaemonPort").default(22123),
|
||||||
|
status: text("status").$type<"pending" | "approved">().default("approved")
|
||||||
|
});
|
||||||
|
|
||||||
export const resourceAiProviders = sqliteTable(
|
export const resourceAiProviders = sqliteTable(
|
||||||
"resourceAiProviders",
|
"resourceAiProviders",
|
||||||
@@ -276,22 +260,16 @@ export const resourceAiModels = sqliteTable(
|
|||||||
(t) => [primaryKey({ columns: [t.resourceId, t.modelId] })]
|
(t) => [primaryKey({ columns: [t.resourceId, t.modelId] })]
|
||||||
);
|
);
|
||||||
|
|
||||||
export const labels = sqliteTable(
|
export const labels = sqliteTable("labels", {
|
||||||
"labels",
|
labelId: integer("labelId").primaryKey({ autoIncrement: true }),
|
||||||
{
|
name: text("name").notNull(),
|
||||||
labelId: integer("labelId").primaryKey({ autoIncrement: true }),
|
color: text("color").notNull(),
|
||||||
name: text("name").notNull(),
|
orgId: text("orgId")
|
||||||
color: text("color").notNull(),
|
.references(() => orgs.orgId, {
|
||||||
orgId: text("orgId")
|
onDelete: "cascade"
|
||||||
.references(() => orgs.orgId, {
|
})
|
||||||
onDelete: "cascade"
|
.notNull()
|
||||||
})
|
});
|
||||||
.notNull()
|
|
||||||
},
|
|
||||||
(table) => [
|
|
||||||
index("idx_labels_orgId").on(table.orgId)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const launcherViews = sqliteTable("launcherViews", {
|
export const launcherViews = sqliteTable("launcherViews", {
|
||||||
viewId: integer("viewId").primaryKey({ autoIncrement: true }),
|
viewId: integer("viewId").primaryKey({ autoIncrement: true }),
|
||||||
@@ -388,44 +366,35 @@ export const clientLabels = sqliteTable(
|
|||||||
(t) => [unique("client_label_uniq").on(t.clientId, t.labelId)]
|
(t) => [unique("client_label_uniq").on(t.clientId, t.labelId)]
|
||||||
);
|
);
|
||||||
|
|
||||||
export const targets = sqliteTable(
|
export const targets = sqliteTable("targets", {
|
||||||
"targets",
|
targetId: integer("targetId").primaryKey({ autoIncrement: true }),
|
||||||
{
|
resourceId: integer("resourceId").references(() => resources.resourceId, {
|
||||||
targetId: integer("targetId").primaryKey({ autoIncrement: true }),
|
onDelete: "cascade"
|
||||||
resourceId: integer("resourceId").references(
|
}),
|
||||||
() => resources.resourceId,
|
providerId: integer("providerId").references(() => aiProviders.providerId, {
|
||||||
{ onDelete: "cascade" }
|
onDelete: "cascade"
|
||||||
),
|
}),
|
||||||
providerId: integer("providerId").references(
|
siteId: integer("siteId")
|
||||||
() => aiProviders.providerId,
|
.references(() => sites.siteId, {
|
||||||
{ onDelete: "cascade" }
|
onDelete: "cascade"
|
||||||
),
|
})
|
||||||
siteId: integer("siteId")
|
.notNull(),
|
||||||
.references(() => sites.siteId, {
|
ip: text("ip").notNull(),
|
||||||
onDelete: "cascade"
|
method: text("method"),
|
||||||
})
|
port: integer("port").notNull(),
|
||||||
.notNull(),
|
internalPort: integer("internalPort"),
|
||||||
ip: text("ip").notNull(),
|
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||||
method: text("method"),
|
path: text("path"),
|
||||||
port: integer("port").notNull(),
|
pathMatchType: text("pathMatchType"), // exact, prefix, regex
|
||||||
internalPort: integer("internalPort"),
|
rewritePath: text("rewritePath"), // if set, rewrites the path to this value before sending to the target
|
||||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
rewritePathType: text("rewritePathType"), // exact, prefix, regex, stripPrefix
|
||||||
path: text("path"),
|
priority: integer("priority").notNull().default(100),
|
||||||
pathMatchType: text("pathMatchType"), // exact, prefix, regex
|
mode: text("mode")
|
||||||
rewritePath: text("rewritePath"), // if set, rewrites the path to this value before sending to the target
|
.$type<"http" | "tcp" | "udp" | "ssh" | "rdp" | "vnc">()
|
||||||
rewritePathType: text("rewritePathType"), // exact, prefix, regex, stripPrefix
|
.notNull()
|
||||||
priority: integer("priority").notNull().default(100),
|
.default("http"),
|
||||||
mode: text("mode")
|
authToken: text("authToken")
|
||||||
.$type<"http" | "tcp" | "udp" | "ssh" | "rdp" | "vnc">()
|
});
|
||||||
.notNull()
|
|
||||||
.default("http"),
|
|
||||||
authToken: text("authToken")
|
|
||||||
},
|
|
||||||
(table) => [
|
|
||||||
index("idx_targets_resourceId").on(table.resourceId),
|
|
||||||
index("idx_targets_siteId").on(table.siteId)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const targetHealthCheck = sqliteTable("targetHealthCheck", {
|
export const targetHealthCheck = sqliteTable("targetHealthCheck", {
|
||||||
targetHealthCheckId: integer("targetHealthCheckId").primaryKey({
|
targetHealthCheckId: integer("targetHealthCheckId").primaryKey({
|
||||||
@@ -694,63 +663,50 @@ export const setupTokens = sqliteTable("setupTokens", {
|
|||||||
dateUsed: text("dateUsed")
|
dateUsed: text("dateUsed")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const newts = sqliteTable(
|
export const newts = sqliteTable("newt", {
|
||||||
"newt",
|
newtId: text("id").primaryKey(),
|
||||||
{
|
secretHash: text("secretHash").notNull(),
|
||||||
newtId: text("id").primaryKey(),
|
dateCreated: text("dateCreated").notNull(),
|
||||||
secretHash: text("secretHash").notNull(),
|
version: text("version"),
|
||||||
dateCreated: text("dateCreated").notNull(),
|
siteId: integer("siteId").references(() => sites.siteId, {
|
||||||
version: text("version"),
|
onDelete: "cascade"
|
||||||
siteId: integer("siteId").references(() => sites.siteId, {
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
export const clients = sqliteTable("clients", {
|
||||||
|
clientId: integer("clientId").primaryKey({ autoIncrement: true }),
|
||||||
|
orgId: text("orgId")
|
||||||
|
.references(() => orgs.orgId, {
|
||||||
onDelete: "cascade"
|
onDelete: "cascade"
|
||||||
})
|
})
|
||||||
},
|
.notNull(),
|
||||||
(table) => [
|
exitNodeId: integer("exitNode").references(() => exitNodes.exitNodeId, {
|
||||||
index("idx_newts_siteId").on(table.siteId)
|
onDelete: "set null"
|
||||||
]
|
}),
|
||||||
);
|
userId: text("userId").references(() => users.userId, {
|
||||||
|
// optionally tied to a user and in this case delete when the user deletes
|
||||||
export const clients = sqliteTable(
|
onDelete: "cascade"
|
||||||
"clients",
|
}),
|
||||||
{
|
niceId: text("niceId").notNull(),
|
||||||
clientId: integer("clientId").primaryKey({ autoIncrement: true }),
|
name: text("name").notNull(),
|
||||||
orgId: text("orgId")
|
pubKey: text("pubKey"),
|
||||||
.references(() => orgs.orgId, {
|
olmId: text("olmId"), // to lock it to a specific olm optionally
|
||||||
onDelete: "cascade"
|
subnet: text("subnet").notNull(),
|
||||||
})
|
exitNodeSubnet: text("exitNodeSubnet"), // this is the subnet when connecting to an exit node
|
||||||
.notNull(),
|
megabytesIn: integer("bytesIn"),
|
||||||
exitNodeId: integer("exitNode").references(() => exitNodes.exitNodeId, {
|
megabytesOut: integer("bytesOut"),
|
||||||
onDelete: "set null"
|
lastBandwidthUpdate: text("lastBandwidthUpdate"),
|
||||||
}),
|
lastPing: integer("lastPing"),
|
||||||
userId: text("userId").references(() => users.userId, {
|
type: text("type").notNull(), // "olm"
|
||||||
// optionally tied to a user and in this case delete when the user deletes
|
online: integer("online", { mode: "boolean" }).notNull().default(false),
|
||||||
onDelete: "cascade"
|
// endpoint: text("endpoint"),
|
||||||
}),
|
lastHolePunch: integer("lastHolePunch"),
|
||||||
niceId: text("niceId").notNull(),
|
archived: integer("archived", { mode: "boolean" }).notNull().default(false),
|
||||||
name: text("name").notNull(),
|
blocked: integer("blocked", { mode: "boolean" }).notNull().default(false),
|
||||||
pubKey: text("pubKey"),
|
approvalState: text("approvalState").$type<
|
||||||
olmId: text("olmId"), // to lock it to a specific olm optionally
|
"pending" | "approved" | "denied"
|
||||||
subnet: text("subnet").notNull(),
|
>()
|
||||||
exitNodeSubnet: text("exitNodeSubnet"), // this is the subnet when connecting to an exit node
|
});
|
||||||
megabytesIn: integer("bytesIn"),
|
|
||||||
megabytesOut: integer("bytesOut"),
|
|
||||||
lastBandwidthUpdate: text("lastBandwidthUpdate"),
|
|
||||||
lastPing: integer("lastPing"),
|
|
||||||
type: text("type").notNull(), // "olm"
|
|
||||||
online: integer("online", { mode: "boolean" }).notNull().default(false),
|
|
||||||
// endpoint: text("endpoint"),
|
|
||||||
lastHolePunch: integer("lastHolePunch"),
|
|
||||||
archived: integer("archived", { mode: "boolean" }).notNull().default(false),
|
|
||||||
blocked: integer("blocked", { mode: "boolean" }).notNull().default(false),
|
|
||||||
approvalState: text("approvalState").$type<
|
|
||||||
"pending" | "approved" | "denied"
|
|
||||||
>()
|
|
||||||
},
|
|
||||||
(table) => [
|
|
||||||
index("idx_clients_orgId").on(table.orgId),
|
|
||||||
index("idx_clients_userId").on(table.userId)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const clientSitesAssociationsCache = sqliteTable(
|
export const clientSitesAssociationsCache = sqliteTable(
|
||||||
"clientSitesAssociationsCache",
|
"clientSitesAssociationsCache",
|
||||||
@@ -778,29 +734,23 @@ export const clientSiteResourcesAssociationsCache = sqliteTable(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const olms = sqliteTable(
|
export const olms = sqliteTable("olms", {
|
||||||
"olms",
|
olmId: text("id").primaryKey(),
|
||||||
{
|
secretHash: text("secretHash").notNull(),
|
||||||
olmId: text("id").primaryKey(),
|
dateCreated: text("dateCreated").notNull(),
|
||||||
secretHash: text("secretHash").notNull(),
|
version: text("version"),
|
||||||
dateCreated: text("dateCreated").notNull(),
|
agent: text("agent"),
|
||||||
version: text("version"),
|
name: text("name"),
|
||||||
agent: text("agent"),
|
clientId: integer("clientId").references(() => clients.clientId, {
|
||||||
name: text("name"),
|
// we will switch this depending on the current org it wants to connect to
|
||||||
clientId: integer("clientId").references(() => clients.clientId, {
|
onDelete: "set null"
|
||||||
// we will switch this depending on the current org it wants to connect to
|
}),
|
||||||
onDelete: "set null"
|
userId: text("userId").references(() => users.userId, {
|
||||||
}),
|
// optionally tied to a user and in this case delete when the user deletes
|
||||||
userId: text("userId").references(() => users.userId, {
|
onDelete: "cascade"
|
||||||
// optionally tied to a user and in this case delete when the user deletes
|
}),
|
||||||
onDelete: "cascade"
|
archived: integer("archived", { mode: "boolean" }).notNull().default(false)
|
||||||
}),
|
});
|
||||||
archived: integer("archived", { mode: "boolean" }).notNull().default(false)
|
|
||||||
},
|
|
||||||
(table) => [
|
|
||||||
index("idx_olms_userId").on(table.userId)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const currentFingerprint = sqliteTable("currentFingerprint", {
|
export const currentFingerprint = sqliteTable("currentFingerprint", {
|
||||||
fingerprintId: integer("id").primaryKey({ autoIncrement: true }),
|
fingerprintId: integer("id").primaryKey({ autoIncrement: true }),
|
||||||
@@ -962,23 +912,17 @@ export const twoFactorBackupCodes = sqliteTable("twoFactorBackupCodes", {
|
|||||||
codeHash: text("codeHash").notNull()
|
codeHash: text("codeHash").notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const sessions = sqliteTable(
|
export const sessions = sqliteTable("session", {
|
||||||
"session",
|
sessionId: text("id").primaryKey(),
|
||||||
{
|
userId: text("userId")
|
||||||
sessionId: text("id").primaryKey(),
|
.notNull()
|
||||||
userId: text("userId")
|
.references(() => users.userId, { onDelete: "cascade" }),
|
||||||
.notNull()
|
expiresAt: integer("expiresAt").notNull(),
|
||||||
.references(() => users.userId, { onDelete: "cascade" }),
|
issuedAt: integer("issuedAt"),
|
||||||
expiresAt: integer("expiresAt").notNull(),
|
deviceAuthUsed: integer("deviceAuthUsed", { mode: "boolean" })
|
||||||
issuedAt: integer("issuedAt"),
|
.notNull()
|
||||||
deviceAuthUsed: integer("deviceAuthUsed", { mode: "boolean" })
|
.default(false)
|
||||||
.notNull()
|
});
|
||||||
.default(false)
|
|
||||||
},
|
|
||||||
(table) => [
|
|
||||||
index("idx_sessions_userId").on(table.userId)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const newtSessions = sqliteTable("newtSession", {
|
export const newtSessions = sqliteTable("newtSession", {
|
||||||
sessionId: text("id").primaryKey(),
|
sessionId: text("id").primaryKey(),
|
||||||
@@ -996,28 +940,21 @@ export const olmSessions = sqliteTable("clientSession", {
|
|||||||
expiresAt: integer("expiresAt").notNull()
|
expiresAt: integer("expiresAt").notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const userOrgs = sqliteTable(
|
export const userOrgs = sqliteTable("userOrgs", {
|
||||||
"userOrgs",
|
userId: text("userId")
|
||||||
{
|
.notNull()
|
||||||
userId: text("userId")
|
.references(() => users.userId, { onDelete: "cascade" }),
|
||||||
.notNull()
|
orgId: text("orgId")
|
||||||
.references(() => users.userId, { onDelete: "cascade" }),
|
.references(() => orgs.orgId, {
|
||||||
orgId: text("orgId")
|
onDelete: "cascade"
|
||||||
.references(() => orgs.orgId, {
|
})
|
||||||
onDelete: "cascade"
|
.notNull(),
|
||||||
})
|
isOwner: integer("isOwner", { mode: "boolean" }).notNull().default(false),
|
||||||
.notNull(),
|
autoProvisioned: integer("autoProvisioned", {
|
||||||
isOwner: integer("isOwner", { mode: "boolean" }).notNull().default(false),
|
mode: "boolean"
|
||||||
autoProvisioned: integer("autoProvisioned", {
|
}).default(false),
|
||||||
mode: "boolean"
|
pamUsername: text("pamUsername") // cleaned username for ssh and such
|
||||||
}).default(false),
|
});
|
||||||
pamUsername: text("pamUsername") // cleaned username for ssh and such
|
|
||||||
},
|
|
||||||
(table) => [
|
|
||||||
index("idx_userOrgs_userId").on(table.userId),
|
|
||||||
index("idx_userOrgs_orgId").on(table.orgId)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const emailVerificationCodes = sqliteTable("emailVerificationCodes", {
|
export const emailVerificationCodes = sqliteTable("emailVerificationCodes", {
|
||||||
codeId: integer("id").primaryKey({ autoIncrement: true }),
|
codeId: integer("id").primaryKey({ autoIncrement: true }),
|
||||||
@@ -1045,32 +982,26 @@ export const actions = sqliteTable("actions", {
|
|||||||
description: text("description")
|
description: text("description")
|
||||||
});
|
});
|
||||||
|
|
||||||
export const roles = sqliteTable(
|
export const roles = sqliteTable("roles", {
|
||||||
"roles",
|
roleId: integer("roleId").primaryKey({ autoIncrement: true }),
|
||||||
{
|
orgId: text("orgId")
|
||||||
roleId: integer("roleId").primaryKey({ autoIncrement: true }),
|
.references(() => orgs.orgId, {
|
||||||
orgId: text("orgId")
|
onDelete: "cascade"
|
||||||
.references(() => orgs.orgId, {
|
})
|
||||||
onDelete: "cascade"
|
.notNull(),
|
||||||
})
|
isAdmin: integer("isAdmin", { mode: "boolean" }),
|
||||||
.notNull(),
|
name: text("name").notNull(),
|
||||||
isAdmin: integer("isAdmin", { mode: "boolean" }),
|
description: text("description"),
|
||||||
name: text("name").notNull(),
|
requireDeviceApproval: integer("requireDeviceApproval", {
|
||||||
description: text("description"),
|
mode: "boolean"
|
||||||
requireDeviceApproval: integer("requireDeviceApproval", {
|
}).default(false),
|
||||||
mode: "boolean"
|
sshSudoMode: text("sshSudoMode").default("full"), // "none" | "full" | "commands"
|
||||||
}).default(false),
|
sshSudoCommands: text("sshSudoCommands").default("[]"),
|
||||||
sshSudoMode: text("sshSudoMode").default("full"), // "none" | "full" | "commands"
|
sshCreateHomeDir: integer("sshCreateHomeDir", { mode: "boolean" }).default(
|
||||||
sshSudoCommands: text("sshSudoCommands").default("[]"),
|
true
|
||||||
sshCreateHomeDir: integer("sshCreateHomeDir", { mode: "boolean" }).default(
|
),
|
||||||
true
|
sshUnixGroups: text("sshUnixGroups").default("[]")
|
||||||
),
|
});
|
||||||
sshUnixGroups: text("sshUnixGroups").default("[]")
|
|
||||||
},
|
|
||||||
(table) => [
|
|
||||||
index("idx_roles_orgId").on(table.orgId)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
export const userOrgRoles = sqliteTable(
|
export const userOrgRoles = sqliteTable(
|
||||||
"userOrgRoles",
|
"userOrgRoles",
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ export const AuthSchema = z.object({
|
|||||||
export const RuleSchema = z
|
export const RuleSchema = z
|
||||||
.object({
|
.object({
|
||||||
action: z.enum(["allow", "deny", "pass"]),
|
action: z.enum(["allow", "deny", "pass"]),
|
||||||
match: z.enum(["cidr", "path", "ip", "country", "country_is_not", "asn", "region"]),
|
match: z.enum(["cidr", "path", "ip", "country", "asn", "region"]),
|
||||||
value: z.coerce.string(),
|
value: z.coerce.string(),
|
||||||
priority: z.int().optional(),
|
priority: z.int().optional(),
|
||||||
enabled: z.boolean().optional().default(true)
|
enabled: z.boolean().optional().default(true)
|
||||||
@@ -136,7 +136,7 @@ export const RuleSchema = z
|
|||||||
)
|
)
|
||||||
.refine(
|
.refine(
|
||||||
(rule) => {
|
(rule) => {
|
||||||
if (rule.match === "country" || rule.match === "country_is_not") {
|
if (rule.match === "country") {
|
||||||
if (!hasMaxmindCountryDb) {
|
if (!hasMaxmindCountryDb) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-10
@@ -31,6 +31,7 @@ export async function validateAndConstructDomain(
|
|||||||
subdomain?: string | null
|
subdomain?: string | null
|
||||||
): Promise<DomainValidationResult> {
|
): Promise<DomainValidationResult> {
|
||||||
try {
|
try {
|
||||||
|
// Query domain with organization access check
|
||||||
const [domainRes] = await db
|
const [domainRes] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(domains)
|
.from(domains)
|
||||||
@@ -41,10 +42,6 @@ export async function validateAndConstructDomain(
|
|||||||
eq(orgDomains.orgId, orgId),
|
eq(orgDomains.orgId, orgId),
|
||||||
eq(orgDomains.domainId, domainId)
|
eq(orgDomains.domainId, domainId)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
.leftJoin(
|
|
||||||
domainNamespaces,
|
|
||||||
eq(domainNamespaces.domainId, domainId)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check if domain exists
|
// Check if domain exists
|
||||||
@@ -55,7 +52,7 @@ export async function validateAndConstructDomain(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!domainRes.orgDomains && !domainRes.domainNamespaces) {
|
if (!domainRes.orgDomains) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: `Organization does not have access to domain with ID ${domainId}`
|
error: `Organization does not have access to domain with ID ${domainId}`
|
||||||
@@ -86,11 +83,19 @@ export async function validateAndConstructDomain(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wildcard subdomains are not allowed on namespace (provided/free) domains
|
// Wildcard subdomains are not allowed on namespace (provided/free) domains
|
||||||
if (isWildcard && domainRes.domainNamespaces) {
|
if (isWildcard) {
|
||||||
return {
|
const [namespaceDomain] = await db
|
||||||
success: false,
|
.select()
|
||||||
error: "Wildcard subdomains are not supported for provided or free domains. Use a specific subdomain instead."
|
.from(domainNamespaces)
|
||||||
};
|
.where(eq(domainNamespaces.domainId, domainId))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (namespaceDomain) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: "Wildcard subdomains are not supported for provided or free domains. Use a specific subdomain instead."
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -68,11 +68,6 @@ export async function verifyApiKeyAccessTokenAccess(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apiKey.isRoot) {
|
|
||||||
// Root keys can access any access token in any org
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!resource.orgId) {
|
if (!resource.orgId) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
|
|||||||
@@ -149,8 +149,12 @@ LQIDAQAB
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Count used sites and users for license comparison
|
// Count used sites and users for license comparison
|
||||||
const [siteCountRes] = await db.select({ value: count() }).from(sites);
|
const [siteCountRes] = await db
|
||||||
const [userCountRes] = await db.select({ value: count() }).from(users);
|
.select({ value: count() })
|
||||||
|
.from(sites);
|
||||||
|
const [userCountRes] = await db
|
||||||
|
.select({ value: count() })
|
||||||
|
.from(users);
|
||||||
|
|
||||||
const status: LicenseStatus = {
|
const status: LicenseStatus = {
|
||||||
hostId: this.hostMeta.hostMetaId,
|
hostId: this.hostMeta.hostMetaId,
|
||||||
@@ -272,13 +276,10 @@ LQIDAQAB
|
|||||||
logger.error(
|
logger.error(
|
||||||
`Allowing failure. Will retry one more time at next run interval.`
|
`Allowing failure. Will retry one more time at next run interval.`
|
||||||
);
|
);
|
||||||
// Fall back to last known good status if we have
|
// return last known good status
|
||||||
// one cached; otherwise return the freshly built
|
return this.statusCache.get(
|
||||||
// status (with defaults) rather than undefined.
|
|
||||||
const lastKnownStatus = this.statusCache.get(
|
|
||||||
this.statusKey
|
this.statusKey
|
||||||
) as LicenseStatus | undefined;
|
) as LicenseStatus;
|
||||||
return lastKnownStatus ?? status;
|
|
||||||
} else {
|
} else {
|
||||||
// Subsequent failures: fail abruptly
|
// Subsequent failures: fail abruptly
|
||||||
throw e;
|
throw e;
|
||||||
@@ -367,7 +368,10 @@ LQIDAQAB
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only consider quantity if defined and >= 0 (quantity = users, quantity_2 = sites)
|
// Only consider quantity if defined and >= 0 (quantity = users, quantity_2 = sites)
|
||||||
if (cached.quantity_2 !== undefined && cached.quantity_2 >= 0) {
|
if (
|
||||||
|
cached.quantity_2 !== undefined &&
|
||||||
|
cached.quantity_2 >= 0
|
||||||
|
) {
|
||||||
status.maxSites =
|
status.maxSites =
|
||||||
(status.maxSites ?? 0) + cached.quantity_2;
|
(status.maxSites ?? 0) + cached.quantity_2;
|
||||||
}
|
}
|
||||||
@@ -557,7 +561,7 @@ LQIDAQAB
|
|||||||
// Calculate exponential backoff delay
|
// Calculate exponential backoff delay
|
||||||
const retryDelay = Math.floor(
|
const retryDelay = Math.floor(
|
||||||
initialRetryDelay *
|
initialRetryDelay *
|
||||||
Math.pow(exponentialFactor, attempt - 1)
|
Math.pow(exponentialFactor, attempt - 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|||||||
@@ -88,27 +88,7 @@ export const queryAccessAuditLogsQuery = z.object({
|
|||||||
.optional()
|
.optional()
|
||||||
.default("0")
|
.default("0")
|
||||||
.transform(Number)
|
.transform(Number)
|
||||||
.pipe(z.int().nonnegative()),
|
.pipe(z.int().nonnegative())
|
||||||
ip: z
|
|
||||||
.preprocess((val) => {
|
|
||||||
if (val === undefined || val === null || val === "") {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (Array.isArray(val)) {
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
// the array is returned as this
|
|
||||||
if (typeof val === "string") {
|
|
||||||
return val.split(",");
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}, z.array(z.string()))
|
|
||||||
.optional()
|
|
||||||
.catch([])
|
|
||||||
.openapi({
|
|
||||||
type: "array",
|
|
||||||
description: "Filter by IP adresses"
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const queryAccessAuditLogsParams = z.object({
|
export const queryAccessAuditLogsParams = z.object({
|
||||||
@@ -154,9 +134,6 @@ function getWhere(data: Q) {
|
|||||||
data.type ? eq(accessAuditLog.type, data.type) : undefined,
|
data.type ? eq(accessAuditLog.type, data.type) : undefined,
|
||||||
data.action !== undefined
|
data.action !== undefined
|
||||||
? eq(accessAuditLog.action, data.action)
|
? eq(accessAuditLog.action, data.action)
|
||||||
: undefined,
|
|
||||||
data.ip && data.ip.length > 0
|
|
||||||
? inArray(accessAuditLog.ip, data.ip)
|
|
||||||
: undefined
|
: undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ import {
|
|||||||
handleRemoteExitNodePingMessage
|
handleRemoteExitNodePingMessage
|
||||||
} from "#private/routers/remoteExitNode";
|
} from "#private/routers/remoteExitNode";
|
||||||
import { MessageHandler } from "@server/routers/ws";
|
import { MessageHandler } from "@server/routers/ws";
|
||||||
import { handleConnectionLogMessage } from "#private/routers/newt";
|
import {
|
||||||
|
handleConnectionLogMessage,
|
||||||
|
} from "#private/routers/newt";
|
||||||
|
|
||||||
export const messageHandlers: Record<string, MessageHandler> = {
|
export const messageHandlers: Record<string, MessageHandler> = {
|
||||||
"remoteExitNode/register": handleRemoteExitNodeRegisterMessage,
|
"remoteExitNode/register": handleRemoteExitNodeRegisterMessage,
|
||||||
"remoteExitNode/ping": handleRemoteExitNodePingMessage,
|
"remoteExitNode/ping": handleRemoteExitNodePingMessage,
|
||||||
"newt/access-log": handleConnectionLogMessage
|
"newt/access-log": handleConnectionLogMessage,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -81,27 +81,7 @@ export const queryAccessAuditLogsQuery = z.strictObject({
|
|||||||
.optional()
|
.optional()
|
||||||
.default("0")
|
.default("0")
|
||||||
.transform(Number)
|
.transform(Number)
|
||||||
.pipe(z.int().nonnegative()),
|
.pipe(z.int().nonnegative())
|
||||||
ip: z
|
|
||||||
.preprocess((val) => {
|
|
||||||
if (val === undefined || val === null || val === "") {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (Array.isArray(val)) {
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
// the array is returned as this
|
|
||||||
if (typeof val === "string") {
|
|
||||||
return val.split(",");
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}, z.array(z.string()))
|
|
||||||
.optional()
|
|
||||||
.catch([])
|
|
||||||
.openapi({
|
|
||||||
type: "array",
|
|
||||||
description: "Filter by IP adresses"
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const queryRequestAuditLogsParams = z.object({
|
export const queryRequestAuditLogsParams = z.object({
|
||||||
@@ -146,9 +126,6 @@ function getWhere(data: Q) {
|
|||||||
data.path ? eq(requestAuditLog.path, data.path) : undefined,
|
data.path ? eq(requestAuditLog.path, data.path) : undefined,
|
||||||
data.action !== undefined
|
data.action !== undefined
|
||||||
? eq(requestAuditLog.action, data.action)
|
? eq(requestAuditLog.action, data.action)
|
||||||
: undefined,
|
|
||||||
data.ip && data.ip.length > 0
|
|
||||||
? inArray(requestAuditLog.ip, data.ip)
|
|
||||||
: undefined
|
: undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -533,23 +533,18 @@ export async function startAuthentication(
|
|||||||
|
|
||||||
// If email is provided, get security keys for that specific user
|
// If email is provided, get security keys for that specific user
|
||||||
if (email) {
|
if (email) {
|
||||||
const matchingUsers = await db
|
const [user] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(users)
|
.from(users)
|
||||||
.where(
|
.where(eq(users.email, email))
|
||||||
and(
|
.limit(1);
|
||||||
eq(users.email, email.toLowerCase()),
|
|
||||||
eq(users.type, UserType.Internal)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (matchingUsers.length !== 1) {
|
if (!user || user.type !== UserType.Internal) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(HttpCode.BAD_REQUEST, "Invalid credentials")
|
createHttpError(HttpCode.BAD_REQUEST, "Invalid credentials")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = matchingUsers[0];
|
|
||||||
userId = user.userId;
|
userId = user.userId;
|
||||||
|
|
||||||
const userSecurityKeys = await db
|
const userSecurityKeys = await db
|
||||||
|
|||||||
@@ -42,62 +42,54 @@ export async function setServerAdmin(
|
|||||||
|
|
||||||
const { email, password, setupToken } = parsedBody.data;
|
const { email, password, setupToken } = parsedBody.data;
|
||||||
|
|
||||||
|
// Validate setup token
|
||||||
|
const [validToken] = await db
|
||||||
|
.select()
|
||||||
|
.from(setupTokens)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(setupTokens.token, setupToken),
|
||||||
|
eq(setupTokens.used, false)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!validToken) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"Invalid or expired setup token"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [existing] = await db
|
||||||
|
.select()
|
||||||
|
.from(users)
|
||||||
|
.where(eq(users.serverAdmin, true));
|
||||||
|
|
||||||
|
if (existing) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"Server admin already exists"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const passwordHash = await hashPassword(password);
|
const passwordHash = await hashPassword(password);
|
||||||
const userId = generateId(15);
|
const userId = generateId(15);
|
||||||
|
|
||||||
await db.transaction(async (trx) => {
|
await db.transaction(async (trx) => {
|
||||||
const consumed = await trx
|
// Mark the token as used
|
||||||
|
await trx
|
||||||
.update(setupTokens)
|
.update(setupTokens)
|
||||||
.set({
|
.set({
|
||||||
used: true,
|
used: true,
|
||||||
dateUsed: moment().toISOString()
|
dateUsed: moment().toISOString()
|
||||||
})
|
})
|
||||||
.where(
|
.where(eq(setupTokens.tokenId, validToken.tokenId));
|
||||||
and(
|
|
||||||
eq(setupTokens.token, setupToken),
|
|
||||||
eq(setupTokens.used, false)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.returning({ tokenId: setupTokens.tokenId });
|
|
||||||
|
|
||||||
if (!consumed.length) {
|
|
||||||
throw createHttpError(
|
|
||||||
HttpCode.BAD_REQUEST,
|
|
||||||
"Invalid setup token"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [existingAdmin] = await trx
|
|
||||||
.select({ userId: users.userId })
|
|
||||||
.from(users)
|
|
||||||
.where(eq(users.serverAdmin, true))
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
if (existingAdmin) {
|
|
||||||
throw createHttpError(
|
|
||||||
HttpCode.BAD_REQUEST,
|
|
||||||
"Server admin already exists"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [existingUser] = await trx
|
|
||||||
.select({ userId: users.userId })
|
|
||||||
.from(users)
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(users.email, email),
|
|
||||||
eq(users.type, UserType.Internal)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
if (existingUser) {
|
|
||||||
throw createHttpError(
|
|
||||||
HttpCode.BAD_REQUEST,
|
|
||||||
"A user with that email address already exists"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Create the server admin user
|
||||||
await trx.insert(users).values({
|
await trx.insert(users).values({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
email: email,
|
email: email,
|
||||||
@@ -119,9 +111,6 @@ export async function setServerAdmin(
|
|||||||
status: HttpCode.OK
|
status: HttpCode.OK
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (createHttpError.isHttpError(e)) {
|
|
||||||
return next(e);
|
|
||||||
}
|
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export async function validateSetupToken(
|
|||||||
return response<ValidateSetupTokenResponse>(res, {
|
return response<ValidateSetupTokenResponse>(res, {
|
||||||
data: {
|
data: {
|
||||||
valid: false,
|
valid: false,
|
||||||
message: "Invalid setup token"
|
message: "Invalid or expired setup token"
|
||||||
},
|
},
|
||||||
success: true,
|
success: true,
|
||||||
error: false,
|
error: false,
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import { DateTimeValue } from "@app/components/DateTimePicker";
|
|||||||
import { ArrowUpRight, Key, User } from "lucide-react";
|
import { ArrowUpRight, Key, User } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { ColumnFilterButton } from "@app/components/ColumnFilterButton";
|
import { ColumnFilterButton } from "@app/components/ColumnFilterButton";
|
||||||
import { ColumnMultiFilterButton } from "@app/components/ColumnMultiFilterButton";
|
|
||||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { getSevenDaysAgo } from "@app/lib/getSevenDaysAgo";
|
import { getSevenDaysAgo } from "@app/lib/getSevenDaysAgo";
|
||||||
@@ -27,7 +26,6 @@ import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
|||||||
import { logQueries } from "@app/lib/queries";
|
import { logQueries } from "@app/lib/queries";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import type { QueryAccessAuditLogResponse } from "@server/routers/auditLogs/types";
|
import type { QueryAccessAuditLogResponse } from "@server/routers/auditLogs/types";
|
||||||
import { countryCodeToFlagEmoji } from "@app/lib/countryCodeToFlagEmoji";
|
|
||||||
|
|
||||||
export default function GeneralPage() {
|
export default function GeneralPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -47,14 +45,12 @@ export default function GeneralPage() {
|
|||||||
resourceId?: string;
|
resourceId?: string;
|
||||||
location?: string;
|
location?: string;
|
||||||
actor?: string;
|
actor?: string;
|
||||||
ip?: string[];
|
|
||||||
}>({
|
}>({
|
||||||
action: searchParams.get("action") || undefined,
|
action: searchParams.get("action") || undefined,
|
||||||
type: searchParams.get("type") || undefined,
|
type: searchParams.get("type") || undefined,
|
||||||
resourceId: searchParams.get("resourceId") || undefined,
|
resourceId: searchParams.get("resourceId") || undefined,
|
||||||
location: searchParams.get("location") || undefined,
|
location: searchParams.get("location") || undefined,
|
||||||
actor: searchParams.get("actor") || undefined,
|
actor: searchParams.get("actor") || undefined
|
||||||
ip: searchParams.getAll("ip") || undefined
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState<number>(0);
|
const [currentPage, setCurrentPage] = useState<number>(0);
|
||||||
@@ -180,7 +176,7 @@ export default function GeneralPage() {
|
|||||||
|
|
||||||
const handleFilterChange = (
|
const handleFilterChange = (
|
||||||
filterType: keyof typeof filters,
|
filterType: keyof typeof filters,
|
||||||
value: string | string[] | undefined
|
value: string | undefined
|
||||||
) => {
|
) => {
|
||||||
const newFilters = { ...filters, [filterType]: value };
|
const newFilters = { ...filters, [filterType]: value };
|
||||||
setFilters(newFilters);
|
setFilters(newFilters);
|
||||||
@@ -198,13 +194,10 @@ export default function GeneralPage() {
|
|||||||
) => {
|
) => {
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
Object.entries(newFilters).forEach(([key, value]) => {
|
Object.entries(newFilters).forEach(([key, value]) => {
|
||||||
params.delete(key);
|
if (value) {
|
||||||
if (typeof value === "string") {
|
|
||||||
params.set(key, value);
|
params.set(key, value);
|
||||||
} else if (typeof value !== "undefined" && "length" in value) {
|
} else {
|
||||||
for (const element of value) {
|
params.delete(key);
|
||||||
params.append(key, element);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
router.replace(`?${params.toString()}`, { scroll: false });
|
router.replace(`?${params.toString()}`, { scroll: false });
|
||||||
@@ -212,7 +205,6 @@ export default function GeneralPage() {
|
|||||||
|
|
||||||
const exportData = async () => {
|
const exportData = async () => {
|
||||||
try {
|
try {
|
||||||
const { ip, ...restFilters } = filters;
|
|
||||||
const params: any = {
|
const params: any = {
|
||||||
timeStart: dateRange.startDate?.date
|
timeStart: dateRange.startDate?.date
|
||||||
? new Date(dateRange.startDate.date).toISOString()
|
? new Date(dateRange.startDate.date).toISOString()
|
||||||
@@ -220,20 +212,13 @@ export default function GeneralPage() {
|
|||||||
timeEnd: dateRange.endDate?.date
|
timeEnd: dateRange.endDate?.date
|
||||||
? new Date(dateRange.endDate.date).toISOString()
|
? new Date(dateRange.endDate.date).toISOString()
|
||||||
: undefined,
|
: undefined,
|
||||||
...restFilters
|
...filters
|
||||||
};
|
};
|
||||||
|
|
||||||
// axios serializes arrays as `ip[]=…`, which express's query
|
const response = await api.get(`/org/${orgId}/logs/access/export`, {
|
||||||
// parser does not read back as `ip`, so pass them in the URL
|
responseType: "blob",
|
||||||
const sp = new URLSearchParams((ip ?? []).map((ip) => ["ip", ip]));
|
params
|
||||||
|
});
|
||||||
const response = await api.get(
|
|
||||||
`/org/${orgId}/logs/access/export?${sp.toString()}`,
|
|
||||||
{
|
|
||||||
responseType: "blob",
|
|
||||||
params
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
@@ -312,24 +297,7 @@ export default function GeneralPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "ip",
|
accessorKey: "ip",
|
||||||
header: () => (
|
header: () => <span className="px-2">{t("ip")}</span>,
|
||||||
<span className="px-2">
|
|
||||||
<ColumnMultiFilterButton
|
|
||||||
options={(filters.ip ?? []).map((ip) => ({
|
|
||||||
label: ip,
|
|
||||||
value: ip
|
|
||||||
}))}
|
|
||||||
label={t("ip")}
|
|
||||||
allowArbitraryValues
|
|
||||||
searchPlaceholder={t("ipFilterSearchPlaceholder")}
|
|
||||||
emptyMessage={t("ipFilterEmptyMessage")}
|
|
||||||
selectedValues={filters.ip ?? []}
|
|
||||||
onSelectedValuesChange={(value) =>
|
|
||||||
handleFilterChange("ip", value)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
return row.original.ip ? (
|
return row.original.ip ? (
|
||||||
row.original.ip
|
row.original.ip
|
||||||
@@ -347,7 +315,7 @@ export default function GeneralPage() {
|
|||||||
options={filterAttributes.locations.map(
|
options={filterAttributes.locations.map(
|
||||||
(location) => ({
|
(location) => ({
|
||||||
value: location,
|
value: location,
|
||||||
label: `${location} ${countryCodeToFlagEmoji(location)}`
|
label: location
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
label={t("location")}
|
label={t("location")}
|
||||||
@@ -366,8 +334,7 @@ export default function GeneralPage() {
|
|||||||
<span className="flex items-center gap-1">
|
<span className="flex items-center gap-1">
|
||||||
{row.original.location ? (
|
{row.original.location ? (
|
||||||
<span className="text-muted-foreground text-xs">
|
<span className="text-muted-foreground text-xs">
|
||||||
{row.original.location}{" "}
|
{row.original.location}
|
||||||
{countryCodeToFlagEmoji(row.original.location)}
|
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-muted-foreground text-xs">
|
<span className="text-muted-foreground text-xs">
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import { useMemo, useState, useTransition } from "react";
|
|||||||
import { useStoredPageSize } from "@app/hooks/useStoredPageSize";
|
import { useStoredPageSize } from "@app/hooks/useStoredPageSize";
|
||||||
import type { QueryRequestAuditLogResponse } from "@server/routers/auditLogs/types";
|
import type { QueryRequestAuditLogResponse } from "@server/routers/auditLogs/types";
|
||||||
import { ColumnFilterButton } from "@app/components/ColumnFilterButton";
|
import { ColumnFilterButton } from "@app/components/ColumnFilterButton";
|
||||||
import { countryCodeToFlagEmoji } from "@app/lib/countryCodeToFlagEmoji";
|
|
||||||
import { ColumnMultiFilterButton } from "@app/components/ColumnMultiFilterButton";
|
|
||||||
|
|
||||||
export default function GeneralPage() {
|
export default function GeneralPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -49,7 +47,6 @@ export default function GeneralPage() {
|
|||||||
method?: string;
|
method?: string;
|
||||||
reason?: string;
|
reason?: string;
|
||||||
path?: string;
|
path?: string;
|
||||||
ip?: string[];
|
|
||||||
}>({
|
}>({
|
||||||
action: searchParams.get("action") || undefined,
|
action: searchParams.get("action") || undefined,
|
||||||
host: searchParams.get("host") || undefined,
|
host: searchParams.get("host") || undefined,
|
||||||
@@ -58,8 +55,7 @@ export default function GeneralPage() {
|
|||||||
actor: searchParams.get("actor") || undefined,
|
actor: searchParams.get("actor") || undefined,
|
||||||
method: searchParams.get("method") || undefined,
|
method: searchParams.get("method") || undefined,
|
||||||
reason: searchParams.get("reason") || undefined,
|
reason: searchParams.get("reason") || undefined,
|
||||||
path: searchParams.get("path") || undefined,
|
path: searchParams.get("path") || undefined
|
||||||
ip: searchParams.getAll("ip") || undefined
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const getDefaultDateRange = () => {
|
const getDefaultDateRange = () => {
|
||||||
@@ -183,7 +179,7 @@ export default function GeneralPage() {
|
|||||||
|
|
||||||
const handleFilterChange = (
|
const handleFilterChange = (
|
||||||
filterType: keyof typeof filters,
|
filterType: keyof typeof filters,
|
||||||
value: string | string[] | undefined
|
value: string | undefined
|
||||||
) => {
|
) => {
|
||||||
const newFilters = { ...filters, [filterType]: value };
|
const newFilters = { ...filters, [filterType]: value };
|
||||||
setFilters(newFilters);
|
setFilters(newFilters);
|
||||||
@@ -201,13 +197,10 @@ export default function GeneralPage() {
|
|||||||
) => {
|
) => {
|
||||||
const params = new URLSearchParams(searchParams);
|
const params = new URLSearchParams(searchParams);
|
||||||
Object.entries(newFilters).forEach(([key, value]) => {
|
Object.entries(newFilters).forEach(([key, value]) => {
|
||||||
params.delete(key);
|
if (value) {
|
||||||
if (typeof value === "string") {
|
|
||||||
params.set(key, value);
|
params.set(key, value);
|
||||||
} else if (typeof value !== "undefined" && "length" in value) {
|
} else {
|
||||||
for (const element of value) {
|
params.delete(key);
|
||||||
params.append(key, element);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
router.replace(`?${params.toString()}`, { scroll: false });
|
router.replace(`?${params.toString()}`, { scroll: false });
|
||||||
@@ -216,7 +209,6 @@ export default function GeneralPage() {
|
|||||||
const exportData = async () => {
|
const exportData = async () => {
|
||||||
try {
|
try {
|
||||||
// Prepare query params for export
|
// Prepare query params for export
|
||||||
const { ip, ...restFilters } = filters;
|
|
||||||
const params: any = {
|
const params: any = {
|
||||||
timeStart: dateRange.startDate?.date
|
timeStart: dateRange.startDate?.date
|
||||||
? new Date(dateRange.startDate.date).toISOString()
|
? new Date(dateRange.startDate.date).toISOString()
|
||||||
@@ -224,15 +216,11 @@ export default function GeneralPage() {
|
|||||||
timeEnd: dateRange.endDate?.date
|
timeEnd: dateRange.endDate?.date
|
||||||
? new Date(dateRange.endDate.date).toISOString()
|
? new Date(dateRange.endDate.date).toISOString()
|
||||||
: undefined,
|
: undefined,
|
||||||
...restFilters
|
...filters
|
||||||
};
|
};
|
||||||
|
|
||||||
// axios serializes arrays as `ip[]=…`, which express's query
|
|
||||||
// parser does not read back as `ip`, so pass them in the URL
|
|
||||||
const sp = new URLSearchParams((ip ?? []).map((ip) => ["ip", ip]));
|
|
||||||
|
|
||||||
const response = await api.get(
|
const response = await api.get(
|
||||||
`/org/${orgId}/logs/request/export?${sp.toString()}`,
|
`/org/${orgId}/logs/request/export`,
|
||||||
{
|
{
|
||||||
responseType: "blob",
|
responseType: "blob",
|
||||||
params
|
params
|
||||||
@@ -363,24 +351,7 @@ export default function GeneralPage() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "ip",
|
accessorKey: "ip",
|
||||||
header: ({ column }) => (
|
header: ({ column }) => <span className="px-2">{t("ip")}</span>,
|
||||||
<span className="px-2">
|
|
||||||
<ColumnMultiFilterButton
|
|
||||||
options={(filters.ip ?? []).map((ip) => ({
|
|
||||||
label: ip,
|
|
||||||
value: ip
|
|
||||||
}))}
|
|
||||||
label={t("ip")}
|
|
||||||
allowArbitraryValues
|
|
||||||
searchPlaceholder={t("ipFilterSearchPlaceholder")}
|
|
||||||
emptyMessage={t("ipFilterEmptyMessage")}
|
|
||||||
selectedValues={filters.ip ?? []}
|
|
||||||
onSelectedValuesChange={(value) =>
|
|
||||||
handleFilterChange("ip", value)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
return row.original.ip ? (
|
return row.original.ip ? (
|
||||||
row.original.ip
|
row.original.ip
|
||||||
@@ -398,7 +369,7 @@ export default function GeneralPage() {
|
|||||||
options={filterAttributes.locations.map(
|
options={filterAttributes.locations.map(
|
||||||
(location) => ({
|
(location) => ({
|
||||||
value: location,
|
value: location,
|
||||||
label: `${location} ${countryCodeToFlagEmoji(location)}`
|
label: location
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
selectedValue={filters.location}
|
selectedValue={filters.location}
|
||||||
@@ -418,8 +389,7 @@ export default function GeneralPage() {
|
|||||||
<span className="flex items-center gap-1">
|
<span className="flex items-center gap-1">
|
||||||
{row.original.location ? (
|
{row.original.location ? (
|
||||||
<span className="text-muted-foreground text-xs">
|
<span className="text-muted-foreground text-xs">
|
||||||
{row.original.location}{" "}
|
{row.original.location}
|
||||||
{countryCodeToFlagEmoji(row.original.location)}
|
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-muted-foreground text-xs">
|
<span className="text-muted-foreground text-xs">
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { useTranslations } from "next-intl";
|
|||||||
|
|
||||||
interface FilterOption {
|
interface FilterOption {
|
||||||
value: string;
|
value: string;
|
||||||
label: React.ReactNode;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ColumnFilterButtonProps {
|
interface ColumnFilterButtonProps {
|
||||||
@@ -32,7 +32,6 @@ interface ColumnFilterButtonProps {
|
|||||||
emptyMessage?: string;
|
emptyMessage?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
label: string;
|
label: string;
|
||||||
allowArbitraryValues?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ColumnFilterButton({
|
export function ColumnFilterButton({
|
||||||
@@ -42,8 +41,7 @@ export function ColumnFilterButton({
|
|||||||
searchPlaceholder = "Search...",
|
searchPlaceholder = "Search...",
|
||||||
emptyMessage = "No options found",
|
emptyMessage = "No options found",
|
||||||
className,
|
className,
|
||||||
label,
|
label
|
||||||
allowArbitraryValues
|
|
||||||
}: ColumnFilterButtonProps) {
|
}: ColumnFilterButtonProps) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
@@ -103,7 +101,7 @@ export function ColumnFilterButton({
|
|||||||
{options.map((option) => (
|
{options.map((option) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={option.value}
|
key={option.value}
|
||||||
value={option.value}
|
value={option.label}
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
onValueChange(
|
onValueChange(
|
||||||
selectedValue === option.value
|
selectedValue === option.value
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ type ColumnMultiFilterButtonProps = {
|
|||||||
emptyMessage?: string;
|
emptyMessage?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
label: string;
|
label: string;
|
||||||
allowArbitraryValues?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ColumnMultiFilterButton({
|
export function ColumnMultiFilterButton({
|
||||||
@@ -45,26 +44,11 @@ export function ColumnMultiFilterButton({
|
|||||||
searchPlaceholder = "Search...",
|
searchPlaceholder = "Search...",
|
||||||
emptyMessage = "No options found",
|
emptyMessage = "No options found",
|
||||||
className,
|
className,
|
||||||
label,
|
label
|
||||||
allowArbitraryValues
|
|
||||||
}: ColumnMultiFilterButtonProps) {
|
}: ColumnMultiFilterButtonProps) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
|
||||||
const visibleOptions = useMemo<FilterOption[]>(() => {
|
|
||||||
const newOptions = [...options];
|
|
||||||
|
|
||||||
if (allowArbitraryValues && searchQuery.trim().length > 0) {
|
|
||||||
newOptions.push({
|
|
||||||
label: searchQuery,
|
|
||||||
value: searchQuery
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return newOptions;
|
|
||||||
}, [options, allowArbitraryValues, searchQuery]);
|
|
||||||
|
|
||||||
const selectedSet = useMemo(
|
const selectedSet = useMemo(
|
||||||
() => new Set(selectedValues),
|
() => new Set(selectedValues),
|
||||||
[selectedValues]
|
[selectedValues]
|
||||||
@@ -80,7 +64,7 @@ export function ColumnMultiFilterButton({
|
|||||||
selectedValues[0]
|
selectedValues[0]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return t("multiSelectFilterCount", {
|
return t("accessUsersRoleFilterCount", {
|
||||||
count: selectedValues.length
|
count: selectedValues.length
|
||||||
});
|
});
|
||||||
}, [selectedValues, options, t]);
|
}, [selectedValues, options, t]);
|
||||||
@@ -124,11 +108,7 @@ export function ColumnMultiFilterButton({
|
|||||||
align="start"
|
align="start"
|
||||||
>
|
>
|
||||||
<Command>
|
<Command>
|
||||||
<CommandInput
|
<CommandInput placeholder={searchPlaceholder} />
|
||||||
placeholder={searchPlaceholder}
|
|
||||||
value={searchQuery}
|
|
||||||
onValueChange={setSearchQuery}
|
|
||||||
/>
|
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>{emptyMessage}</CommandEmpty>
|
<CommandEmpty>{emptyMessage}</CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
@@ -143,7 +123,7 @@ export function ColumnMultiFilterButton({
|
|||||||
{t("accessFilterClear")}
|
{t("accessFilterClear")}
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
)}
|
)}
|
||||||
{visibleOptions.map((option) => (
|
{options.map((option) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={option.value}
|
key={option.value}
|
||||||
value={option.label}
|
value={option.label}
|
||||||
|
|||||||
+22
-30
@@ -1,8 +1,3 @@
|
|||||||
import {
|
|
||||||
getAiBudgetScopeListPath,
|
|
||||||
type AiBudgetScope
|
|
||||||
} from "@app/lib/aiBudgetScope";
|
|
||||||
import type { AiProviderType } from "@app/lib/aiProviderDefaults";
|
|
||||||
import type { LauncherQueryFilters } from "@app/lib/launcherSearchParams";
|
import type { LauncherQueryFilters } from "@app/lib/launcherSearchParams";
|
||||||
import { buildLauncherSearchParams } from "@app/lib/launcherSearchParams";
|
import { buildLauncherSearchParams } from "@app/lib/launcherSearchParams";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
@@ -10,21 +5,15 @@ import {
|
|||||||
StatusHistoryResponse,
|
StatusHistoryResponse,
|
||||||
type BatchedStatusHistoryResponse
|
type BatchedStatusHistoryResponse
|
||||||
} from "@server/lib/statusHistory";
|
} from "@server/lib/statusHistory";
|
||||||
import type { ListAiBudgetsByScopeResponse } from "@server/routers/aiBudget/types";
|
|
||||||
import type {
|
|
||||||
ListAiModelsResponse,
|
|
||||||
ListAiProvidersResponse,
|
|
||||||
ListCatalogModelsResponse
|
|
||||||
} from "@server/routers/aiProvider/types";
|
|
||||||
import type { ListAlertRulesResponse } from "@server/routers/alertRule/types";
|
import type { ListAlertRulesResponse } from "@server/routers/alertRule/types";
|
||||||
import type {
|
import type {
|
||||||
|
QueryRequestAnalyticsResponse,
|
||||||
QueryAiUsageFilterOptionsResponse,
|
QueryAiUsageFilterOptionsResponse,
|
||||||
QueryAiUsageOverviewResponse,
|
QueryAiUsageOverviewResponse,
|
||||||
QueryAiUsageProvidersResponse,
|
QueryAiUsageProvidersResponse,
|
||||||
QueryAiUsageResourcesResponse,
|
QueryAiUsageResourcesResponse,
|
||||||
QueryAiUsageUsersRolesResponse,
|
QueryAiUsageUsersRolesResponse,
|
||||||
QueryAiUsageVirtualApiKeysResponse,
|
QueryAiUsageVirtualApiKeysResponse
|
||||||
QueryRequestAnalyticsResponse
|
|
||||||
} from "@server/routers/auditLogs";
|
} from "@server/routers/auditLogs";
|
||||||
import type {
|
import type {
|
||||||
QueryAccessAuditLogResponse,
|
QueryAccessAuditLogResponse,
|
||||||
@@ -45,7 +34,6 @@ import type {
|
|||||||
import type { GetDomainResponse } from "@server/routers/domain/getDomain";
|
import type { GetDomainResponse } from "@server/routers/domain/getDomain";
|
||||||
import { ListHealthChecksResponse } from "@server/routers/healthChecks/types";
|
import { ListHealthChecksResponse } from "@server/routers/healthChecks/types";
|
||||||
import type { ListOrgLabelsResponse } from "@server/routers/labels/types";
|
import type { ListOrgLabelsResponse } from "@server/routers/labels/types";
|
||||||
import type { ListLauncherAiModelsResponse } from "@server/routers/launcher/listLauncherAiModels";
|
|
||||||
import type {
|
import type {
|
||||||
LauncherResource,
|
LauncherResource,
|
||||||
ListLauncherGroupsResponse,
|
ListLauncherGroupsResponse,
|
||||||
@@ -55,8 +43,9 @@ import type {
|
|||||||
ListLauncherSitesResponse,
|
ListLauncherSitesResponse,
|
||||||
ListLauncherViewsResponse
|
ListLauncherViewsResponse
|
||||||
} from "@server/routers/launcher/types";
|
} from "@server/routers/launcher/types";
|
||||||
|
import type { ListLauncherAiModelsResponse } from "@server/routers/launcher/listLauncherAiModels";
|
||||||
|
import type { ListMyVirtualApiKeysResponse } from "@server/routers/virtualApiKey/types";
|
||||||
import type { GetResourcePolicyResponse } from "@server/routers/policy";
|
import type { GetResourcePolicyResponse } from "@server/routers/policy";
|
||||||
import type { ListRemoteExitNodesResponse } from "@server/routers/remoteExitNode/types";
|
|
||||||
import type {
|
import type {
|
||||||
GetResourcePoliciesResponse,
|
GetResourcePoliciesResponse,
|
||||||
GetResourceWhitelistResponse,
|
GetResourceWhitelistResponse,
|
||||||
@@ -70,6 +59,7 @@ import type {
|
|||||||
import type { GetResourceResponse } from "@server/routers/resource/getResource";
|
import type { GetResourceResponse } from "@server/routers/resource/getResource";
|
||||||
import type { GetResourceAuthInfoResponse } from "@server/routers/resource/getResourceAuthInfo";
|
import type { GetResourceAuthInfoResponse } from "@server/routers/resource/getResourceAuthInfo";
|
||||||
import type { ListResourcePoliciesResponse } from "@server/routers/resource/types";
|
import type { ListResourcePoliciesResponse } from "@server/routers/resource/types";
|
||||||
|
import type { ListRemoteExitNodesResponse } from "@server/routers/remoteExitNode/types";
|
||||||
import type { ListRolesResponse } from "@server/routers/role";
|
import type { ListRolesResponse } from "@server/routers/role";
|
||||||
import type { ListSitesResponse } from "@server/routers/site";
|
import type { ListSitesResponse } from "@server/routers/site";
|
||||||
import type {
|
import type {
|
||||||
@@ -81,8 +71,18 @@ import type {
|
|||||||
} from "@server/routers/siteResource";
|
} from "@server/routers/siteResource";
|
||||||
import type { GetSiteResourceResponse } from "@server/routers/siteResource/getSiteResource";
|
import type { GetSiteResourceResponse } from "@server/routers/siteResource/getSiteResource";
|
||||||
import type { ListTargetsResponse } from "@server/routers/target";
|
import type { ListTargetsResponse } from "@server/routers/target";
|
||||||
|
import type {
|
||||||
|
ListAiModelsResponse,
|
||||||
|
ListAiProvidersResponse,
|
||||||
|
ListCatalogModelsResponse
|
||||||
|
} from "@server/routers/aiProvider/types";
|
||||||
|
import type { AiProviderType } from "@app/lib/aiProviderDefaults";
|
||||||
|
import type { ListAiBudgetsByScopeResponse } from "@server/routers/aiBudget/types";
|
||||||
|
import {
|
||||||
|
getAiBudgetScopeListPath,
|
||||||
|
type AiBudgetScope
|
||||||
|
} from "@app/lib/aiBudgetScope";
|
||||||
import type { ListUsersResponse } from "@server/routers/user";
|
import type { ListUsersResponse } from "@server/routers/user";
|
||||||
import type { ListMyVirtualApiKeysResponse } from "@server/routers/virtualApiKey/types";
|
|
||||||
import type ResponseT from "@server/types/Response";
|
import type ResponseT from "@server/types/Response";
|
||||||
import {
|
import {
|
||||||
infiniteQueryOptions,
|
infiniteQueryOptions,
|
||||||
@@ -1000,8 +1000,7 @@ export const httpLogsFiltersSchema = z.object({
|
|||||||
actor: z.string().optional().catch(undefined),
|
actor: z.string().optional().catch(undefined),
|
||||||
method: z.string().optional().catch(undefined),
|
method: z.string().optional().catch(undefined),
|
||||||
reason: z.string().optional().catch(undefined),
|
reason: z.string().optional().catch(undefined),
|
||||||
path: z.string().optional().catch(undefined),
|
path: z.string().optional().catch(undefined)
|
||||||
ip: z.array(z.string()).optional().catch(undefined)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type HttpLogFilters = z.output<typeof httpLogsFiltersSchema>;
|
export type HttpLogFilters = z.output<typeof httpLogsFiltersSchema>;
|
||||||
@@ -1027,8 +1026,7 @@ export const accessLogsFiltersSchema = z.object({
|
|||||||
action: z.string().optional().catch(undefined),
|
action: z.string().optional().catch(undefined),
|
||||||
location: z.string().optional().catch(undefined),
|
location: z.string().optional().catch(undefined),
|
||||||
actor: z.string().optional().catch(undefined),
|
actor: z.string().optional().catch(undefined),
|
||||||
type: z.string().optional().catch(undefined),
|
type: z.string().optional().catch(undefined)
|
||||||
ip: z.array(z.string()).optional().catch(undefined)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type AccessLogFilters = z.output<typeof accessLogsFiltersSchema>;
|
export type AccessLogFilters = z.output<typeof accessLogsFiltersSchema>;
|
||||||
@@ -1141,13 +1139,10 @@ export const logQueries = {
|
|||||||
queryOptions({
|
queryOptions({
|
||||||
queryKey: ["REQUEST_LOGS", orgId, "ALL", filters] as const,
|
queryKey: ["REQUEST_LOGS", orgId, "ALL", filters] as const,
|
||||||
queryFn: async ({ signal, meta }) => {
|
queryFn: async ({ signal, meta }) => {
|
||||||
const { page, pageSize, ip, ...rest } = filters;
|
const { page, pageSize, ...rest } = filters;
|
||||||
const sp = new URLSearchParams(
|
|
||||||
(ip ?? []).map((ip) => ["ip", ip])
|
|
||||||
);
|
|
||||||
const res = await meta!.api.get<
|
const res = await meta!.api.get<
|
||||||
AxiosResponse<QueryRequestAuditLogResponse>
|
AxiosResponse<QueryRequestAuditLogResponse>
|
||||||
>(`/org/${orgId}/logs/request?${sp.toString()}`, {
|
>(`/org/${orgId}/logs/request`, {
|
||||||
params: {
|
params: {
|
||||||
...rest,
|
...rest,
|
||||||
limit: pageSize,
|
limit: pageSize,
|
||||||
@@ -1169,13 +1164,10 @@ export const logQueries = {
|
|||||||
queryOptions({
|
queryOptions({
|
||||||
queryKey: ["ACCESS_LOGS", orgId, "ALL", filters] as const,
|
queryKey: ["ACCESS_LOGS", orgId, "ALL", filters] as const,
|
||||||
queryFn: async ({ signal, meta }) => {
|
queryFn: async ({ signal, meta }) => {
|
||||||
const { page, pageSize, ip, ...rest } = filters;
|
const { page, pageSize, ...rest } = filters;
|
||||||
const sp = new URLSearchParams(
|
|
||||||
(ip ?? []).map((ip) => ["ip", ip])
|
|
||||||
);
|
|
||||||
const res = await meta!.api.get<
|
const res = await meta!.api.get<
|
||||||
AxiosResponse<QueryAccessAuditLogResponse>
|
AxiosResponse<QueryAccessAuditLogResponse>
|
||||||
>(`/org/${orgId}/logs/access?${sp.toString()}`, {
|
>(`/org/${orgId}/logs/access`, {
|
||||||
params: {
|
params: {
|
||||||
...rest,
|
...rest,
|
||||||
limit: pageSize,
|
limit: pageSize,
|
||||||
|
|||||||
Reference in New Issue
Block a user