From 500a8cd4b0e4171e386a7ce9c91e0491b5fa7bf7 Mon Sep 17 00:00:00 2001 From: eikendev Date: Sat, 12 Feb 2022 18:58:43 +0100 Subject: [PATCH] Reintroduce check for minimum token length --- internal/authentication/token_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/authentication/token_test.go b/internal/authentication/token_test.go index 7e7138e..4e354d1 100644 --- a/internal/authentication/token_test.go +++ b/internal/authentication/token_test.go @@ -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")