fix: use GetSecret() in ticket.go makeCookie to respect cookie-secret-file #3228
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.
The makeCookie method in ticket.go was using t.options.Secret directly, which meant cookie-secret-file was not being respected. Updated to use GetSecret() which handles both cookie-secret and cookie-secret-file properly.
Also added test coverage for cookie-secret-file functionality.
Fixes #3224
Description
The
makeCookiemethod inticket.gowas directly accessingt.options.Secretwhen signing cookie values. This meant that when users configured acookie-secret-file, the secret from the file was not being used.Changes made:
makeCookieto uset.options.GetSecret()which properly handles bothcookie-secretandcookie-secret-filesession_store_tests.goto verify cookie signing works with secrets loaded from filesMotivation and Context
When users configure oauth2-proxy with
cookie-secret-file, they expect the secret from that file to be used for all cookie operations. However, due to this bug, themakeCookiemethod was bypassing the file-based secret mechanism and only using the direct secret value.This fixes issue #3224 where it was reported that cookie signing was broken when using
cookie-secret-file.How Has This Been Tested?
cookie-secret-file(with emptySecret)Checklist: