Skip to content

fix: OIDC expiry 0 sets nil instead of far-future date#3113

Open
cobyfrombrooklyn-bot wants to merge 1 commit into
juanfont:mainfrom
cobyfrombrooklyn-bot:fix-issue-3111
Open

fix: OIDC expiry 0 sets nil instead of far-future date#3113
cobyfrombrooklyn-bot wants to merge 1 commit into
juanfont:mainfrom
cobyfrombrooklyn-bot:fix-issue-3111

Conversation

@cobyfrombrooklyn-bot
Copy link
Copy Markdown

Fixes #3111

Problem

When oidc.expiry is set to 0 (meaning "no expiry"), headscale sets the node expiry to MaxDuration (~292 years in the future). This results in a far-future date like 2318-06-08 in 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:

  1. hscontrol/oidc.go - determineNodeExpiry: When Expiry equals MaxDuration, return zero time instead of adding 292 years to now.

  2. hscontrol/oidc.go - handleRegistration: When the computed expiry is zero time, pass nil (instead of &expiry) to HandleNodeFromAuthPath, resulting in NULL in the database. This is consistent with how IsExpired() already treats nil expiry as "not expired".

  3. hscontrol/types/config.go: Exported MaxDuration so it can be referenced from the hscontrol package.

Test

Added TestDetermineNodeExpiry with 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 works
  • use_token_expiry: verifies UseExpiryFromToken still works

Tested locally on macOS ARM (Apple Silicon). All hscontrol tests pass.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] oidc expiry: 0 sets far-future date (year 2318) instead of NULL

1 participant