mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-13 17:21:48 +02:00
Properly do disable enterprise features this time
This commit is contained in:
@@ -886,7 +886,9 @@ export const resourcePolicyRules = pgTable("resourcePolicyRules", {
|
|||||||
enabled: boolean("enabled").notNull().default(true),
|
enabled: boolean("enabled").notNull().default(true),
|
||||||
priority: integer("priority").notNull(),
|
priority: integer("priority").notNull(),
|
||||||
action: varchar("action").$type<"ACCEPT" | "DROP" | "PASS">().notNull(),
|
action: varchar("action").$type<"ACCEPT" | "DROP" | "PASS">().notNull(),
|
||||||
match: varchar("match").$type<"CIDR" | "PATH" | "IP">().notNull(),
|
match: varchar("match")
|
||||||
|
.$type<"CIDR" | "PATH" | "IP" | "COUNTRY" | "ASN" | "REGION">()
|
||||||
|
.notNull(),
|
||||||
value: varchar("value").notNull()
|
value: varchar("value").notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1248,7 +1248,9 @@ export const resourcePolicyRules = sqliteTable("resourcePolicyRules", {
|
|||||||
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
|
||||||
priority: integer("priority").notNull(),
|
priority: integer("priority").notNull(),
|
||||||
action: text("action").$type<"ACCEPT" | "DROP" | "PASS">().notNull(),
|
action: text("action").$type<"ACCEPT" | "DROP" | "PASS">().notNull(),
|
||||||
match: text("match").$type<"CIDR" | "PATH" | "IP">().notNull(),
|
match: text("match")
|
||||||
|
.$type<"CIDR" | "PATH" | "IP" | "COUNTRY" | "ASN" | "REGION">()
|
||||||
|
.notNull(),
|
||||||
value: text("value").notNull()
|
value: text("value").notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -345,8 +345,16 @@ function getRuleAction(input: string): "ACCEPT" | "DROP" | "PASS" {
|
|||||||
return "PASS";
|
return "PASS";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRuleMatch(input: string): "CIDR" | "IP" | "PATH" {
|
function getRuleMatch(
|
||||||
return input.toUpperCase() as "CIDR" | "IP" | "PATH";
|
input: string
|
||||||
|
): "CIDR" | "IP" | "PATH" | "COUNTRY" | "ASN" | "REGION" {
|
||||||
|
return input.toUpperCase() as
|
||||||
|
| "CIDR"
|
||||||
|
| "IP"
|
||||||
|
| "PATH"
|
||||||
|
| "COUNTRY"
|
||||||
|
| "ASN"
|
||||||
|
| "REGION";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncRolePolicies(
|
async function syncRolePolicies(
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ export const RuleSchema = z
|
|||||||
action: z.enum(["allow", "deny", "pass"]),
|
action: z.enum(["allow", "deny", "pass"]),
|
||||||
match: z.enum(["cidr", "path", "ip", "country", "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)
|
||||||
})
|
})
|
||||||
.refine(
|
.refine(
|
||||||
(rule) => {
|
(rule) => {
|
||||||
@@ -507,40 +508,7 @@ export const PrivateResourceSchema = z
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const ResourcePolicyRuleSchema = z
|
export const ResourcePolicyRuleSchema = RuleSchema;
|
||||||
.object({
|
|
||||||
action: z.enum(["allow", "deny", "pass"]),
|
|
||||||
match: z.enum(["cidr", "path", "ip"]),
|
|
||||||
value: z.coerce.string(),
|
|
||||||
priority: z.int().optional(),
|
|
||||||
enabled: z.boolean().optional().default(true)
|
|
||||||
})
|
|
||||||
.refine(
|
|
||||||
(rule) => {
|
|
||||||
if (rule.match === "ip") {
|
|
||||||
return z.union([z.ipv4(), z.ipv6()]).safeParse(rule.value)
|
|
||||||
.success;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ["value"],
|
|
||||||
message: "Value must be a valid IP address when match is 'ip'"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.refine(
|
|
||||||
(rule) => {
|
|
||||||
if (rule.match === "cidr") {
|
|
||||||
return z.union([z.cidrv4(), z.cidrv6()]).safeParse(rule.value)
|
|
||||||
.success;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ["value"],
|
|
||||||
message: "Value must be a valid CIDR notation when match is 'cidr'"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export const ResourcePolicySchema = z.object({
|
export const ResourcePolicySchema = z.object({
|
||||||
name: z.string().min(1).max(255),
|
name: z.string().min(1).max(255),
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ export default function Page() {
|
|||||||
env.flags.allowRawResources &&
|
env.flags.allowRawResources &&
|
||||||
(build !== "saas" || remoteExitNodes.length > 0);
|
(build !== "saas" || remoteExitNodes.length > 0);
|
||||||
const enterpriseModesAllowed =
|
const enterpriseModesAllowed =
|
||||||
build === "oss" && !env.flags.disableEnterpriseFeatures;
|
!env.flags.disableEnterpriseFeatures;
|
||||||
|
|
||||||
const availableTypes = useMemo((): NewResourceType[] => {
|
const availableTypes = useMemo((): NewResourceType[] => {
|
||||||
const base: NewResourceType[] = ["http"];
|
const base: NewResourceType[] = ["http"];
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ export const orgNavSections = (
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
...(build === "oss" && !env?.flags.disableEnterpriseFeatures
|
...(!env?.flags.disableEnterpriseFeatures
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
title: "sidebarPolicies",
|
title: "sidebarPolicies",
|
||||||
|
|||||||
Reference in New Issue
Block a user