Reintroduce check for minimum token length

This commit is contained in:
eikendev 2022-02-12 18:58:43 +01:00
parent 47f10c03ae
commit 500a8cd4b0
No known key found for this signature in database
GPG key ID: A1BDB1B28C8EF694

View file

@ -7,6 +7,10 @@ import (
"github.com/stretchr/testify/require"
)
const (
minTokenLength = 14
)
func isGoodToken(assert *assert.Assertions, require *require.Assertions, token string, compat bool) {
if compat {
assert.Equal(len(token), compatTokenLength, "Unexpected compatibility token length")
@ -14,6 +18,8 @@ func isGoodToken(assert *assert.Assertions, require *require.Assertions, token s
assert.Equal(len(token), regularTokenLength, "Unexpected regular token length")
}
assert.GreaterOrEqual(len(token), minTokenLength, "Token is too short to give sufficient entropy")
prefix := token[0:len(applicationTokenPrefix)]
assert.Equal(prefix, applicationTokenPrefix, "Invalid token prefix")