[PR #9554] [MERGED] Closes #9536: Last Used field on API tokens #13482

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/9554
Author: @PieterL75
Created: 6/17/2022
Status: Merged
Merged: 6/23/2022
Merged by: @jeremystretch

Base: 9536-token-last-usedHead: issue_9536


📝 Commits (8)

  • c04b4bb Add last_used to Token model and update when used
  • 5d4575e Only update every 60 seconds
  • 5d86816 Rename timediff to lasted_used_diff
  • d32bbd0 Fix last_used=None error
  • f822134 Disable token last_used update when in Maint mode
  • ae342a0 Correct delay time from 6 to 60 seconds
  • 81cea9b Show LastUsed in /user/api-tokens/
  • cfb9605 Merge branch 'feature' into issue_9536

📊 Changes

5 files changed (+46 additions, -1 deletions)

View changed files

📝 netbox/netbox/api/authentication.py (+15 -0)
📝 netbox/templates/users/api_tokens.html (+8 -0)
📝 netbox/users/admin/__init__.py (+1 -1)
netbox/users/migrations/0003_token_last_used.py (+18 -0)
📝 netbox/users/models.py (+4 -0)

📄 Description

Fixes: #9536: Last Used field on API tokens

Added a new field to the Token Model : last_used (DateTime)
The field is updated each time a token is authenticated (max 1x per minute to reduce db write load)


🔄 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/9554 **Author:** [@PieterL75](https://github.com/PieterL75) **Created:** 6/17/2022 **Status:** ✅ Merged **Merged:** 6/23/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `9536-token-last-used` ← **Head:** `issue_9536` --- ### 📝 Commits (8) - [`c04b4bb`](https://github.com/netbox-community/netbox/commit/c04b4bbbfaab83f566bdd287b4b7b3b58752da99) Add last_used to Token model and update when used - [`5d4575e`](https://github.com/netbox-community/netbox/commit/5d4575ed258e8ccfa55a14648e6b0eb688cfd8e4) Only update every 60 seconds - [`5d86816`](https://github.com/netbox-community/netbox/commit/5d868168a51e2a5864352c8518798eebe12d98ba) Rename timediff to lasted_used_diff - [`d32bbd0`](https://github.com/netbox-community/netbox/commit/d32bbd06cf4ee86392724cdf4f3b66b05d2d96df) Fix last_used=None error - [`f822134`](https://github.com/netbox-community/netbox/commit/f8221340af52b776e6dd972897bc6d491cb0775a) Disable token last_used update when in Maint mode - [`ae342a0`](https://github.com/netbox-community/netbox/commit/ae342a0506c627e3b23196ce49940b60b94f54f5) Correct delay time from 6 to 60 seconds - [`81cea9b`](https://github.com/netbox-community/netbox/commit/81cea9b9d9b86b945052d58c83341e189a58abb3) Show LastUsed in /user/api-tokens/ - [`cfb9605`](https://github.com/netbox-community/netbox/commit/cfb9605e9b5586c84ce93d89c13a525cb7d2b778) Merge branch 'feature' into issue_9536 ### 📊 Changes **5 files changed** (+46 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `netbox/netbox/api/authentication.py` (+15 -0) 📝 `netbox/templates/users/api_tokens.html` (+8 -0) 📝 `netbox/users/admin/__init__.py` (+1 -1) ➕ `netbox/users/migrations/0003_token_last_used.py` (+18 -0) 📝 `netbox/users/models.py` (+4 -0) </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 opened for approval prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. Please indicate the relevant feature request or bug report below. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ACCEPTED BUG REPORT OR FEATURE REQUEST, IT WILL BE MARKED AS INVALID AND CLOSED. --> ### Fixes: #9536: Last Used field on API tokens <!-- Please include a summary of the proposed changes below. --> Added a new field to the Token Model : last_used (DateTime) The field is updated each time a token is authenticated (max 1x per minute to reduce db write load) --- <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:19:07 +01:00
adam closed this issue 2025-12-29 23:19:07 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13482