Skip to content

Commit ac01faf

Browse files
mmetcbuixor
andauthored
strip '=' signs from encoded api keys (#2472)
Co-authored-by: Thibault "bui" Koechlin <thibault@crowdsec.net>
1 parent 4c08e1e commit ac01faf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/apiserver/middlewares/v1/api_key.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ func GenerateAPIKey(n int) (string, error) {
3333
if _, err := rand.Read(bytes); err != nil {
3434
return "", err
3535
}
36-
return base64.StdEncoding.EncodeToString(bytes), nil
36+
encoded := base64.StdEncoding.EncodeToString(bytes)
37+
// the '=' can cause issues on some bouncers
38+
return strings.TrimRight(encoded, "="), nil
3739
}
3840

3941
func NewAPIKey(dbClient *database.Client) *APIKey {

0 commit comments

Comments
 (0)