Closes #20834: Add support for enabling/disabling Tokens #827

Closed
opened 2026-04-05 17:59:35 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 11/21/2025

Fixes: #20834

This PR introduces an enabled field on the Token model to allow API tokens to be temporarily disabled without being deleted.

Key changes:

  • Add an enabled Boolean field to Token (defaulting to True for backwards compatibility)
  • Enforce the enabled flag in token authentication so disabled tokens are rejected
  • Expose the new field in token forms, bulk edit, and tables to make it easy to toggle status from the UI
  • Expose enabled via the token API serializers (including provisioning), allowing tokens to be created and managed in a disabled state
  • Add tests for the Token model, API, and authentication to cover the new behavior

Existing tokens remain enabled by default, so there is no change in behavior until a token is explicitly disabled.

Thanks in advance for reviewing!

*Originally created by @pheus on 11/21/2025* ### Fixes: #20834 This PR introduces an `enabled` field on the `Token` model to allow API tokens to be temporarily disabled without being deleted. Key changes: - Add an `enabled` Boolean field to `Token` (defaulting to `True` for backwards compatibility) - Enforce the `enabled` flag in token authentication so disabled tokens are rejected - Expose the new field in token forms, bulk edit, and tables to make it easy to toggle status from the UI - Expose `enabled` via the token API serializers (including provisioning), allowing tokens to be created and managed in a disabled state - Add tests for the Token model, API, and authentication to cover the new behavior Existing tokens remain enabled by default, so there is no change in behavior until a token is explicitly disabled. Thanks in advance for reviewing!
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#827