mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-06 02:36:38 +00:00
Add to blueprints
This commit is contained in:
@@ -2,6 +2,7 @@ import {
|
|||||||
domains,
|
domains,
|
||||||
orgDomains,
|
orgDomains,
|
||||||
Resource,
|
Resource,
|
||||||
|
resourceHeaderAuth,
|
||||||
resourcePincode,
|
resourcePincode,
|
||||||
resourceRules,
|
resourceRules,
|
||||||
resourceWhitelist,
|
resourceWhitelist,
|
||||||
@@ -122,7 +123,9 @@ export async function updateProxyResources(
|
|||||||
|
|
||||||
const healthcheckData = targetData.healthcheck;
|
const healthcheckData = targetData.healthcheck;
|
||||||
|
|
||||||
const hcHeaders = healthcheckData?.headers ? JSON.stringify(healthcheckData.headers) : null;
|
const hcHeaders = healthcheckData?.headers
|
||||||
|
? JSON.stringify(healthcheckData.headers)
|
||||||
|
: null;
|
||||||
|
|
||||||
const [newHealthcheck] = await trx
|
const [newHealthcheck] = await trx
|
||||||
.insert(targetHealthCheck)
|
.insert(targetHealthCheck)
|
||||||
@@ -263,6 +266,32 @@ export async function updateProxyResources(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await trx
|
||||||
|
.delete(resourceHeaderAuth)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
resourceHeaderAuth.resourceId,
|
||||||
|
existingResource.resourceId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (resourceData.auth?.["basic-auth"]) {
|
||||||
|
const headerAuthUser =
|
||||||
|
resourceData.auth?.["basic-auth"]?.user;
|
||||||
|
const headerAuthPassword =
|
||||||
|
resourceData.auth?.["basic-auth"]?.password;
|
||||||
|
if (headerAuthUser && headerAuthPassword) {
|
||||||
|
const headerAuthHash = await hashPassword(
|
||||||
|
Buffer.from(
|
||||||
|
`${headerAuthUser}:${headerAuthPassword}`
|
||||||
|
).toString("base64")
|
||||||
|
);
|
||||||
|
await trx.insert(resourceHeaderAuth).values({
|
||||||
|
resourceId: existingResource.resourceId,
|
||||||
|
headerAuthHash
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (resourceData.auth?.["sso-roles"]) {
|
if (resourceData.auth?.["sso-roles"]) {
|
||||||
const ssoRoles = resourceData.auth?.["sso-roles"];
|
const ssoRoles = resourceData.auth?.["sso-roles"];
|
||||||
await syncRoleResources(
|
await syncRoleResources(
|
||||||
@@ -406,7 +435,9 @@ export async function updateProxyResources(
|
|||||||
)
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
const hcHeaders = healthcheckData?.headers ? JSON.stringify(healthcheckData.headers) : null;
|
const hcHeaders = healthcheckData?.headers
|
||||||
|
? JSON.stringify(healthcheckData.headers)
|
||||||
|
: null;
|
||||||
|
|
||||||
const [newHealthcheck] = await trx
|
const [newHealthcheck] = await trx
|
||||||
.update(targetHealthCheck)
|
.update(targetHealthCheck)
|
||||||
@@ -591,6 +622,25 @@ export async function updateProxyResources(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resourceData.auth?.["basic-auth"]) {
|
||||||
|
const headerAuthUser = resourceData.auth?.["basic-auth"]?.user;
|
||||||
|
const headerAuthPassword =
|
||||||
|
resourceData.auth?.["basic-auth"]?.password;
|
||||||
|
|
||||||
|
if (headerAuthUser && headerAuthPassword) {
|
||||||
|
const headerAuthHash = await hashPassword(
|
||||||
|
Buffer.from(
|
||||||
|
`${headerAuthUser}:${headerAuthPassword}`
|
||||||
|
).toString("base64")
|
||||||
|
);
|
||||||
|
|
||||||
|
await trx.insert(resourceHeaderAuth).values({
|
||||||
|
resourceId: newResource.resourceId,
|
||||||
|
headerAuthHash
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resource = newResource;
|
resource = newResource;
|
||||||
|
|
||||||
const [adminRole] = await trx
|
const [adminRole] = await trx
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ export const AuthSchema = z.object({
|
|||||||
// pincode has to have 6 digits
|
// pincode has to have 6 digits
|
||||||
pincode: z.number().min(100000).max(999999).optional(),
|
pincode: z.number().min(100000).max(999999).optional(),
|
||||||
password: z.string().min(1).optional(),
|
password: z.string().min(1).optional(),
|
||||||
|
"basic-auth": z.object({
|
||||||
|
user: z.string().min(1),
|
||||||
|
password: z.string().min(1)
|
||||||
|
}).optional(),
|
||||||
"sso-enabled": z.boolean().optional().default(false),
|
"sso-enabled": z.boolean().optional().default(false),
|
||||||
"sso-roles": z
|
"sso-roles": z
|
||||||
.array(z.string())
|
.array(z.string())
|
||||||
|
|||||||
Reference in New Issue
Block a user