[PR #20576] [MERGED] Fixes #20476: Prohibit changing a token's owner #15969

Closed
opened 2025-12-30 00:25:04 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20576
Author: @jeremystretch
Created: 10/14/2025
Status: Merged
Merged: 10/14/2025
Merged by: @jnovinger

Base: featureHead: 20476-prevent-api-token-user-change


📝 Commits (1)

📊 Changes

3 files changed (+42 additions, -3 deletions)

View changed files

📝 netbox/users/api/serializers_/tokens.py (+9 -0)
📝 netbox/users/forms/model_forms.py (+7 -0)
📝 netbox/users/tests/test_api.py (+26 -3)

📄 Description

Closes: #20476

  • Adjust TokenSerializer so that the user field is set to read-only when not creating a new token
  • Disable the user field on TokenForm when editing an existing token
  • Introduce the test_reassign_token() API test

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20576 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 10/14/2025 **Status:** ✅ Merged **Merged:** 10/14/2025 **Merged by:** [@jnovinger](https://github.com/jnovinger) **Base:** `feature` ← **Head:** `20476-prevent-api-token-user-change` --- ### 📝 Commits (1) - [`c914c7a`](https://github.com/netbox-community/netbox/commit/c914c7ae5a72dfd40fab449bab692c147bbd066f) Fixes #20476: Prohibit changing a token's owner ### 📊 Changes **3 files changed** (+42 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `netbox/users/api/serializers_/tokens.py` (+9 -0) 📝 `netbox/users/forms/model_forms.py` (+7 -0) 📝 `netbox/users/tests/test_api.py` (+26 -3) </details> ### 📄 Description ### Closes: #20476 - Adjust TokenSerializer so that the `user` field is set to read-only when not creating a new token - Disable the `user` field on TokenForm when editing an existing token - Introduce the `test_reassign_token()` API test --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:25:04 +01:00
adam closed this issue 2025-12-30 00:25:04 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15969