You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-06-15 00:15:00 +02:00
Stop accepting legacy SHA1 signed cookies
This commit is contained in:
@ -2,8 +2,6 @@ package encryption
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
// TODO (@NickMeves): Remove SHA1 signed cookie support in V7
|
||||
"crypto/sha1" // #nosec G505
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
@ -95,16 +93,7 @@ func checkSignature(signature string, args ...string) bool {
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if checkHmac(signature, checkSig) {
|
||||
return true
|
||||
}
|
||||
|
||||
// TODO (@NickMeves): Remove SHA1 signed cookie support in V7
|
||||
legacySig, err := cookieSignature(sha1.New, args...)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return checkHmac(signature, legacySig)
|
||||
return checkHmac(signature, checkSig)
|
||||
}
|
||||
|
||||
func checkHmac(input, expected string) bool {
|
||||
|
@ -94,8 +94,8 @@ func TestSignAndValidate(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.True(t, checkSignature(sha256sig, seed, key, value, epoch))
|
||||
// This should be switched to False after fully deprecating SHA1
|
||||
assert.True(t, checkSignature(sha1sig, seed, key, value, epoch))
|
||||
// We don't validate legacy SHA1 signatures anymore
|
||||
assert.False(t, checkSignature(sha1sig, seed, key, value, epoch))
|
||||
|
||||
assert.False(t, checkSignature(sha256sig, seed, key, "tampered", epoch))
|
||||
assert.False(t, checkSignature(sha1sig, seed, key, "tampered", epoch))
|
||||
|
Reference in New Issue
Block a user