strip '=' signs from encoded api keys (#2472)

Co-authored-by: Thibault "bui" Koechlin <thibault@crowdsec.net>
This commit is contained in:
mmetc 2023-09-19 14:00:23 +02:00 committed by GitHub
parent 4c08e1e68c
commit ac01faf483
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,7 +33,9 @@ func GenerateAPIKey(n int) (string, error) {
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(bytes), nil
encoded := base64.StdEncoding.EncodeToString(bytes)
// the '=' can cause issues on some bouncers
return strings.TrimRight(encoded, "="), nil
}
func NewAPIKey(dbClient *database.Client) *APIKey {