Skip to content

Conversation

@pheus
Copy link
Contributor

@pheus pheus commented Nov 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!

Introduce an `enabled` flag on the `Token` model to allow temporarily
revoking API tokens without deleting them. Update forms, serializers,
and views to expose the new field.
Enforce the `enabled` flag in token authentication.
Add model, API, and authentication tests for the new behavior.

Fixes netbox-community#20834
@pheus
Copy link
Contributor Author

pheus commented Nov 21, 2025

I’ve opened this as a draft PR to get an initial round of feedback on the approach and implementation.

Once the changes from #20823 are merged from main into the feature branch, I’ll rebase this work to align with the updated code and reduce potential merge conflicts.

In the meantime, any early feedback on the model changes, API surface, or tests is very welcome. Thanks in advance for taking a look!

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.

1 participant