Allow users to list their own service accounts (#13706)

Bonus: add extensive tests for svc acc actions by users
This commit is contained in:
Aditya Manthramurthy
2021-11-19 12:35:35 -08:00
committed by GitHub
parent 556ae07857
commit 40244994ad
2 changed files with 212 additions and 14 deletions

View File

@@ -939,8 +939,10 @@ func (a adminAPIHandlers) ListServiceAccounts(w http.ResponseWriter, r *http.Req
var targetAccount string
// If listing is requested for a specific user (who is not the request
// sender), check that the user has permissions.
user := r.Form.Get("user")
if user != "" {
if user != "" && user != cred.AccessKey {
if !globalIAMSys.IsAllowed(iampolicy.Args{
AccountName: cred.AccessKey,
Action: iampolicy.ListServiceAccountsAdminAction,