[PR #10645] [MERGED] 8853 Prevent the retrieval of API tokens after creation #13667

Closed
opened 2025-12-29 23:20:10 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/10645
Author: @arthanson
Created: 10/13/2022
Status: Merged
Merged: 11/2/2022
Merged by: @jeremystretch

Base: featureHead: 8853-api-tokens


📝 Commits (10+)

  • dd48bf5 8853 hide api token
  • 9a0b8f5 8853 hide key on edit
  • 96145c4 8853 add key display
  • 0615f8c Merge branch 'feature' into 8853-api-tokens
  • c262593 8853 cleanup html
  • 08b965b 8853 make token view accessible only once on POST
  • 9f4135a Clean up display of tokens in views
  • 2550f2d Honor ALLOW_TOKEN_RETRIEVAL in API serializer
  • 1f75c9f Add docs & tweak default setting
  • c34c62a Include token key when provisioning with user credentials

📊 Changes

12 files changed (+116 additions, -12 deletions)

View changed files

📝 docs/configuration/security.md (+8 -0)
📝 docs/integrations/rest-api.md (+3 -0)
📝 docs/release-notes/version-3.4.md (+1 -0)
📝 netbox/netbox/configuration_example.py (+3 -0)
📝 netbox/netbox/settings.py (+1 -0)
netbox/templates/users/api_token.html (+60 -0)
📝 netbox/users/api/serializers.py (+8 -1)
📝 netbox/users/api/views.py (+2 -0)
📝 netbox/users/forms.py (+8 -0)
📝 netbox/users/models.py (+6 -5)
📝 netbox/users/tables.py (+7 -5)
📝 netbox/users/views.py (+9 -1)

📄 Description

Fixes: #8853

Prevents retrieval of API tokens after creation. The "Add another" makes things a bit different to put in. Presents a page after creation where you can see the key with a note to copy it down. Edit page does not show the key, could have it present the key as asterisks if that would be better.

Monosnap Editing token test9 (ahanson) | NetBox 2022-10-13 09-47-47
Monosnap test9 (ahanson) | NetBox 2022-10-13 09-47-12


🔄 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/10645 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 10/13/2022 **Status:** ✅ Merged **Merged:** 11/2/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `8853-api-tokens` --- ### 📝 Commits (10+) - [`dd48bf5`](https://github.com/netbox-community/netbox/commit/dd48bf5a4c977eb45e57c946a02b570d6799f758) 8853 hide api token - [`9a0b8f5`](https://github.com/netbox-community/netbox/commit/9a0b8f51bf333c01fa3c444ce93b4c0fb4fdd957) 8853 hide key on edit - [`96145c4`](https://github.com/netbox-community/netbox/commit/96145c4a5a9fb28cf041b548479928d5bee15a75) 8853 add key display - [`0615f8c`](https://github.com/netbox-community/netbox/commit/0615f8c134974c281d7175c0a16260aabfbc846f) Merge branch 'feature' into 8853-api-tokens - [`c262593`](https://github.com/netbox-community/netbox/commit/c262593706028c74b2ba20b930e4fc17591b9d9a) 8853 cleanup html - [`08b965b`](https://github.com/netbox-community/netbox/commit/08b965b55e060898b286d8f19de9499b1c822092) 8853 make token view accessible only once on POST - [`9f4135a`](https://github.com/netbox-community/netbox/commit/9f4135a23a67c7a3573b1c49696dc30b7b71fa1b) Clean up display of tokens in views - [`2550f2d`](https://github.com/netbox-community/netbox/commit/2550f2d27ad3f37f3ba1c2f80a26b6ec60358721) Honor ALLOW_TOKEN_RETRIEVAL in API serializer - [`1f75c9f`](https://github.com/netbox-community/netbox/commit/1f75c9f3e8b69092f5322fcd00e06c25d0cfcfec) Add docs & tweak default setting - [`c34c62a`](https://github.com/netbox-community/netbox/commit/c34c62a538a14fa9811d6336643d0eee5f51ec27) Include token key when provisioning with user credentials ### 📊 Changes **12 files changed** (+116 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `docs/configuration/security.md` (+8 -0) 📝 `docs/integrations/rest-api.md` (+3 -0) 📝 `docs/release-notes/version-3.4.md` (+1 -0) 📝 `netbox/netbox/configuration_example.py` (+3 -0) 📝 `netbox/netbox/settings.py` (+1 -0) ➕ `netbox/templates/users/api_token.html` (+60 -0) 📝 `netbox/users/api/serializers.py` (+8 -1) 📝 `netbox/users/api/views.py` (+2 -0) 📝 `netbox/users/forms.py` (+8 -0) 📝 `netbox/users/models.py` (+6 -5) 📝 `netbox/users/tables.py` (+7 -5) 📝 `netbox/users/views.py` (+9 -1) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be approved and assigned prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WE BE CLOSED AUTOMATICALLY. Specify your assigned issue number on the line below. --> ### Fixes: #8853 <!-- Please include a summary of the proposed changes below. --> Prevents retrieval of API tokens after creation. The "Add another" makes things a bit different to put in. Presents a page after creation where you can see the key with a note to copy it down. Edit page does not show the key, could have it present the key as asterisks if that would be better. ![Monosnap Editing token test9 (ahanson) | NetBox 2022-10-13 09-47-47](https://user-images.githubusercontent.com/99642/195657341-8cbf4cc1-d535-45b9-a145-b8988bc97e36.png) ![Monosnap test9 (ahanson) | NetBox 2022-10-13 09-47-12](https://user-images.githubusercontent.com/99642/195657344-66b0c4d6-00ce-4b51-8797-4b6e01ced3a8.png) --- <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-29 23:20:10 +01:00
adam closed this issue 2025-12-29 23:20:10 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13667