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:
parent
6c35ea4fd9
commit
4bd93294d4
4 changed files with 122 additions and 82 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue