fix(blueprints): hash basic-auth before header-auth delete

Compute the header-auth hash before deleting existing rows so
concurrent blueprint applies keep delete and insert adjacent.

Fixes #3835
This commit is contained in:
Tyagiquamar
2026-10-18 22:45:34 +05:30
parent 3e0f9996c3
commit 3c0dc478da
+18 -9
View File
@@ -177,15 +177,7 @@ export async function updateResourcePolicies(
});
}
// Sync header auth
await trx
.delete(resourcePolicyHeaderAuth)
.where(
eq(
resourcePolicyHeaderAuth.resourcePolicyId,
resourcePolicyId
)
);
// Sync header auth (hash before delete so delete+insert stay adjacent)
if (policyData["basic-auth"]) {
const basicAuth = policyData["basic-auth"];
const headerAuthHash = await hashPassword(
@@ -193,12 +185,29 @@ export async function updateResourcePolicies(
`${basicAuth.user}:${basicAuth.password}`
).toString("base64")
);
await trx
.delete(resourcePolicyHeaderAuth)
.where(
eq(
resourcePolicyHeaderAuth.resourcePolicyId,
resourcePolicyId
)
);
await trx.insert(resourcePolicyHeaderAuth).values({
resourcePolicyId,
headerAuthHash,
extendedCompatibility:
basicAuth["extended-compatibility"] ?? true
});
} else {
await trx
.delete(resourcePolicyHeaderAuth)
.where(
eq(
resourcePolicyHeaderAuth.resourcePolicyId,
resourcePolicyId
)
);
}
// Sync SSO roles