Skip to content

Commit c35aaa9

Browse files
committed
notification-sentinel: lower-case x-ms-date header for correct HMAC
1 parent 4624f98 commit c35aaa9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cmd/notification-sentinel/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ var logger hclog.Logger = hclog.New(&hclog.LoggerOptions{
4040
})
4141

4242
func (s *SentinelPlugin) getAuthorizationHeader(now string, length int, name string) (string, error) {
43-
xHeaders := "X-Ms-Date:" + now
43+
// Azure calculates HMAC with this header in lower-case
44+
xHeaders := "x-ms-date:" + now
4445

4546
cfg := s.PluginConfigByName[name]
4647

@@ -94,7 +95,9 @@ func (s *SentinelPlugin) Notify(ctx context.Context, notification *protobufs.Not
9495
req.Header.Set("Content-Type", "application/json")
9596
req.Header.Set("Log-Type", cfg.LogType)
9697
req.Header.Set("Authorization", authorization)
97-
req.Header.Set("X-Ms-Date", now)
98+
// to match lower-case header in HMAC calculation it must not be auto-Canonicalized
99+
// https://pkg.go.dev/net/http#Header.Set
100+
req.Header["x-ms-date"] = []string{now}
98101

99102
client := &http.Client{}
100103

0 commit comments

Comments
 (0)