From 4687c4616f61592b9dea3ad2bc38b2d0bd24218c Mon Sep 17 00:00:00 2001 From: Poorna Date: Thu, 15 Aug 2024 23:12:42 -0700 Subject: [PATCH] try loading temp account if not in cache (#20266) --- cmd/iam.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/iam.go b/cmd/iam.go index f9b78f8b4..d7ac42775 100644 --- a/cmd/iam.go +++ b/cmd/iam.go @@ -1221,9 +1221,18 @@ func (sys *IAMSys) getServiceAccount(ctx context.Context, accessKey string) (Use // GetTemporaryAccount - wrapper method to get information about a temporary account func (sys *IAMSys) GetTemporaryAccount(ctx context.Context, accessKey string) (auth.Credentials, *policy.Policy, error) { + if !sys.Initialized() { + return auth.Credentials{}, nil, errServerNotInitialized + } tmpAcc, embeddedPolicy, err := sys.getTempAccount(ctx, accessKey) if err != nil { - return auth.Credentials{}, nil, err + if err == errNoSuchTempAccount { + sys.store.LoadUser(ctx, accessKey) + tmpAcc, embeddedPolicy, err = sys.getTempAccount(ctx, accessKey) + } + if err != nil { + return auth.Credentials{}, nil, err + } } // Hide secret & session keys tmpAcc.Credentials.SecretKey = ""