From adcc80f09c3c88f0655da23c0530fe08938f0e1f Mon Sep 17 00:00:00 2001 From: Flare576 Date: Thu, 26 Mar 2026 13:23:10 -0500 Subject: [PATCH] fix: create storageState directory if it does not exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Browser provider saves session state to ~/.aws/saml2aws/storageState.json after each login, but never creates the ~/.aws/saml2aws/ directory. If the directory does not exist, context.StorageState() silently fails and the session is never persisted — meaning every login requires full re-authentication including MFA, defeating the purpose of the storageState feature introduced in #1267. Fix: call os.MkdirAll on the directory before attempting to save. Also fixes a pre-existing typo: 'broswer' -> 'browser' in comment. Co-authored-by: Sisyphus --- pkg/provider/browser/browser.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/provider/browser/browser.go b/pkg/provider/browser/browser.go index 0681589b1..e538507d6 100644 --- a/pkg/provider/browser/browser.go +++ b/pkg/provider/browser/browser.go @@ -115,15 +115,19 @@ func (cl *Client) Authenticate(loginDetails *creds.LoginDetails) (string, error) // load saved storageState if present and add to contextOptions userHomeDir, err := os.UserHomeDir() - storageStatePath := fmt.Sprintf("%s/.aws/saml2aws/storageState.json", userHomeDir) if err != nil { return "", err } + storageStateDir := fmt.Sprintf("%s/.aws/saml2aws", userHomeDir) + storageStatePath := fmt.Sprintf("%s/storageState.json", storageStateDir) + if err := os.MkdirAll(storageStateDir, 0700); err != nil { + logger.Warn("failed to create storageState directory, session state will not be persisted: ", err) + } if _, err := os.Stat(storageStatePath); err == nil { contextOptions.StorageStatePath = playwright.String(storageStatePath) } - // Create new broswer context + // Create new browser context context, err := browser.NewContext(contextOptions) if err != nil { return "", err