@@ -26,7 +26,6 @@ import (
2626
2727 bucketApi "github.com/minio/console/api/operations/bucket"
2828 policyApi "github.com/minio/console/api/operations/policy"
29- "github.com/minio/console/pkg/utils"
3029 s3 "github.com/minio/minio-go/v7"
3130
3231 "github.com/go-openapi/runtime/middleware"
@@ -308,10 +307,6 @@ func getListPoliciesResponse(session *models.Principal, params policyApi.ListPol
308307func getListUsersForPolicyResponse (session * models.Principal , params policyApi.ListUsersForPolicyParams ) ([]string , * CodedAPIError ) {
309308 ctx , cancel := context .WithCancel (params .HTTPRequest .Context ())
310309 defer cancel ()
311- policy , err := utils .DecodeBase64 (params .Policy )
312- if err != nil {
313- return nil , ErrorWithContext (ctx , err )
314- }
315310 mAdmin , err := NewMinioAdminClient (params .HTTPRequest .Context (), session )
316311 if err != nil {
317312 return nil , ErrorWithContext (ctx , err )
@@ -325,12 +320,12 @@ func getListUsersForPolicyResponse(session *models.Principal, params policyApi.L
325320 }
326321 found := false
327322 for i := range policies {
328- if policies [i ].Name == policy {
323+ if policies [i ].Name == params . Policy {
329324 found = true
330325 }
331326 }
332327 if ! found {
333- return nil , ErrorWithContext (ctx , ErrPolicyNotFound , fmt .Errorf ("the policy %s does not exist" , policy ))
328+ return nil , ErrorWithContext (ctx , ErrPolicyNotFound , fmt .Errorf ("the policy %s does not exist" , params . Policy ))
334329 }
335330 users , err := listUsers (ctx , adminClient )
336331 if err != nil {
@@ -340,7 +335,7 @@ func getListUsersForPolicyResponse(session *models.Principal, params policyApi.L
340335 var filteredUsers []string
341336 for _ , user := range users {
342337 for _ , upolicy := range user .Policy {
343- if upolicy == policy {
338+ if upolicy == params . Policy {
344339 filteredUsers = append (filteredUsers , user .AccessKey )
345340 break
346341 }
@@ -397,12 +392,7 @@ func getSAUserPolicyResponse(session *models.Principal, params policyApi.GetSAUs
397392 }
398393 userAdminClient := AdminClient {Client : mAdminClient }
399394
400- userName , err := utils .DecodeBase64 (params .Name )
401- if err != nil {
402- return nil , ErrorWithContext (ctx , err )
403- }
404-
405- user , err := getUserInfo (ctx , userAdminClient , userName )
395+ user , err := getUserInfo (ctx , userAdminClient , params .Name )
406396 if err != nil {
407397 return nil , ErrorWithContext (ctx , err )
408398 }
@@ -467,23 +457,19 @@ func getListGroupsForPolicyResponse(session *models.Principal, params policyApi.
467457 }
468458 // create a minioClient interface implementation
469459 // defining the client to be used
470- policy , err := utils .DecodeBase64 (params .Policy )
471- if err != nil {
472- return nil , ErrorWithContext (ctx , err )
473- }
474460 adminClient := AdminClient {Client : mAdmin }
475461 policies , err := listPolicies (ctx , adminClient )
476462 if err != nil {
477463 return nil , ErrorWithContext (ctx , err )
478464 }
479465 found := false
480466 for i := range policies {
481- if policies [i ].Name == policy {
467+ if policies [i ].Name == params . Policy {
482468 found = true
483469 }
484470 }
485471 if ! found {
486- return nil , ErrorWithContext (ctx , ErrPolicyNotFound , fmt .Errorf ("the policy %s does not exist" , policy ))
472+ return nil , ErrorWithContext (ctx , ErrPolicyNotFound , fmt .Errorf ("the policy %s does not exist" , params . Policy ))
487473 }
488474
489475 groups , err := adminClient .listGroups (ctx )
@@ -499,7 +485,7 @@ func getListGroupsForPolicyResponse(session *models.Principal, params policyApi.
499485 }
500486 groupPolicies := strings .Split (info .Policy , "," )
501487 for _ , groupPolicy := range groupPolicies {
502- if groupPolicy == policy {
488+ if groupPolicy == params . Policy {
503489 filteredGroups = append (filteredGroups , group )
504490 }
505491 }
@@ -524,10 +510,6 @@ func getRemovePolicyResponse(session *models.Principal, params policyApi.RemoveP
524510 if params .Name == "" {
525511 return ErrorWithContext (ctx , ErrPolicyNameNotInRequest )
526512 }
527- policyName , err := utils .DecodeBase64 (params .Name )
528- if err != nil {
529- return ErrorWithContext (ctx , err )
530- }
531513 mAdmin , err := NewMinioAdminClient (params .HTTPRequest .Context (), session )
532514 if err != nil {
533515 return ErrorWithContext (ctx , err )
@@ -536,7 +518,7 @@ func getRemovePolicyResponse(session *models.Principal, params policyApi.RemoveP
536518 // defining the client to be used
537519 adminClient := AdminClient {Client : mAdmin }
538520
539- if err := removePolicy (ctx , adminClient , policyName ); err != nil {
521+ if err := removePolicy (ctx , adminClient , params . Name ); err != nil {
540522 return ErrorWithContext (ctx , err )
541523 }
542524 return nil
@@ -623,11 +605,7 @@ func getPolicyInfoResponse(session *models.Principal, params policyApi.PolicyInf
623605 // create a MinIO Admin Client interface implementation
624606 // defining the client to be used
625607 adminClient := AdminClient {Client : mAdmin }
626- policyName , err := utils .DecodeBase64 (params .Name )
627- if err != nil {
628- return nil , ErrorWithContext (ctx , err )
629- }
630- policy , err := policyInfo (ctx , adminClient , policyName )
608+ policy , err := policyInfo (ctx , adminClient , params .Name )
631609 if err != nil {
632610 return nil , ErrorWithContext (ctx , err )
633611 }
0 commit comments