Merge pull request #3922 from Tyagiquamar/fix/blueprint-basic-auth-race-3835

fix(blueprints): hash basic-auth before header-auth delete
This commit is contained in:
Owen Schwartz
2026-10-27 15:27:06 -04:00
committed by GitHub
+18 -9
View File
@@ -182,15 +182,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(
@@ -198,12 +190,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