|
|
|
@ -777,6 +777,47 @@ func (a adminAPIHandlers) ListUsers(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
writeSuccessResponseJSON(w, econfigData) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SetUserStatus - PUT /minio/admin/v1/set-user-status?accessKey=<access_key>&status=[enabled|disabled]
|
|
|
|
|
func (a adminAPIHandlers) SetUserStatus(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
ctx := newContext(r, w, "SetUserStatus") |
|
|
|
|
|
|
|
|
|
// Get current object layer instance.
|
|
|
|
|
objectAPI := newObjectLayerFn() |
|
|
|
|
if objectAPI == nil { |
|
|
|
|
writeErrorResponseJSON(w, ErrServerNotInitialized, r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Validate request signature.
|
|
|
|
|
adminAPIErr := checkAdminRequestAuthType(r, "") |
|
|
|
|
if adminAPIErr != ErrNone { |
|
|
|
|
writeErrorResponseJSON(w, adminAPIErr, r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Deny if WORM is enabled
|
|
|
|
|
if globalWORMEnabled { |
|
|
|
|
writeErrorResponseJSON(w, ErrMethodNotAllowed, r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vars := mux.Vars(r) |
|
|
|
|
accessKey := vars["accessKey"] |
|
|
|
|
status := vars["status"] |
|
|
|
|
|
|
|
|
|
// Custom IAM policies not allowed for admin user.
|
|
|
|
|
if accessKey == globalServerConfig.GetCredential().AccessKey { |
|
|
|
|
writeErrorResponse(w, ErrInvalidRequest, r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if err := globalIAMSys.SetUserStatus(accessKey, madmin.AccountStatus(status)); err != nil { |
|
|
|
|
logger.LogIf(ctx, err) |
|
|
|
|
writeErrorResponseJSON(w, toAdminAPIErrCode(err), r.URL) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// AddUser - PUT /minio/admin/v1/add-user?accessKey=<access_key>
|
|
|
|
|
func (a adminAPIHandlers) AddUser(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
ctx := newContext(r, w, "AddUser") |
|
|
|
|