support authenticating with SHA-256 digest (#524)

This commit is contained in:
Alessandro Ros
2024-02-22 19:12:17 +01:00
committed by GitHub
parent c10f7aaedb
commit f040e20ac4
13 changed files with 241 additions and 120 deletions

View File

@@ -30,9 +30,10 @@ var casesAuthenticate = []struct {
{
"digest 1",
base.HeaderValue{`Digest realm="4419b63f5e51", nonce="8b84a3b789283a8bea8da7fa7d41f08b", stale="FALSE"`},
base.HeaderValue{`Digest realm="4419b63f5e51", nonce="8b84a3b789283a8bea8da7fa7d41f08b", stale="FALSE"`},
base.HeaderValue{`Digest realm="4419b63f5e51", nonce="8b84a3b789283a8bea8da7fa7d41f08b", ` +
`stale="FALSE", algorithm="MD5"`},
Authenticate{
Method: AuthDigest,
Method: AuthDigestMD5,
Realm: "4419b63f5e51",
Nonce: "8b84a3b789283a8bea8da7fa7d41f08b",
Stale: stringPtr("FALSE"),
@@ -41,9 +42,10 @@ var casesAuthenticate = []struct {
{
"digest 2",
base.HeaderValue{`Digest realm="4419b63f5e51", nonce="8b84a3b789283a8bea8da7fa7d41f08b", stale=FALSE`},
base.HeaderValue{`Digest realm="4419b63f5e51", nonce="8b84a3b789283a8bea8da7fa7d41f08b", stale="FALSE"`},
base.HeaderValue{`Digest realm="4419b63f5e51", nonce="8b84a3b789283a8bea8da7fa7d41f08b", ` +
`stale="FALSE", algorithm="MD5"`},
Authenticate{
Method: AuthDigest,
Method: AuthDigestMD5,
Realm: "4419b63f5e51",
Nonce: "8b84a3b789283a8bea8da7fa7d41f08b",
Stale: stringPtr("FALSE"),
@@ -52,9 +54,10 @@ var casesAuthenticate = []struct {
{
"digest 3",
base.HeaderValue{`Digest realm="4419b63f5e51",nonce="133767111917411116111311118211673010032", stale="FALSE"`},
base.HeaderValue{`Digest realm="4419b63f5e51", nonce="133767111917411116111311118211673010032", stale="FALSE"`},
base.HeaderValue{`Digest realm="4419b63f5e51", nonce="133767111917411116111311118211673010032", ` +
`stale="FALSE", algorithm="MD5"`},
Authenticate{
Method: AuthDigest,
Method: AuthDigestMD5,
Realm: "4419b63f5e51",
Nonce: "133767111917411116111311118211673010032",
Stale: stringPtr("FALSE"),
@@ -67,12 +70,24 @@ var casesAuthenticate = []struct {
base.HeaderValue{`Digest realm="Please log in with a valid username", ` +
`nonce="752a62306daf32b401a41004555c7663", opaque="", stale="FALSE", algorithm="MD5"`},
Authenticate{
Method: AuthDigest,
Realm: "Please log in with a valid username",
Nonce: "752a62306daf32b401a41004555c7663",
Opaque: stringPtr(""),
Stale: stringPtr("FALSE"),
Algorithm: stringPtr("MD5"),
Method: AuthDigestMD5,
Realm: "Please log in with a valid username",
Nonce: "752a62306daf32b401a41004555c7663",
Opaque: stringPtr(""),
Stale: stringPtr("FALSE"),
},
},
{
"digest sha256",
base.HeaderValue{`Digest realm="IP Camera(AB705)", ` +
`nonce="fcc86deace979a488b2bfb89f4d0812c", algorithm="SHA-256", stale="FALSE"`},
base.HeaderValue{`Digest realm="IP Camera(AB705)", ` +
`nonce="fcc86deace979a488b2bfb89f4d0812c", stale="FALSE", algorithm="SHA-256"`},
Authenticate{
Method: AuthDigestSHA256,
Realm: "IP Camera(AB705)",
Nonce: "fcc86deace979a488b2bfb89f4d0812c",
Stale: stringPtr("FALSE"),
},
},
}