1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-30 19:22:09 +00:00

add WriteIsolationKey to MAC

This commit is contained in:
Mathieu Fenniak 2025-08-19 11:18:32 -06:00 committed by Earl Warren
parent 6c35ea4fd9
commit 4bd93294d4
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 122 additions and 82 deletions

View file

@ -55,7 +55,7 @@ type RunData struct {
}
func (h *Handler) CreateRunData(fullName, runNumber, timestamp, writeIsolationKey string) RunData {
mac := computeMac(h.cacheSecret, fullName, runNumber, timestamp)
mac := computeMac(h.cacheSecret, fullName, runNumber, timestamp, writeIsolationKey)
return RunData{
RepositoryFullName: fullName,
RunNumber: runNumber,
@ -212,12 +212,14 @@ func (h *Handler) Close() error {
return retErr
}
func computeMac(secret, repo, run, ts string) string {
func computeMac(secret, repo, run, ts, writeIsolationKey string) string {
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(repo))
mac.Write([]byte(">"))
mac.Write([]byte(run))
mac.Write([]byte(">"))
mac.Write([]byte(ts))
mac.Write([]byte(">"))
mac.Write([]byte(writeIsolationKey))
return hex.EncodeToString(mac.Sum(nil))
}