mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-01 16:26:39 +00:00
Adjust headers to work as name value
This commit is contained in:
@@ -32,8 +32,10 @@ proxy-resources:
|
|||||||
# whitelist-users:
|
# whitelist-users:
|
||||||
# - owen@fossorial.io
|
# - owen@fossorial.io
|
||||||
headers:
|
headers:
|
||||||
- X-Example-Header: example-value
|
- name: X-Example-Header
|
||||||
- X-Another-Header: another-value
|
value: example-value
|
||||||
|
- name: X-Another-Header
|
||||||
|
value: another-value
|
||||||
rules:
|
rules:
|
||||||
- action: allow
|
- action: allow
|
||||||
match: ip
|
match: ip
|
||||||
|
|||||||
@@ -138,10 +138,8 @@ export async function updateProxyResources(
|
|||||||
? true
|
? true
|
||||||
: resourceData.ssl;
|
: resourceData.ssl;
|
||||||
let headers = "";
|
let headers = "";
|
||||||
for (const headerObj of resourceData.headers || []) {
|
for (const header of resourceData.headers || []) {
|
||||||
for (const [key, value] of Object.entries(headerObj)) {
|
headers += `${header.name}: ${header.value},`;
|
||||||
headers += `${key}: ${value},`;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// if there are headers, remove the trailing comma
|
// if there are headers, remove the trailing comma
|
||||||
if (headers.endsWith(",")) {
|
if (headers.endsWith(",")) {
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ export const RuleSchema = z.object({
|
|||||||
value: z.string()
|
value: z.string()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const HeaderSchema = z.object({
|
||||||
|
name: z.string().min(1),
|
||||||
|
value: z.string().min(1)
|
||||||
|
});
|
||||||
|
|
||||||
// Schema for individual resource
|
// Schema for individual resource
|
||||||
export const ResourceSchema = z
|
export const ResourceSchema = z
|
||||||
.object({
|
.object({
|
||||||
@@ -53,7 +58,7 @@ export const ResourceSchema = z
|
|||||||
auth: AuthSchema.optional(),
|
auth: AuthSchema.optional(),
|
||||||
"host-header": z.string().optional(),
|
"host-header": z.string().optional(),
|
||||||
"tls-server-name": z.string().optional(),
|
"tls-server-name": z.string().optional(),
|
||||||
headers: z.array(z.record(z.string(), z.string())).optional().default([]),
|
headers: z.array(HeaderSchema).optional().default([]),
|
||||||
rules: z.array(RuleSchema).optional().default([]),
|
rules: z.array(RuleSchema).optional().default([]),
|
||||||
})
|
})
|
||||||
.refine(
|
.refine(
|
||||||
|
|||||||
Reference in New Issue
Block a user