fix: OIDC expiry 0 sets nil instead of far-future date#3113
Open
cobyfrombrooklyn-bot wants to merge 1 commit into
Open
fix: OIDC expiry 0 sets nil instead of far-future date#3113cobyfrombrooklyn-bot wants to merge 1 commit into
cobyfrombrooklyn-bot wants to merge 1 commit into
Conversation
When oidc.expiry is set to 0, the intent is 'no expiry'. Previously, this was represented as MaxDuration (~292 years), which resulted in a far-future date in the database. Clients like Headplane couldn't distinguish this from an actual expiry. Now determineNodeExpiry returns zero time for MaxDuration, and handleRegistration passes nil to HandleNodeFromAuthPath when the expiry is zero, resulting in NULL in the database. Exported MaxDuration from types package for use in the check. Added TestDetermineNodeExpiry with three cases. Fixes juanfont#3111
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3111
Problem
When
oidc.expiryis set to0(meaning "no expiry"), headscale sets the node expiry toMaxDuration(~292 years in the future). This results in a far-future date like2318-06-08in the database instead of NULL. Clients like Headplane cannot distinguish this from a real expiry and fail to show the "no expiry" tag.Fix
Three changes:
hscontrol/oidc.go-determineNodeExpiry: WhenExpiryequalsMaxDuration, return zero time instead of adding 292 years to now.hscontrol/oidc.go-handleRegistration: When the computed expiry is zero time, passnil(instead of&expiry) toHandleNodeFromAuthPath, resulting in NULL in the database. This is consistent with howIsExpired()already treats nil expiry as "not expired".hscontrol/types/config.go: ExportedMaxDurationso it can be referenced from thehscontrolpackage.Test
Added
TestDetermineNodeExpirywith three test cases:zero_expiry_means_no_expiry: verifies MaxDuration config returns zero time (fails without fix: returns year 2318)normal_expiry_returns_future_time: verifies normal expiry still worksuse_token_expiry: verifies UseExpiryFromToken still worksTested locally on macOS ARM (Apple Silicon). All hscontrol tests pass.