mirror of
https://github.com/minio/minio.git
synced 2025-11-20 01:50:24 -05:00
Check key length before adding a new user. (#6790)
User's key should satisfy the requirement of `mc config host add`. Check access key and secret key length before adding a new user, avoid creating a useless user which cannot be added into config host or log into the browser.
This commit is contained in:
@@ -21,6 +21,8 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
)
|
||||
|
||||
// AccountStatus - account status.
|
||||
@@ -97,6 +99,15 @@ func (adm *AdminClient) ListUsers() (map[string]UserInfo, error) {
|
||||
|
||||
// SetUser - sets a user info.
|
||||
func (adm *AdminClient) SetUser(accessKey, secretKey string, status AccountStatus) error {
|
||||
|
||||
if !auth.IsAccessKeyValid(accessKey) {
|
||||
return auth.ErrInvalidAccessKeyLength
|
||||
}
|
||||
|
||||
if !auth.IsSecretKeyValid(secretKey) {
|
||||
return auth.ErrInvalidSecretKeyLength
|
||||
}
|
||||
|
||||
data, err := json.Marshal(UserInfo{
|
||||
SecretKey: secretKey,
|
||||
Status: status,
|
||||
|
||||
Reference in New Issue
Block a user