From c9e7002fc20907c1d835af9d9f27f335475508c3 Mon Sep 17 00:00:00 2001 From: shaj13 Date: Sat, 27 Feb 2021 02:19:15 -0800 Subject: [PATCH] chore: fix issue 84 and use EqualFold --- auth/strategies/digest/header.go | 2 +- auth/strategies/digest/header_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/auth/strategies/digest/header.go b/auth/strategies/digest/header.go index d2aebfd..61b7fa1 100644 --- a/auth/strategies/digest/header.go +++ b/auth/strategies/digest/header.go @@ -180,7 +180,7 @@ func (h Header) WWWAuthenticate() string { func (h Header) Compare(ch Header) error { for k, v := range h { cv := ch[k] - if cv != v { + if !strings.EqualFold(cv, v) { return fmt.Errorf("strategies/digest: %s Does not match value in provided header", k) } } diff --git a/auth/strategies/digest/header_test.go b/auth/strategies/digest/header_test.go index 1923d8e..0aba4a3 100644 --- a/auth/strategies/digest/header_test.go +++ b/auth/strategies/digest/header_test.go @@ -118,6 +118,11 @@ func TestCompare(t *testing.T) { clientHeader string expectedErr bool }{ + { + serverHeader: `Digest algorithm="md5"`, + clientHeader: `Digest algorithm="MD5"`, + expectedErr: false, + }, { serverHeader: `Digest username="a", realm="t", nonce="1", uri="/", cnonce="1=", nc=00000001, qop=auth, response="22cf307b29e6318dafba1fc1d564fc12", opaque="1"`, clientHeader: `Digest username="a", realm="t", nonce="1", uri="/", cnonce="1=", nc=00000001, qop=auth, response="22cf307b29e6318dafba1fc1d564fc12", opaque="1"`,