Skip to content

Commit

Permalink
Add temporary account info API (#155)
Browse files Browse the repository at this point in the history
Useful to know who is the parent user who generated the STS account
found in some S3 trace.
  • Loading branch information
vadmeste committed Nov 29, 2022
1 parent 7e8fb56 commit 8834a6b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions user-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,39 @@ func (adm *AdminClient) DeleteServiceAccount(ctx context.Context, serviceAccount

return nil
}

// TemporaryAccountInfoResp is the response body of the info temporary call
type TemporaryAccountInfoResp InfoServiceAccountResp

// TemporaryAccountInfo - returns the info of a temporary account
func (adm *AdminClient) TemporaryAccountInfo(ctx context.Context, accessKey string) (TemporaryAccountInfoResp, error) {
queryValues := url.Values{}
queryValues.Set("accessKey", accessKey)

reqData := requestData{
relPath: adminAPIPrefix + "/temporary-account-info",
queryValues: queryValues,
}

// Execute GET on /minio/admin/v3/temporary-account-info
resp, err := adm.executeMethod(ctx, http.MethodGet, reqData)
defer closeResponse(resp)
if err != nil {
return TemporaryAccountInfoResp{}, err
}

if resp.StatusCode != http.StatusOK {
return TemporaryAccountInfoResp{}, httpRespToErrorResponse(resp)
}

data, err := DecryptData(adm.getSecretKey(), resp.Body)
if err != nil {
return TemporaryAccountInfoResp{}, err
}

var infoResp TemporaryAccountInfoResp
if err = json.Unmarshal(data, &infoResp); err != nil {
return TemporaryAccountInfoResp{}, err
}
return infoResp, nil
}

0 comments on commit 8834a6b

Please sign in to comment.