mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
honor client context in IAM user/policy listing calls (#14682)
This commit is contained in:
parent
598ce1e354
commit
6bc3c74c0c
@ -90,7 +90,7 @@ func (a adminAPIHandlers) ListBucketUsers(w http.ResponseWriter, r *http.Request
|
|||||||
|
|
||||||
password := cred.SecretKey
|
password := cred.SecretKey
|
||||||
|
|
||||||
allCredentials, err := globalIAMSys.ListBucketUsers(bucket)
|
allCredentials, err := globalIAMSys.ListBucketUsers(ctx, bucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
@ -124,7 +124,7 @@ func (a adminAPIHandlers) ListUsers(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
password := cred.SecretKey
|
password := cred.SecretKey
|
||||||
|
|
||||||
allCredentials, err := globalIAMSys.ListUsers()
|
allCredentials, err := globalIAMSys.ListUsers(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
|
50
cmd/iam.go
50
cmd/iam.go
@ -538,9 +538,12 @@ func (sys *IAMSys) ListPolicies(ctx context.Context, bucketName string) (map[str
|
|||||||
return nil, errServerNotInitialized
|
return nil, errServerNotInitialized
|
||||||
}
|
}
|
||||||
|
|
||||||
<-sys.configLoaded
|
select {
|
||||||
|
case <-sys.configLoaded:
|
||||||
return sys.store.ListPolicies(ctx, bucketName)
|
return sys.store.ListPolicies(ctx, bucketName)
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil, ctx.Err()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPolicy - sets a new named policy.
|
// SetPolicy - sets a new named policy.
|
||||||
@ -673,25 +676,30 @@ func (sys *IAMSys) SetTempUser(ctx context.Context, accessKey string, cred auth.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListBucketUsers - list all users who can access this 'bucket'
|
// ListBucketUsers - list all users who can access this 'bucket'
|
||||||
func (sys *IAMSys) ListBucketUsers(bucket string) (map[string]madmin.UserInfo, error) {
|
func (sys *IAMSys) ListBucketUsers(ctx context.Context, bucket string) (map[string]madmin.UserInfo, error) {
|
||||||
if !sys.Initialized() {
|
if !sys.Initialized() {
|
||||||
return nil, errServerNotInitialized
|
return nil, errServerNotInitialized
|
||||||
}
|
}
|
||||||
|
|
||||||
<-sys.configLoaded
|
select {
|
||||||
|
case <-sys.configLoaded:
|
||||||
return sys.store.GetBucketUsers(bucket)
|
return sys.store.GetBucketUsers(bucket)
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil, ctx.Err()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListUsers - list all users.
|
// ListUsers - list all users.
|
||||||
func (sys *IAMSys) ListUsers() (map[string]madmin.UserInfo, error) {
|
func (sys *IAMSys) ListUsers(ctx context.Context) (map[string]madmin.UserInfo, error) {
|
||||||
if !sys.Initialized() {
|
if !sys.Initialized() {
|
||||||
return nil, errServerNotInitialized
|
return nil, errServerNotInitialized
|
||||||
}
|
}
|
||||||
|
select {
|
||||||
<-sys.configLoaded
|
case <-sys.configLoaded:
|
||||||
|
return sys.store.GetUsers(), nil
|
||||||
return sys.store.GetUsers(), nil
|
case <-ctx.Done():
|
||||||
|
return nil, ctx.Err()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListLDAPUsers - list LDAP users which has
|
// ListLDAPUsers - list LDAP users which has
|
||||||
@ -909,9 +917,12 @@ func (sys *IAMSys) ListServiceAccounts(ctx context.Context, accessKey string) ([
|
|||||||
return nil, errServerNotInitialized
|
return nil, errServerNotInitialized
|
||||||
}
|
}
|
||||||
|
|
||||||
<-sys.configLoaded
|
select {
|
||||||
|
case <-sys.configLoaded:
|
||||||
return sys.store.ListServiceAccounts(ctx, accessKey)
|
return sys.store.ListServiceAccounts(ctx, accessKey)
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil, ctx.Err()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetServiceAccount - wrapper method to get information about a service account
|
// GetServiceAccount - wrapper method to get information about a service account
|
||||||
@ -1311,9 +1322,12 @@ func (sys *IAMSys) ListGroups(ctx context.Context) (r []string, err error) {
|
|||||||
return r, errServerNotInitialized
|
return r, errServerNotInitialized
|
||||||
}
|
}
|
||||||
|
|
||||||
<-sys.configLoaded
|
select {
|
||||||
|
case <-sys.configLoaded:
|
||||||
return sys.store.ListGroups(ctx)
|
return sys.store.ListGroups(ctx)
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil, ctx.Err()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PolicyDBSet - sets a policy for a user or group in the PolicyDB.
|
// PolicyDBSet - sets a policy for a user or group in the PolicyDB.
|
||||||
|
@ -2892,7 +2892,7 @@ func (c *SiteReplicationSys) SiteReplicationMetaInfo(ctx context.Context, objAPI
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// get users/group info on local.
|
// get users/group info on local.
|
||||||
userInfoMap, errU := globalIAMSys.ListUsers()
|
userInfoMap, errU := globalIAMSys.ListUsers(ctx)
|
||||||
if errU != nil {
|
if errU != nil {
|
||||||
return info, errSRBackendIssue(errU)
|
return info, errSRBackendIssue(errU)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user