mirror of
https://github.com/minio/minio.git
synced 2025-11-20 09:56:07 -05:00
Simplify credential usage. (#3893)
This commit is contained in:
@@ -373,7 +373,7 @@ func (web webAPIHandlers) GenerateAuth(r *http.Request, args *WebGenericArgs, re
|
||||
if !isHTTPRequestValid(r) {
|
||||
return toJSONError(errAuthentication)
|
||||
}
|
||||
cred := newCredential()
|
||||
cred := mustGetNewCredential()
|
||||
reply.AccessKey = cred.AccessKey
|
||||
reply.SecretKey = cred.SecretKey
|
||||
reply.UIVersion = browser.UIVersion
|
||||
@@ -404,16 +404,11 @@ func (web *webAPIHandlers) SetAuth(r *http.Request, args *SetAuthArgs, reply *Se
|
||||
return toJSONError(errChangeCredNotAllowed)
|
||||
}
|
||||
|
||||
// As we already validated the authentication, we save given access/secret keys.
|
||||
if err := validateAuthKeys(args.AccessKey, args.SecretKey); err != nil {
|
||||
creds, err := createCredential(args.AccessKey, args.SecretKey)
|
||||
if err != nil {
|
||||
return toJSONError(err)
|
||||
}
|
||||
|
||||
creds := credential{
|
||||
AccessKey: args.AccessKey,
|
||||
SecretKey: args.SecretKey,
|
||||
}
|
||||
|
||||
// Notify all other Minio peers to update credentials
|
||||
errsMap := updateCredsOnPeers(creds)
|
||||
|
||||
@@ -421,7 +416,7 @@ func (web *webAPIHandlers) SetAuth(r *http.Request, args *SetAuthArgs, reply *Se
|
||||
serverConfig.SetCredential(creds)
|
||||
|
||||
// Persist updated credentials.
|
||||
if err := serverConfig.Save(); err != nil {
|
||||
if err = serverConfig.Save(); err != nil {
|
||||
errsMap[globalMinioAddr] = err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user