Skip to content

Allow disabling automatic API token rotation - #466

Merged
timmarkhuff merged 5 commits into
mainfrom
thuff/disable-token-rotation-flag
Jul 29, 2026
Merged

Allow disabling automatic API token rotation#466
timmarkhuff merged 5 commits into
mainfrom
thuff/disable-token-rotation-flag

Conversation

@timmarkhuff

@timmarkhuff timmarkhuff commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Background

Follow-up to #445 before cutting 0.31.0.

The edge-endpoint container on Edge Endpoint builds Groundlight(api_token=request x-api-token) for sync cloud calls. With rotation enabled it would mint/revoke against tokens that are owned by the client application. This could result in a token being revoked while the client is still using it.

Disabling rotation here leaves ownership of the token's rotation with the application client.

Summary

  • Adds enable_token_rotation (default True) to Groundlight and ExperimentalApi.
  • When False, Groundlight skips constructing TokenManager and uses the configured token as-is (no by-snippet lookup, on-disk cache, mint/revoke, or background refresh thread).
  • TokenManager itself is unchanged from feat: automatically rotate SDK API tokens #445: it always owns a rotation chain when constructed.

Test plan

  • poetry run pytest test/unit/test_token_manager.py test/unit/test_token_refresh_client.py
  • Confirm default enable_token_rotation=True still rotates when token_ttl is set
  • Edge follow-up: construct request-token clients with enable_token_rotation=False; keep rotation on for device-token containers with shared GROUNDLIGHT_TOKEN_DIR

Tim Huff and others added 5 commits July 29, 2026 10:56
Add enable_token_rotation to Groundlight/TokenManager so proxies like Edge
Endpoint can forward a caller's token without minting or revoking against
that identity's rotation chain. Defaults to True to preserve existing behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
Silence PLR0913 on the new constructor args, drop the unreachable refresh
guard and redundant _available flag, defer cache/lock setup until rotation
is enabled, and cover close() plus ExperimentalApi forwarding.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the behavioral description of enable_token_rotation without naming
Edge Endpoint or other call-site examples.

Co-authored-by: Cursor <cursoragent@cursor.com>
When enable_token_rotation is False, skip creating TokenManager entirely
so the configured token is used as-is. TokenManager stays a pure rotation
collaborator with no disabled mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
Constructor forwarding for the subclass follows the existing pattern and
is already covered by the Groundlight client test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@timmarkhuff
timmarkhuff requested a review from honeytung July 29, 2026 23:25

@honeytung honeytung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@timmarkhuff
timmarkhuff merged commit 1b37595 into main Jul 29, 2026
8 checks passed
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.

2 participants