feat(auth): add configurable MaxAge to auth cookies #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tracking issue
Related to frequent re-authentication issues reported by users (flyte/grafana.heph sessions expiring quickly)
Why are the changes needed?
Users were experiencing frequent re-authentication prompts because auth cookies were created without
MaxAgeorExpiresattributes. This made them session cookies that browsers could clear at any time (e.g., when closing the browser, or based on browser-specific session management policies).By adding a configurable
MaxAgeto cookies, sessions can persist for a specified duration (e.g., matching the token lifespan of 168h), significantly reducing login frequency.What changes were proposed in this pull request?
MaxAgefield (typeconfig.Duration) toCookieSettingsstructmaxAgefield toCookieManagerstruct to store the configured valueNewSecureCookiefunction to accept amaxAge time.DurationparametermaxAge > 0, the cookie'sMaxAgeattribute is set accordinglyNewSecureCookiecall sites to pass the configuredmaxAge0for maxAge (backward compatible - session cookie behavior)Important for reviewers: This PR only adds the capability. To enable persistent cookies, the helm values need to be updated separately to set
cookieSettings.maxAge(e.g.,168hto match token lifespan).How was this patch tested?
TestSecureCookieLifecycle,TestGetHTTPRequestCookieToMetadataHandler)go test -v -run "TestSecureCookieLifecycle|TestGetHTTPRequestCookieToMetadataHandler" ./...inflyteadmin/authLabels
maxAgeconfiguration option for auth cookiesCheck all the applicable boxes
Human Review Checklist
config.Durationis the appropriate type forMaxAgefieldmaxAge > 0condition handles edge cases correctlyLink to Devin run: https://app.devin.ai/sessions/6bf80d9947cd470cba4919b461a7176f
Requested by: carlos