From 9dd87aa80af3d53eee10c3ac1ed452cffc5b2998 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 2 Jan 2026 21:22:00 -0800 Subject: [PATCH] refactor(sts): remove unused IsExpired() helper functions The session_helpers.go file contained two unused IsExpired() methods: - Credentials.IsExpired() - SessionInfo.IsExpired() These were never called anywhere in the codebase. The actual expiration checks use: - isCredentialExpired() in weed/s3api/auth_credentials.go (S3 auth) - Direct time.Now().After() checks Removing unused code improves code clarity and reduces maintenance burden. --- weed/iam/sts/session_helpers.go | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 weed/iam/sts/session_helpers.go diff --git a/weed/iam/sts/session_helpers.go b/weed/iam/sts/session_helpers.go deleted file mode 100644 index 64abc23d4..000000000 --- a/weed/iam/sts/session_helpers.go +++ /dev/null @@ -1,29 +0,0 @@ -package sts - -import "time" - -// IsExpired returns true if the credentials have expired -func (c *Credentials) IsExpired() bool { - if c == nil { - return true - } - // Treat zero-time expiration as expired (uninitialized credentials) - // This prevents treating uninitialized credentials as valid - if c.Expiration.IsZero() { - return true - } - return time.Now().After(c.Expiration) -} - -// IsExpired returns true if the session has expired -func (s *SessionInfo) IsExpired() bool { - // If SessionInfo is nil, consider it expired - if s == nil { - return true - } - // Treat zero-time expiration as expired (uninitialized session) - if s.ExpiresAt.IsZero() { - return true - } - return time.Now().After(s.ExpiresAt) -}