mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Restrict access keys for users and groups to not allow '=' or ',' (#19749)
* initial commit * Add UTF check --------- Co-authored-by: Harshavardhana <harsha@minio.io>
This commit is contained in:
@@ -54,6 +54,8 @@ const (
|
||||
|
||||
// Total length of the alpha numeric table.
|
||||
alphaNumericTableLen = byte(len(alphaNumericTable))
|
||||
|
||||
reservedChars = "=,"
|
||||
)
|
||||
|
||||
// Common errors generated for access and secret key validation.
|
||||
@@ -62,11 +64,17 @@ var (
|
||||
ErrInvalidSecretKeyLength = fmt.Errorf("secret key length should be between %d and %d", secretKeyMinLen, secretKeyMaxLen)
|
||||
ErrNoAccessKeyWithSecretKey = fmt.Errorf("access key must be specified if secret key is specified")
|
||||
ErrNoSecretKeyWithAccessKey = fmt.Errorf("secret key must be specified if access key is specified")
|
||||
ErrContainsReservedChars = fmt.Errorf("access key contains one of reserved characters '=' or ','")
|
||||
)
|
||||
|
||||
// AnonymousCredentials simply points to empty credentials
|
||||
var AnonymousCredentials = Credentials{}
|
||||
|
||||
// ContainsReservedChars - returns whether the input string contains reserved characters.
|
||||
func ContainsReservedChars(s string) bool {
|
||||
return strings.ContainsAny(s, reservedChars)
|
||||
}
|
||||
|
||||
// IsAccessKeyValid - validate access key for right length.
|
||||
func IsAccessKeyValid(accessKey string) bool {
|
||||
return len(accessKey) >= accessKeyMinLen
|
||||
|
||||
Reference in New Issue
Block a user