2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2019-11-09 12:27:23 -05:00
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2021-05-06 11:52:02 -04:00
|
|
|
"bytes"
|
2019-11-09 12:27:23 -05:00
|
|
|
"encoding/json"
|
2021-03-23 20:39:20 -04:00
|
|
|
"errors"
|
2019-11-09 12:27:23 -05:00
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
2021-02-09 12:53:07 -05:00
|
|
|
"sort"
|
2019-11-09 12:27:23 -05:00
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
2021-05-06 11:52:02 -04:00
|
|
|
"github.com/minio/madmin-go"
|
2021-10-06 19:36:31 -04:00
|
|
|
"github.com/minio/minio/internal/auth"
|
2021-06-01 17:59:40 -04:00
|
|
|
"github.com/minio/minio/internal/config/dns"
|
|
|
|
"github.com/minio/minio/internal/logger"
|
2021-05-30 00:16:42 -04:00
|
|
|
iampolicy "github.com/minio/pkg/iam/policy"
|
2019-11-09 12:27:23 -05:00
|
|
|
)
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// RemoveUser - DELETE /minio/admin/v3/remove-user?accessKey=<access_key>
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) RemoveUser(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "RemoveUser")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.DeleteUserAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
accessKey := vars["accessKey"]
|
|
|
|
|
2021-02-25 16:49:59 -05:00
|
|
|
ok, _, err := globalIAMSys.IsTempUser(accessKey)
|
2019-12-19 17:21:21 -05:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if ok {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, errIAMActionNotAllowed), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-21 05:16:50 -05:00
|
|
|
if err := globalIAMSys.DeleteUser(ctx, accessKey, true); err != nil {
|
2019-11-09 12:27:23 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2022-01-06 18:52:43 -05:00
|
|
|
|
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemIAMUser,
|
|
|
|
IAMUser: &madmin.SRIAMUser{
|
|
|
|
AccessKey: accessKey,
|
|
|
|
IsDeleteReq: true,
|
|
|
|
},
|
|
|
|
}); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
|
2022-01-19 13:45:13 -05:00
|
|
|
// ListBucketUsers - GET /minio/admin/v3/list-users?bucket={bucket}
|
2021-05-27 13:15:02 -04:00
|
|
|
func (a adminAPIHandlers) ListBucketUsers(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "ListBucketUsers")
|
|
|
|
|
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, cred := validateAdminReq(ctx, w, r, iampolicy.ListUsersAdminAction)
|
2021-05-27 13:15:02 -04:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
bucket := mux.Vars(r)["bucket"]
|
|
|
|
|
|
|
|
password := cred.SecretKey
|
|
|
|
|
2022-04-19 12:00:19 -04:00
|
|
|
allCredentials, err := globalIAMSys.ListBucketUsers(ctx, bucket)
|
2021-05-27 13:15:02 -04:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err := json.Marshal(allCredentials)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
econfigData, err := madmin.EncryptData(password, data)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, econfigData)
|
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// ListUsers - GET /minio/admin/v3/list-users
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) ListUsers(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "ListUsers")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, cred := validateAdminReq(ctx, w, r, iampolicy.ListUsersAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-03-23 17:06:00 -04:00
|
|
|
password := cred.SecretKey
|
|
|
|
|
2022-04-19 12:00:19 -04:00
|
|
|
allCredentials, err := globalIAMSys.ListUsers(ctx)
|
2019-11-09 12:27:23 -05:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-16 00:26:02 -04:00
|
|
|
// Add ldap users which have mapped policies if in LDAP mode
|
|
|
|
// FIXME(vadmeste): move this to policy info in the future
|
|
|
|
ldapUsers, err := globalIAMSys.ListLDAPUsers()
|
|
|
|
if err != nil && err != errIAMActionNotAllowed {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for k, v := range ldapUsers {
|
|
|
|
allCredentials[k] = v
|
|
|
|
}
|
|
|
|
|
|
|
|
// Marshal the response
|
2019-11-09 12:27:23 -05:00
|
|
|
data, err := json.Marshal(allCredentials)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
econfigData, err := madmin.EncryptData(password, data)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, econfigData)
|
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// GetUserInfo - GET /minio/admin/v3/user-info
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) GetUserInfo(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "GetUserInfo")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2020-11-27 20:23:57 -05:00
|
|
|
vars := mux.Vars(r)
|
|
|
|
name := vars["accessKey"]
|
|
|
|
|
|
|
|
// Get current object layer instance.
|
|
|
|
objectAPI := newObjectLayerFn()
|
|
|
|
if objectAPI == nil || globalNotificationSys == nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
2019-11-09 12:27:23 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-11-27 20:23:57 -05:00
|
|
|
cred, claims, owner, s3Err := validateAdminSignature(ctx, r, "")
|
|
|
|
if s3Err != ErrNone {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:03:39 -05:00
|
|
|
checkDenyOnly := false
|
|
|
|
if name == cred.AccessKey {
|
|
|
|
// Check that there is no explicit deny - otherwise it's allowed
|
|
|
|
// to view one's own info.
|
|
|
|
checkDenyOnly = true
|
|
|
|
}
|
|
|
|
|
|
|
|
if !globalIAMSys.IsAllowed(iampolicy.Args{
|
|
|
|
AccountName: cred.AccessKey,
|
|
|
|
Groups: cred.Groups,
|
|
|
|
Action: iampolicy.GetUserAdminAction,
|
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
|
|
|
IsOwner: owner,
|
|
|
|
Claims: claims,
|
|
|
|
DenyOnly: checkDenyOnly,
|
|
|
|
}) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAccessDenied), r.URL)
|
|
|
|
return
|
2020-11-27 20:23:57 -05:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2021-11-15 17:14:22 -05:00
|
|
|
userInfo, err := globalIAMSys.GetUserInfo(ctx, name)
|
2019-11-09 12:27:23 -05:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err := json.Marshal(userInfo)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, data)
|
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// UpdateGroupMembers - PUT /minio/admin/v3/update-group-members
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) UpdateGroupMembers(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "UpdateGroupMembers")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.AddUserToGroupAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err := ioutil.ReadAll(r.Body)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrInvalidRequest), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var updReq madmin.GroupAddRemove
|
|
|
|
err = json.Unmarshal(data, &updReq)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrInvalidRequest), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if updReq.IsRemove {
|
2021-11-15 17:14:22 -05:00
|
|
|
err = globalIAMSys.RemoveUsersFromGroup(ctx, updReq.Group, updReq.Members)
|
2019-11-09 12:27:23 -05:00
|
|
|
} else {
|
2022-05-02 12:27:35 -04:00
|
|
|
// Check if group already exists
|
|
|
|
if _, gerr := globalIAMSys.GetGroupDescription(updReq.Group); gerr != nil {
|
|
|
|
// If group does not exist, then check if the group has beginning and end space characters
|
|
|
|
// we will reject such group names.
|
|
|
|
if errors.Is(gerr, errNoSuchGroup) && hasSpaceBE(updReq.Group) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminResourceInvalidArgument), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2021-11-15 17:14:22 -05:00
|
|
|
err = globalIAMSys.AddUsersToGroup(ctx, updReq.Group, updReq.Members)
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2022-01-06 18:52:43 -05:00
|
|
|
|
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemGroupInfo,
|
|
|
|
GroupInfo: &madmin.SRGroupInfo{
|
|
|
|
UpdateReq: updReq,
|
|
|
|
},
|
|
|
|
}); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// GetGroup - /minio/admin/v3/group?group=mygroup1
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) GetGroup(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "GetGroup")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.GetGroupAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
group := vars["group"]
|
|
|
|
|
|
|
|
gdesc, err := globalIAMSys.GetGroupDescription(group)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
body, err := json.Marshal(gdesc)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, body)
|
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// ListGroups - GET /minio/admin/v3/groups
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) ListGroups(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "ListGroups")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.ListGroupsAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-11-15 17:14:22 -05:00
|
|
|
groups, err := globalIAMSys.ListGroups(ctx)
|
2019-11-09 12:27:23 -05:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
body, err := json.Marshal(groups)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, body)
|
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// SetGroupStatus - PUT /minio/admin/v3/set-group-status?group=mygroup1&status=enabled
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) SetGroupStatus(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "SetGroupStatus")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.EnableGroupAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
group := vars["group"]
|
|
|
|
status := vars["status"]
|
|
|
|
|
|
|
|
var err error
|
2021-11-16 12:28:29 -05:00
|
|
|
switch status {
|
|
|
|
case statusEnabled:
|
2021-11-15 17:14:22 -05:00
|
|
|
err = globalIAMSys.SetGroupStatus(ctx, group, true)
|
2021-11-16 12:28:29 -05:00
|
|
|
case statusDisabled:
|
2021-11-15 17:14:22 -05:00
|
|
|
err = globalIAMSys.SetGroupStatus(ctx, group, false)
|
2021-11-16 12:28:29 -05:00
|
|
|
default:
|
2019-11-09 12:27:23 -05:00
|
|
|
err = errInvalidArgument
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2022-01-19 23:02:24 -05:00
|
|
|
|
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemGroupInfo,
|
|
|
|
GroupInfo: &madmin.SRGroupInfo{
|
|
|
|
UpdateReq: madmin.GroupAddRemove{
|
|
|
|
Group: group,
|
|
|
|
Status: madmin.GroupStatus(status),
|
|
|
|
IsRemove: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// SetUserStatus - PUT /minio/admin/v3/set-user-status?accessKey=<access_key>&status=[enabled|disabled]
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) SetUserStatus(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "SetUserStatus")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.EnableUserAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
accessKey := vars["accessKey"]
|
|
|
|
status := vars["status"]
|
|
|
|
|
2022-01-19 23:02:24 -05:00
|
|
|
// This API is not allowed to lookup master access key user status
|
2019-11-09 12:27:23 -05:00
|
|
|
if accessKey == globalActiveCred.AccessKey {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrInvalidRequest), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-11-15 17:14:22 -05:00
|
|
|
if err := globalIAMSys.SetUserStatus(ctx, accessKey, madmin.AccountStatus(status)); err != nil {
|
2019-11-09 12:27:23 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2022-01-19 23:02:24 -05:00
|
|
|
|
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemIAMUser,
|
|
|
|
IAMUser: &madmin.SRIAMUser{
|
|
|
|
AccessKey: accessKey,
|
|
|
|
IsDeleteReq: false,
|
|
|
|
UserReq: &madmin.AddOrUpdateUserReq{
|
|
|
|
Status: madmin.AccountStatus(status),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// AddUser - PUT /minio/admin/v3/add-user?accessKey=<access_key>
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) AddUser(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "AddUser")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2020-11-27 20:23:57 -05:00
|
|
|
vars := mux.Vars(r)
|
2021-04-15 19:32:13 -04:00
|
|
|
accessKey := vars["accessKey"]
|
2020-11-27 20:23:57 -05:00
|
|
|
|
|
|
|
// Get current object layer instance.
|
|
|
|
objectAPI := newObjectLayerFn()
|
|
|
|
if objectAPI == nil || globalNotificationSys == nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
2019-11-09 12:27:23 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-11-27 20:23:57 -05:00
|
|
|
cred, claims, owner, s3Err := validateAdminSignature(ctx, r, "")
|
|
|
|
if s3Err != ErrNone {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2020-12-19 16:24:21 -05:00
|
|
|
// Not allowed to add a user with same access key as root credential
|
|
|
|
if owner && accessKey == cred.AccessKey {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAddUserInvalidArgument), r.URL)
|
2020-11-27 20:23:57 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-09 20:48:51 -05:00
|
|
|
userCred, exists := globalIAMSys.GetUser(ctx, accessKey)
|
|
|
|
if exists && (userCred.IsTemp() || userCred.IsServiceAccount()) {
|
|
|
|
// Updating STS credential is not allowed, and this API does not
|
|
|
|
// support updating service accounts.
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAddUserInvalidArgument), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-12-19 16:24:21 -05:00
|
|
|
if (cred.IsTemp() || cred.IsServiceAccount()) && cred.ParentUser == accessKey {
|
|
|
|
// Incoming access key matches parent user then we should
|
|
|
|
// reject password change requests.
|
2019-11-09 12:27:23 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAddUserInvalidArgument), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-02 12:27:35 -04:00
|
|
|
// Check if accessKey has beginning and end space characters, this only applies to new users.
|
|
|
|
if !exists && hasSpaceBE(accessKey) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminResourceInvalidArgument), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-09 20:48:51 -05:00
|
|
|
checkDenyOnly := false
|
|
|
|
if accessKey == cred.AccessKey {
|
|
|
|
// Check that there is no explicit deny - otherwise it's allowed
|
|
|
|
// to change one's own password.
|
|
|
|
checkDenyOnly = true
|
2020-11-27 20:23:57 -05:00
|
|
|
}
|
|
|
|
|
2021-12-09 20:48:51 -05:00
|
|
|
if !globalIAMSys.IsAllowed(iampolicy.Args{
|
|
|
|
AccountName: cred.AccessKey,
|
2021-03-23 18:15:51 -04:00
|
|
|
Groups: cred.Groups,
|
2021-03-02 18:35:50 -05:00
|
|
|
Action: iampolicy.CreateUserAdminAction,
|
2021-12-09 20:48:51 -05:00
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
2021-03-02 20:02:29 -05:00
|
|
|
IsOwner: owner,
|
2021-03-02 18:35:50 -05:00
|
|
|
Claims: claims,
|
2021-12-09 20:48:51 -05:00
|
|
|
DenyOnly: checkDenyOnly,
|
2021-03-02 18:35:50 -05:00
|
|
|
}) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAccessDenied), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-11-09 12:27:23 -05:00
|
|
|
if r.ContentLength > maxEConfigJSONSize || r.ContentLength == -1 {
|
|
|
|
// More than maxConfigSize bytes were available
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigTooLarge), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-11-19 05:03:18 -05:00
|
|
|
password := cred.SecretKey
|
2019-11-09 12:27:23 -05:00
|
|
|
configBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
|
|
|
if err != nil {
|
|
|
|
logger.LogIf(ctx, err)
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-23 12:21:21 -05:00
|
|
|
var ureq madmin.AddOrUpdateUserReq
|
|
|
|
if err = json.Unmarshal(configBytes, &ureq); err != nil {
|
2019-11-09 12:27:23 -05:00
|
|
|
logger.LogIf(ctx, err)
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-23 12:21:21 -05:00
|
|
|
if err = globalIAMSys.CreateUser(ctx, accessKey, ureq); err != nil {
|
2019-11-09 12:27:23 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2022-01-06 18:52:43 -05:00
|
|
|
|
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemIAMUser,
|
|
|
|
IAMUser: &madmin.SRIAMUser{
|
|
|
|
AccessKey: accessKey,
|
|
|
|
IsDeleteReq: false,
|
|
|
|
UserReq: &ureq,
|
|
|
|
},
|
|
|
|
}); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
|
2020-04-14 14:28:56 -04:00
|
|
|
// AddServiceAccount - PUT /minio/admin/v3/add-service-account
|
2020-03-17 13:36:13 -04:00
|
|
|
func (a adminAPIHandlers) AddServiceAccount(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "AddServiceAccount")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2020-04-14 14:28:56 -04:00
|
|
|
// Get current object layer instance.
|
2020-10-09 12:59:52 -04:00
|
|
|
objectAPI := newObjectLayerFn()
|
2020-10-19 12:54:40 -04:00
|
|
|
if objectAPI == nil || globalNotificationSys == nil {
|
2020-04-14 14:28:56 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
2020-03-17 13:36:13 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
cred, claims, owner, s3Err := validateAdminSignature(ctx, r, "")
|
2020-04-14 14:28:56 -04:00
|
|
|
if s3Err != ErrNone {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
2020-03-17 13:36:13 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
password := cred.SecretKey
|
2020-04-24 15:10:09 -04:00
|
|
|
reqBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
2020-03-17 13:36:13 -04:00
|
|
|
if err != nil {
|
2020-04-14 14:28:56 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrAdminConfigBadJSON, err), r.URL)
|
2020-03-17 13:36:13 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var createReq madmin.AddServiceAccountReq
|
2020-04-24 15:10:09 -04:00
|
|
|
if err = json.Unmarshal(reqBytes, &createReq); err != nil {
|
2020-04-14 14:28:56 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrAdminConfigBadJSON, err), r.URL)
|
2020-03-17 13:36:13 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-02 12:27:35 -04:00
|
|
|
// service account access key cannot have space characters beginning and end of the string.
|
|
|
|
if hasSpaceBE(createReq.AccessKey) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminResourceInvalidArgument), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
var (
|
|
|
|
targetUser string
|
|
|
|
targetGroups []string
|
|
|
|
)
|
|
|
|
|
2021-09-20 17:28:19 -04:00
|
|
|
// If the request did not set a TargetUser, the service account is
|
|
|
|
// created for the request sender.
|
2021-04-15 01:51:14 -04:00
|
|
|
targetUser = createReq.TargetUser
|
2021-09-20 17:28:19 -04:00
|
|
|
if targetUser == "" {
|
|
|
|
targetUser = cred.AccessKey
|
|
|
|
}
|
|
|
|
|
|
|
|
opts := newServiceAccountOpts{
|
|
|
|
accessKey: createReq.AccessKey,
|
|
|
|
secretKey: createReq.SecretKey,
|
2021-10-05 14:49:33 -04:00
|
|
|
claims: make(map[string]interface{}),
|
2021-09-20 17:28:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Find the user for the request sender (as it may be sent via a service
|
|
|
|
// account or STS account):
|
|
|
|
requestorUser := cred.AccessKey
|
|
|
|
requestorParentUser := cred.AccessKey
|
|
|
|
requestorGroups := cred.Groups
|
|
|
|
requestorIsDerivedCredential := false
|
|
|
|
if cred.IsServiceAccount() || cred.IsTemp() {
|
|
|
|
requestorParentUser = cred.ParentUser
|
|
|
|
requestorIsDerivedCredential = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if we are creating svc account for request sender.
|
|
|
|
isSvcAccForRequestor := false
|
|
|
|
if targetUser == requestorUser || targetUser == requestorParentUser {
|
|
|
|
isSvcAccForRequestor = true
|
|
|
|
}
|
2021-04-15 01:51:14 -04:00
|
|
|
|
2021-09-20 17:28:19 -04:00
|
|
|
// If we are creating svc account for request sender, ensure
|
|
|
|
// that targetUser is a real user (i.e. not derived
|
|
|
|
// credentials).
|
|
|
|
if isSvcAccForRequestor {
|
2021-11-15 09:57:52 -05:00
|
|
|
// Check if adding service account is explicitly denied.
|
|
|
|
//
|
|
|
|
// This allows turning off service accounts for request sender,
|
|
|
|
// if there is no deny statement this call is implicitly enabled.
|
|
|
|
if !globalIAMSys.IsAllowed(iampolicy.Args{
|
|
|
|
AccountName: requestorUser,
|
2021-12-06 18:55:11 -05:00
|
|
|
Groups: requestorGroups,
|
2021-11-15 09:57:52 -05:00
|
|
|
Action: iampolicy.CreateServiceAccountAdminAction,
|
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
|
|
|
IsOwner: owner,
|
|
|
|
Claims: claims,
|
|
|
|
DenyOnly: true,
|
|
|
|
}) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAccessDenied), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-09-20 17:28:19 -04:00
|
|
|
if requestorIsDerivedCredential {
|
|
|
|
if requestorParentUser == "" {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx,
|
|
|
|
errors.New("service accounts cannot be generated for temporary credentials without parent")), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
targetUser = requestorParentUser
|
|
|
|
}
|
|
|
|
targetGroups = requestorGroups
|
|
|
|
|
2021-10-05 14:49:33 -04:00
|
|
|
// In case of LDAP/OIDC we need to set `opts.claims` to ensure
|
|
|
|
// it is associated with the LDAP/OIDC user properly.
|
|
|
|
for k, v := range cred.Claims {
|
|
|
|
if k == expClaim {
|
|
|
|
continue
|
2021-09-20 17:28:19 -04:00
|
|
|
}
|
2021-10-05 14:49:33 -04:00
|
|
|
opts.claims[k] = v
|
2021-09-20 17:28:19 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Need permission if we are creating a service acccount for a
|
|
|
|
// user <> to the request sender
|
2021-04-15 01:51:14 -04:00
|
|
|
if !globalIAMSys.IsAllowed(iampolicy.Args{
|
2021-09-20 17:28:19 -04:00
|
|
|
AccountName: requestorUser,
|
2021-12-06 18:55:11 -05:00
|
|
|
Groups: requestorGroups,
|
2021-04-15 01:51:14 -04:00
|
|
|
Action: iampolicy.CreateServiceAccountAdminAction,
|
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
|
|
|
IsOwner: owner,
|
|
|
|
Claims: claims,
|
|
|
|
}) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAccessDenied), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2020-04-28 15:49:56 -04:00
|
|
|
|
2021-09-20 17:28:19 -04:00
|
|
|
// In case of LDAP we need to resolve the targetUser to a DN and
|
|
|
|
// query their groups:
|
|
|
|
if globalLDAPConfig.Enabled {
|
2021-10-05 14:49:33 -04:00
|
|
|
opts.claims[ldapUserN] = targetUser // simple username
|
2021-09-20 17:28:19 -04:00
|
|
|
targetUser, targetGroups, err = globalLDAPConfig.LookupUserDN(targetUser)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
2021-04-29 16:01:42 -04:00
|
|
|
return
|
|
|
|
}
|
2021-10-05 14:49:33 -04:00
|
|
|
opts.claims[ldapUser] = targetUser // username DN
|
2021-05-13 00:25:07 -04:00
|
|
|
}
|
2021-09-20 17:28:19 -04:00
|
|
|
|
|
|
|
// NOTE: if not using LDAP, then internal IDP or open ID is
|
|
|
|
// being used - in the former, group info is enforced when
|
|
|
|
// generated credentials are used to make requests, and in the
|
|
|
|
// latter, a group notion is not supported.
|
2021-04-15 01:51:14 -04:00
|
|
|
}
|
|
|
|
|
2021-05-06 11:52:02 -04:00
|
|
|
var sp *iampolicy.Policy
|
|
|
|
if len(createReq.Policy) > 0 {
|
|
|
|
sp, err = iampolicy.ParseConfig(bytes.NewReader(createReq.Policy))
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-20 17:28:19 -04:00
|
|
|
opts.sessionPolicy = sp
|
2021-04-15 01:51:14 -04:00
|
|
|
newCred, err := globalIAMSys.NewServiceAccount(ctx, targetUser, targetGroups, opts)
|
2020-03-17 13:36:13 -04:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-20 22:09:11 -04:00
|
|
|
createResp := madmin.AddServiceAccountResp{
|
|
|
|
Credentials: madmin.Credentials{
|
|
|
|
AccessKey: newCred.AccessKey,
|
|
|
|
SecretKey: newCred.SecretKey,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err := json.Marshal(createResp)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
encryptedData, err := madmin.EncryptData(password, data)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, encryptedData)
|
|
|
|
|
2022-01-06 18:52:43 -05:00
|
|
|
// Call hook for cluster-replication if the service account is not for a
|
|
|
|
// root user.
|
|
|
|
if newCred.ParentUser != globalActiveCred.AccessKey {
|
2021-10-06 19:36:31 -04:00
|
|
|
err = globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemSvcAcc,
|
|
|
|
SvcAccChange: &madmin.SRSvcAccChange{
|
|
|
|
Create: &madmin.SRSvcAccCreate{
|
|
|
|
Parent: newCred.ParentUser,
|
|
|
|
AccessKey: newCred.AccessKey,
|
|
|
|
SecretKey: newCred.SecretKey,
|
|
|
|
Groups: newCred.Groups,
|
|
|
|
Claims: opts.claims,
|
|
|
|
SessionPolicy: createReq.Policy,
|
|
|
|
Status: auth.AccountOn,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
if err != nil {
|
2022-05-20 22:09:11 -04:00
|
|
|
logger.LogIf(ctx, err)
|
2021-10-06 19:36:31 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2020-04-24 15:10:09 -04:00
|
|
|
}
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
// UpdateServiceAccount - POST /minio/admin/v3/update-service-account
|
|
|
|
func (a adminAPIHandlers) UpdateServiceAccount(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "UpdateServiceAccount")
|
|
|
|
|
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
|
|
|
|
|
|
|
// Get current object layer instance.
|
|
|
|
objectAPI := newObjectLayerFn()
|
|
|
|
if objectAPI == nil || globalNotificationSys == nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cred, claims, owner, s3Err := validateAdminSignature(ctx, r, "")
|
|
|
|
if s3Err != ErrNone {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
accessKey := mux.Vars(r)["accessKey"]
|
|
|
|
if accessKey == "" {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrInvalidRequest), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
svcAccount, _, err := globalIAMSys.GetServiceAccount(ctx, accessKey)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !globalIAMSys.IsAllowed(iampolicy.Args{
|
|
|
|
AccountName: cred.AccessKey,
|
|
|
|
Action: iampolicy.UpdateServiceAccountAdminAction,
|
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
|
|
|
IsOwner: owner,
|
|
|
|
Claims: claims,
|
|
|
|
}) {
|
|
|
|
requestUser := cred.AccessKey
|
|
|
|
if cred.ParentUser != "" {
|
|
|
|
requestUser = cred.ParentUser
|
|
|
|
}
|
|
|
|
|
|
|
|
if requestUser != svcAccount.ParentUser {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAccessDenied), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
password := cred.SecretKey
|
|
|
|
reqBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrAdminConfigBadJSON, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var updateReq madmin.UpdateServiceAccountReq
|
|
|
|
if err = json.Unmarshal(reqBytes, &updateReq); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErrWithErr(ErrAdminConfigBadJSON, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-05-06 11:52:02 -04:00
|
|
|
var sp *iampolicy.Policy
|
|
|
|
if len(updateReq.NewPolicy) > 0 {
|
|
|
|
sp, err = iampolicy.ParseConfig(bytes.NewReader(updateReq.NewPolicy))
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
opts := updateServiceAccountOpts{
|
|
|
|
secretKey: updateReq.NewSecretKey,
|
|
|
|
status: updateReq.NewStatus,
|
|
|
|
sessionPolicy: sp,
|
|
|
|
}
|
2021-04-15 01:51:14 -04:00
|
|
|
err = globalIAMSys.UpdateServiceAccount(ctx, accessKey, opts)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-01-07 20:41:43 -05:00
|
|
|
// Call site replication hook - non-root user accounts are replicated.
|
|
|
|
if svcAccount.ParentUser != globalActiveCred.AccessKey {
|
2021-10-06 19:36:31 -04:00
|
|
|
err = globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemSvcAcc,
|
|
|
|
SvcAccChange: &madmin.SRSvcAccChange{
|
|
|
|
Update: &madmin.SRSvcAccUpdate{
|
|
|
|
AccessKey: accessKey,
|
|
|
|
SecretKey: opts.secretKey,
|
|
|
|
Status: opts.status,
|
|
|
|
SessionPolicy: updateReq.NewPolicy,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2022-01-07 20:41:43 -05:00
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
writeSuccessNoContent(w)
|
|
|
|
}
|
|
|
|
|
|
|
|
// InfoServiceAccount - GET /minio/admin/v3/info-service-account
|
|
|
|
func (a adminAPIHandlers) InfoServiceAccount(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "InfoServiceAccount")
|
|
|
|
|
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
|
|
|
|
|
|
|
// Get current object layer instance.
|
|
|
|
objectAPI := newObjectLayerFn()
|
|
|
|
if objectAPI == nil || globalNotificationSys == nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cred, claims, owner, s3Err := validateAdminSignature(ctx, r, "")
|
|
|
|
if s3Err != ErrNone {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
accessKey := mux.Vars(r)["accessKey"]
|
|
|
|
if accessKey == "" {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrInvalidRequest), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
svcAccount, policy, err := globalIAMSys.GetServiceAccount(ctx, accessKey)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !globalIAMSys.IsAllowed(iampolicy.Args{
|
|
|
|
AccountName: cred.AccessKey,
|
|
|
|
Action: iampolicy.ListServiceAccountsAdminAction,
|
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
|
|
|
IsOwner: owner,
|
|
|
|
Claims: claims,
|
|
|
|
}) {
|
|
|
|
requestUser := cred.AccessKey
|
|
|
|
if cred.ParentUser != "" {
|
|
|
|
requestUser = cred.ParentUser
|
|
|
|
}
|
|
|
|
|
|
|
|
if requestUser != svcAccount.ParentUser {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAccessDenied), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var svcAccountPolicy iampolicy.Policy
|
|
|
|
|
2022-01-10 17:26:26 -05:00
|
|
|
if policy != nil {
|
|
|
|
svcAccountPolicy = *policy
|
2021-04-15 01:51:14 -04:00
|
|
|
} else {
|
2021-04-21 21:12:02 -04:00
|
|
|
policiesNames, err := globalIAMSys.PolicyDBGet(svcAccount.ParentUser, false)
|
2021-04-15 01:51:14 -04:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2022-01-10 17:26:26 -05:00
|
|
|
svcAccountPolicy = globalIAMSys.GetCombinedPolicy(policiesNames...)
|
2021-04-15 01:51:14 -04:00
|
|
|
}
|
|
|
|
|
2021-05-29 12:22:22 -04:00
|
|
|
policyJSON, err := json.MarshalIndent(svcAccountPolicy, "", " ")
|
2021-04-15 01:51:14 -04:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-01-02 12:15:06 -05:00
|
|
|
infoResp := madmin.InfoServiceAccountResp{
|
2021-04-15 01:51:14 -04:00
|
|
|
ParentUser: svcAccount.ParentUser,
|
|
|
|
AccountStatus: svcAccount.Status,
|
2022-01-10 17:26:26 -05:00
|
|
|
ImpliedPolicy: policy == nil,
|
2021-04-15 01:51:14 -04:00
|
|
|
Policy: string(policyJSON),
|
|
|
|
}
|
|
|
|
|
|
|
|
data, err := json.Marshal(infoResp)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
encryptedData, err := madmin.EncryptData(cred.SecretKey, data)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, encryptedData)
|
|
|
|
}
|
|
|
|
|
2020-04-24 15:10:09 -04:00
|
|
|
// ListServiceAccounts - GET /minio/admin/v3/list-service-accounts
|
|
|
|
func (a adminAPIHandlers) ListServiceAccounts(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "ListServiceAccounts")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2020-04-24 15:10:09 -04:00
|
|
|
// Get current object layer instance.
|
2020-10-09 12:59:52 -04:00
|
|
|
objectAPI := newObjectLayerFn()
|
2020-10-19 12:54:40 -04:00
|
|
|
if objectAPI == nil || globalNotificationSys == nil {
|
2020-04-24 15:10:09 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
cred, claims, owner, s3Err := validateAdminSignature(ctx, r, "")
|
2020-04-24 15:10:09 -04:00
|
|
|
if s3Err != ErrNone {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
var targetAccount string
|
|
|
|
|
2021-11-19 15:35:35 -05:00
|
|
|
// If listing is requested for a specific user (who is not the request
|
|
|
|
// sender), check that the user has permissions.
|
2021-08-08 01:43:01 -04:00
|
|
|
user := r.Form.Get("user")
|
2021-11-19 15:35:35 -05:00
|
|
|
if user != "" && user != cred.AccessKey {
|
2021-04-15 01:51:14 -04:00
|
|
|
if !globalIAMSys.IsAllowed(iampolicy.Args{
|
|
|
|
AccountName: cred.AccessKey,
|
|
|
|
Action: iampolicy.ListServiceAccountsAdminAction,
|
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
|
|
|
IsOwner: owner,
|
|
|
|
Claims: claims,
|
|
|
|
}) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAccessDenied), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
targetAccount = user
|
|
|
|
} else {
|
|
|
|
targetAccount = cred.AccessKey
|
|
|
|
if cred.ParentUser != "" {
|
|
|
|
targetAccount = cred.ParentUser
|
|
|
|
}
|
2020-05-01 11:05:14 -04:00
|
|
|
}
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
serviceAccounts, err := globalIAMSys.ListServiceAccounts(ctx, targetAccount)
|
2020-04-24 15:10:09 -04:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
var serviceAccountsNames []string
|
|
|
|
|
|
|
|
for _, svc := range serviceAccounts {
|
|
|
|
serviceAccountsNames = append(serviceAccountsNames, svc.AccessKey)
|
|
|
|
}
|
|
|
|
|
2022-01-02 12:15:06 -05:00
|
|
|
listResp := madmin.ListServiceAccountsResp{
|
2021-04-15 01:51:14 -04:00
|
|
|
Accounts: serviceAccountsNames,
|
2020-04-24 15:10:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err := json.Marshal(listResp)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
encryptedData, err := madmin.EncryptData(cred.SecretKey, data)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, encryptedData)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeleteServiceAccount - DELETE /minio/admin/v3/delete-service-account
|
|
|
|
func (a adminAPIHandlers) DeleteServiceAccount(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "DeleteServiceAccount")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2020-04-24 15:10:09 -04:00
|
|
|
// Get current object layer instance.
|
2020-10-09 12:59:52 -04:00
|
|
|
objectAPI := newObjectLayerFn()
|
2020-10-19 12:54:40 -04:00
|
|
|
if objectAPI == nil || globalNotificationSys == nil {
|
2020-04-24 15:10:09 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
cred, claims, owner, s3Err := validateAdminSignature(ctx, r, "")
|
2020-04-24 15:10:09 -04:00
|
|
|
if s3Err != ErrNone {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
serviceAccount := mux.Vars(r)["accessKey"]
|
|
|
|
if serviceAccount == "" {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminInvalidArgument), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-02 20:56:19 -04:00
|
|
|
// We do not care if service account is readable or not at this point,
|
|
|
|
// since this is a delete call we shall allow it to be deleted if possible.
|
|
|
|
svcAccount, _, _ := globalIAMSys.GetServiceAccount(ctx, serviceAccount)
|
2020-04-24 15:10:09 -04:00
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
adminPrivilege := globalIAMSys.IsAllowed(iampolicy.Args{
|
|
|
|
AccountName: cred.AccessKey,
|
|
|
|
Action: iampolicy.RemoveServiceAccountAdminAction,
|
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
|
|
|
IsOwner: owner,
|
|
|
|
Claims: claims,
|
|
|
|
})
|
2020-05-01 11:05:14 -04:00
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
if !adminPrivilege {
|
|
|
|
parentUser := cred.AccessKey
|
|
|
|
if cred.ParentUser != "" {
|
|
|
|
parentUser = cred.ParentUser
|
|
|
|
}
|
2022-05-02 20:56:19 -04:00
|
|
|
if svcAccount.ParentUser != "" && parentUser != svcAccount.ParentUser {
|
2021-04-15 01:51:14 -04:00
|
|
|
// The service account belongs to another user but return not
|
|
|
|
// found error to mitigate brute force attacks. or the
|
|
|
|
// serviceAccount doesn't exist.
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminServiceAccountNotFound), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2020-04-24 15:10:09 -04:00
|
|
|
}
|
|
|
|
|
2022-05-02 20:56:19 -04:00
|
|
|
if err := globalIAMSys.DeleteServiceAccount(ctx, serviceAccount, true); err != nil {
|
2020-04-24 15:10:09 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2021-07-15 00:28:53 -04:00
|
|
|
|
2022-01-07 20:41:43 -05:00
|
|
|
// Call site replication hook - non-root user accounts are replicated.
|
2022-05-02 20:56:19 -04:00
|
|
|
if svcAccount.ParentUser != "" && svcAccount.ParentUser != globalActiveCred.AccessKey {
|
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
2021-10-06 19:36:31 -04:00
|
|
|
Type: madmin.SRIAMItemSvcAcc,
|
|
|
|
SvcAccChange: &madmin.SRSvcAccChange{
|
|
|
|
Delete: &madmin.SRSvcAccDelete{
|
|
|
|
AccessKey: serviceAccount,
|
|
|
|
},
|
|
|
|
},
|
2022-05-02 20:56:19 -04:00
|
|
|
}); err != nil {
|
2021-10-06 19:36:31 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-24 15:10:09 -04:00
|
|
|
writeSuccessNoContent(w)
|
2020-03-17 13:36:13 -04:00
|
|
|
}
|
|
|
|
|
2020-11-27 20:23:57 -05:00
|
|
|
// AccountInfoHandler returns usage
|
|
|
|
func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "AccountInfo")
|
2020-05-15 21:16:45 -04:00
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-15 21:16:45 -04:00
|
|
|
|
|
|
|
// Get current object layer instance.
|
2020-10-09 12:59:52 -04:00
|
|
|
objectAPI := newObjectLayerFn()
|
2020-10-19 12:54:40 -04:00
|
|
|
if objectAPI == nil || globalNotificationSys == nil {
|
2020-05-15 21:16:45 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
cred, claims, owner, s3Err := validateAdminSignature(ctx, r, "")
|
|
|
|
if s3Err != ErrNone {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set prefix value for "s3:prefix" policy conditionals.
|
|
|
|
r.Header.Set("prefix", "")
|
|
|
|
|
|
|
|
// Set delimiter value for "s3:delimiter" policy conditionals.
|
|
|
|
r.Header.Set("delimiter", SlashSeparator)
|
|
|
|
|
2021-07-14 11:51:10 -04:00
|
|
|
// Check if we are asked to return prefix usage
|
2021-08-08 01:43:01 -04:00
|
|
|
enablePrefixUsage := r.Form.Get("prefix-usage") == "true"
|
2021-07-14 11:51:10 -04:00
|
|
|
|
2020-05-15 21:16:45 -04:00
|
|
|
isAllowedAccess := func(bucketName string) (rd, wr bool) {
|
|
|
|
if globalIAMSys.IsAllowed(iampolicy.Args{
|
2021-07-11 20:39:52 -04:00
|
|
|
AccountName: cred.AccessKey,
|
2021-03-23 18:15:51 -04:00
|
|
|
Groups: cred.Groups,
|
2020-05-15 21:16:45 -04:00
|
|
|
Action: iampolicy.ListBucketAction,
|
|
|
|
BucketName: bucketName,
|
2021-07-11 20:39:52 -04:00
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
2020-05-15 21:16:45 -04:00
|
|
|
IsOwner: owner,
|
|
|
|
ObjectName: "",
|
|
|
|
Claims: claims,
|
|
|
|
}) {
|
|
|
|
rd = true
|
|
|
|
}
|
|
|
|
|
2022-05-12 13:46:20 -04:00
|
|
|
if globalIAMSys.IsAllowed(iampolicy.Args{
|
|
|
|
AccountName: cred.AccessKey,
|
|
|
|
Groups: cred.Groups,
|
|
|
|
Action: iampolicy.GetBucketLocationAction,
|
|
|
|
BucketName: bucketName,
|
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
|
|
|
IsOwner: owner,
|
|
|
|
ObjectName: "",
|
|
|
|
Claims: claims,
|
|
|
|
}) {
|
|
|
|
rd = true
|
|
|
|
}
|
|
|
|
|
2020-05-15 21:16:45 -04:00
|
|
|
if globalIAMSys.IsAllowed(iampolicy.Args{
|
2021-07-11 20:39:52 -04:00
|
|
|
AccountName: cred.AccessKey,
|
2021-03-23 18:15:51 -04:00
|
|
|
Groups: cred.Groups,
|
2020-05-15 21:16:45 -04:00
|
|
|
Action: iampolicy.PutObjectAction,
|
|
|
|
BucketName: bucketName,
|
2021-07-11 20:39:52 -04:00
|
|
|
ConditionValues: getConditionValues(r, "", cred.AccessKey, claims),
|
2020-05-15 21:16:45 -04:00
|
|
|
IsOwner: owner,
|
|
|
|
ObjectName: "",
|
|
|
|
Claims: claims,
|
|
|
|
}) {
|
|
|
|
wr = true
|
|
|
|
}
|
|
|
|
|
|
|
|
return rd, wr
|
|
|
|
}
|
|
|
|
|
2021-09-18 16:31:35 -04:00
|
|
|
var dataUsageInfo DataUsageInfo
|
2021-07-09 13:35:09 -04:00
|
|
|
var err error
|
|
|
|
if !globalIsGateway {
|
|
|
|
// Load the latest calculated data usage
|
2022-01-11 11:43:18 -05:00
|
|
|
dataUsageInfo, _ = loadDataUsageFromBackend(ctx, objectAPI)
|
2020-05-15 21:16:45 -04:00
|
|
|
}
|
|
|
|
|
2021-02-09 12:53:07 -05:00
|
|
|
// If etcd, dns federation configured list buckets from etcd.
|
|
|
|
var buckets []BucketInfo
|
|
|
|
if globalDNSConfig != nil && globalBucketFederation {
|
|
|
|
dnsBuckets, err := globalDNSConfig.List()
|
|
|
|
if err != nil && !IsErrIgnored(err,
|
|
|
|
dns.ErrNoEntriesFound,
|
|
|
|
dns.ErrDomainMissing) {
|
2021-06-15 21:52:01 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
2021-02-09 12:53:07 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
for _, dnsRecords := range dnsBuckets {
|
|
|
|
buckets = append(buckets, BucketInfo{
|
|
|
|
Name: dnsRecords[0].Key,
|
|
|
|
Created: dnsRecords[0].CreationDate,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
sort.Slice(buckets, func(i, j int) bool {
|
|
|
|
return buckets[i].Name < buckets[j].Name
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
buckets, err = objectAPI.ListBuckets(ctx)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-15 21:16:45 -04:00
|
|
|
accountName := cred.AccessKey
|
2021-12-20 17:07:16 -05:00
|
|
|
if cred.IsTemp() || cred.IsServiceAccount() {
|
|
|
|
// For derived credentials, check the parent user's permissions.
|
|
|
|
accountName = cred.ParentUser
|
2021-03-23 20:39:20 -04:00
|
|
|
}
|
2021-12-20 17:07:16 -05:00
|
|
|
policies, err := globalIAMSys.PolicyDBGet(accountName, false, cred.Groups...)
|
2020-11-27 20:23:57 -05:00
|
|
|
if err != nil {
|
|
|
|
logger.LogIf(ctx, err)
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-05-29 12:22:22 -04:00
|
|
|
buf, err := json.MarshalIndent(globalIAMSys.GetCombinedPolicy(policies...), "", " ")
|
2021-05-06 11:52:02 -04:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-11-27 20:23:57 -05:00
|
|
|
acctInfo := madmin.AccountInfo{
|
2020-05-15 21:16:45 -04:00
|
|
|
AccountName: accountName,
|
2021-07-16 17:37:06 -04:00
|
|
|
Server: objectAPI.BackendInfo(),
|
2021-05-06 11:52:02 -04:00
|
|
|
Policy: buf,
|
2020-05-15 21:16:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, bucket := range buckets {
|
|
|
|
rd, wr := isAllowedAccess(bucket.Name)
|
|
|
|
if rd || wr {
|
|
|
|
// Fetch the data usage of the current bucket
|
2021-07-14 11:51:10 -04:00
|
|
|
var size uint64
|
2021-09-17 18:02:21 -04:00
|
|
|
var objectsCount uint64
|
|
|
|
var objectsHist map[string]uint64
|
2020-05-27 09:45:43 -04:00
|
|
|
if !dataUsageInfo.LastUpdate.IsZero() {
|
|
|
|
size = dataUsageInfo.BucketsUsage[bucket.Name].Size
|
2021-09-17 18:02:21 -04:00
|
|
|
objectsCount = dataUsageInfo.BucketsUsage[bucket.Name].ObjectsCount
|
|
|
|
objectsHist = dataUsageInfo.BucketsUsage[bucket.Name].ObjectSizesHistogram
|
2020-05-15 21:16:45 -04:00
|
|
|
}
|
2021-07-14 11:51:10 -04:00
|
|
|
// Fetch the prefix usage of the current bucket
|
|
|
|
var prefixUsage map[string]uint64
|
|
|
|
if enablePrefixUsage {
|
2022-01-11 11:43:18 -05:00
|
|
|
prefixUsage, _ = loadPrefixUsageFromBackend(ctx, objectAPI, bucket.Name)
|
2021-07-14 11:51:10 -04:00
|
|
|
}
|
2021-09-17 18:02:21 -04:00
|
|
|
|
|
|
|
lcfg, _ := globalBucketObjectLockSys.Get(bucket.Name)
|
2022-01-31 20:27:43 -05:00
|
|
|
quota, _ := globalBucketQuotaSys.Get(ctx, bucket.Name)
|
2022-04-24 05:36:31 -04:00
|
|
|
rcfg, _, _ := globalBucketMetadataSys.GetReplicationConfig(ctx, bucket.Name)
|
|
|
|
tcfg, _, _ := globalBucketMetadataSys.GetTaggingConfig(bucket.Name)
|
2021-09-17 18:02:21 -04:00
|
|
|
|
2021-04-03 12:03:42 -04:00
|
|
|
acctInfo.Buckets = append(acctInfo.Buckets, madmin.BucketAccessInfo{
|
2021-09-17 18:02:21 -04:00
|
|
|
Name: bucket.Name,
|
|
|
|
Created: bucket.Created,
|
|
|
|
Size: size,
|
|
|
|
Objects: objectsCount,
|
|
|
|
ObjectSizesHistogram: objectsHist,
|
|
|
|
PrefixUsage: prefixUsage,
|
|
|
|
Details: &madmin.BucketDetails{
|
|
|
|
Versioning: globalBucketVersioningSys.Enabled(bucket.Name),
|
|
|
|
VersioningSuspended: globalBucketVersioningSys.Suspended(bucket.Name),
|
|
|
|
Replication: rcfg != nil,
|
|
|
|
Locking: lcfg.LockEnabled,
|
|
|
|
Quota: quota,
|
|
|
|
Tagging: tcfg,
|
|
|
|
},
|
2020-05-15 21:16:45 -04:00
|
|
|
Access: madmin.AccountAccess{
|
|
|
|
Read: rd,
|
|
|
|
Write: wr,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
usageInfoJSON, err := json.Marshal(acctInfo)
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
writeSuccessResponseJSON(w, usageInfoJSON)
|
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// InfoCannedPolicy - GET /minio/admin/v3/info-canned-policy?name={policyName}
|
2021-12-11 12:03:39 -05:00
|
|
|
//
|
|
|
|
// Newer API response with policy timestamps is returned with query parameter
|
|
|
|
// `v=2` like:
|
|
|
|
//
|
|
|
|
// GET /minio/admin/v3/info-canned-policy?name={policyName}&v=2
|
|
|
|
//
|
|
|
|
// The newer API will eventually become the default (and only) one. The older
|
|
|
|
// response is to return only the policy JSON. The newer response returns
|
|
|
|
// timestamps along with the policy JSON. Both versions are supported for now,
|
|
|
|
// for smooth transition to new API.
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) InfoCannedPolicy(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "InfoCannedPolicy")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.GetPolicyAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-11 12:03:39 -05:00
|
|
|
name := mux.Vars(r)["name"]
|
|
|
|
policies := newMappedPolicy(name).toSlice()
|
|
|
|
if len(policies) != 1 {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, errTooManyPolicies), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
policyDoc, err := globalIAMSys.InfoPolicy(name)
|
2019-11-09 12:27:23 -05:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-11 12:03:39 -05:00
|
|
|
// Is the new API version being requested?
|
|
|
|
infoPolicyAPIVersion := r.Form.Get("v")
|
|
|
|
if infoPolicyAPIVersion == "2" {
|
|
|
|
buf, err := json.MarshalIndent(policyDoc, "", " ")
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
w.Write(buf)
|
|
|
|
return
|
|
|
|
} else if infoPolicyAPIVersion != "" {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, errors.New("invalid version parameter 'v' supplied")), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the older API response value of just the policy json.
|
|
|
|
buf, err := json.MarshalIndent(policyDoc.Policy, "", " ")
|
2021-05-29 12:22:22 -04:00
|
|
|
if err != nil {
|
2020-09-27 13:24:04 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2021-05-29 12:22:22 -04:00
|
|
|
w.Write(buf)
|
2020-04-07 22:30:59 -04:00
|
|
|
}
|
|
|
|
|
2021-05-27 13:15:02 -04:00
|
|
|
// ListBucketPolicies - GET /minio/admin/v3/list-canned-policies?bucket={bucket}
|
|
|
|
func (a adminAPIHandlers) ListBucketPolicies(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "ListBucketPolicies")
|
2020-04-07 22:30:59 -04:00
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.ListUserPoliciesAdminAction)
|
2020-04-07 22:30:59 -04:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-05-27 13:15:02 -04:00
|
|
|
bucket := mux.Vars(r)["bucket"]
|
2021-11-15 17:14:22 -05:00
|
|
|
policies, err := globalIAMSys.ListPolicies(ctx, bucket)
|
2020-04-07 22:30:59 -04:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-01-02 12:15:06 -05:00
|
|
|
newPolicies := make(map[string]iampolicy.Policy)
|
2021-05-27 13:15:02 -04:00
|
|
|
for name, p := range policies {
|
|
|
|
_, err = json.Marshal(p)
|
2020-04-07 22:30:59 -04:00
|
|
|
if err != nil {
|
|
|
|
logger.LogIf(ctx, err)
|
|
|
|
continue
|
|
|
|
}
|
2021-05-27 13:15:02 -04:00
|
|
|
newPolicies[name] = p
|
2020-04-07 22:30:59 -04:00
|
|
|
}
|
2021-05-27 13:15:02 -04:00
|
|
|
if err = json.NewEncoder(w).Encode(newPolicies); err != nil {
|
2020-04-07 22:30:59 -04:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// ListCannedPolicies - GET /minio/admin/v3/list-canned-policies
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) ListCannedPolicies(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "ListCannedPolicies")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.ListUserPoliciesAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-11-15 17:14:22 -05:00
|
|
|
policies, err := globalIAMSys.ListPolicies(ctx, "")
|
2019-11-09 12:27:23 -05:00
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-01-02 12:15:06 -05:00
|
|
|
newPolicies := make(map[string]iampolicy.Policy)
|
2020-04-15 15:16:40 -04:00
|
|
|
for name, p := range policies {
|
|
|
|
_, err = json.Marshal(p)
|
|
|
|
if err != nil {
|
|
|
|
logger.LogIf(ctx, err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
newPolicies[name] = p
|
|
|
|
}
|
|
|
|
if err = json.NewEncoder(w).Encode(newPolicies); err != nil {
|
2019-11-09 12:27:23 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// RemoveCannedPolicy - DELETE /minio/admin/v3/remove-canned-policy?name=<policy_name>
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) RemoveCannedPolicy(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "RemoveCannedPolicy")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.DeletePolicyAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
policyName := vars["name"]
|
|
|
|
|
2021-11-29 17:38:57 -05:00
|
|
|
if err := globalIAMSys.DeletePolicy(ctx, policyName, true); err != nil {
|
2019-11-09 12:27:23 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-10-06 19:36:31 -04:00
|
|
|
// Call cluster-replication policy creation hook to replicate policy deletion to
|
|
|
|
// other minio clusters.
|
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemPolicy,
|
|
|
|
Name: policyName,
|
|
|
|
}); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// AddCannedPolicy - PUT /minio/admin/v3/add-canned-policy?name=<policy_name>
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) AddCannedPolicy(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "AddCannedPolicy")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.CreatePolicyAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
policyName := vars["name"]
|
|
|
|
|
2022-05-02 12:27:35 -04:00
|
|
|
// Policy has space characters in begin and end reject such inputs.
|
|
|
|
if hasSpaceBE(policyName) {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminResourceInvalidArgument), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-11-09 12:27:23 -05:00
|
|
|
// Error out if Content-Length is missing.
|
|
|
|
if r.ContentLength <= 0 {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMissingContentLength), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error out if Content-Length is beyond allowed size.
|
|
|
|
if r.ContentLength > maxBucketPolicySize {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrEntityTooLarge), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-10-06 19:36:31 -04:00
|
|
|
iamPolicyBytes, err := ioutil.ReadAll(io.LimitReader(r.Body, r.ContentLength))
|
|
|
|
if err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
iamPolicy, err := iampolicy.ParseConfig(bytes.NewReader(iamPolicyBytes))
|
2019-11-09 12:27:23 -05:00
|
|
|
if err != nil {
|
2020-01-03 14:28:52 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
2019-11-09 12:27:23 -05:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Version in policy must not be empty
|
|
|
|
if iamPolicy.Version == "" {
|
|
|
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMalformedPolicy), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-11-15 17:14:22 -05:00
|
|
|
if err = globalIAMSys.SetPolicy(ctx, policyName, *iamPolicy); err != nil {
|
2019-11-09 12:27:23 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-10-06 19:36:31 -04:00
|
|
|
// Call cluster-replication policy creation hook to replicate policy to
|
|
|
|
// other minio clusters.
|
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemPolicy,
|
|
|
|
Name: policyName,
|
|
|
|
Policy: iamPolicyBytes,
|
|
|
|
}); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|
|
|
|
|
2020-04-07 22:30:59 -04:00
|
|
|
// SetPolicyForUserOrGroup - PUT /minio/admin/v3/set-policy?policy=xxx&user-or-group=?[&is-group]
|
2019-11-09 12:27:23 -05:00
|
|
|
func (a adminAPIHandlers) SetPolicyForUserOrGroup(w http.ResponseWriter, r *http.Request) {
|
|
|
|
ctx := newContext(r, w, "SetPolicyForUserOrGroup")
|
|
|
|
|
2021-01-26 16:21:51 -05:00
|
|
|
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
|
2020-05-11 13:34:08 -04:00
|
|
|
|
2021-08-09 21:14:38 -04:00
|
|
|
objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.AttachPolicyAdminAction)
|
2019-11-09 12:27:23 -05:00
|
|
|
if objectAPI == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
policyName := vars["policyName"]
|
|
|
|
entityName := vars["userOrGroup"]
|
|
|
|
isGroup := vars["isGroup"] == "true"
|
|
|
|
|
2019-12-19 17:21:21 -05:00
|
|
|
if !isGroup {
|
2021-02-25 16:49:59 -05:00
|
|
|
ok, _, err := globalIAMSys.IsTempUser(entityName)
|
2020-04-09 04:04:08 -04:00
|
|
|
if err != nil && err != errNoSuchUser {
|
2019-12-19 17:21:21 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if ok {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, errIAMActionNotAllowed), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-15 17:14:22 -05:00
|
|
|
if err := globalIAMSys.PolicyDBSet(ctx, entityName, policyName, isGroup); err != nil {
|
2019-11-09 12:27:23 -05:00
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-10-06 19:36:31 -04:00
|
|
|
if err := globalSiteReplicationSys.IAMChangeHook(ctx, madmin.SRIAMItem{
|
|
|
|
Type: madmin.SRIAMItemPolicyMapping,
|
|
|
|
PolicyMapping: &madmin.SRPolicyMapping{
|
|
|
|
UserOrGroup: entityName,
|
|
|
|
IsGroup: isGroup,
|
|
|
|
Policy: policyName,
|
|
|
|
},
|
|
|
|
}); err != nil {
|
|
|
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
|
|
return
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
}
|