[PR #9595] [MERGED] Closes #9536: Record last used time for API tokens #13495

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

📋 Pull Request Information

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

Base: featureHead: 9536-token-last-used


📝 Commits (10+)

  • 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
  • 4f33685 Merge pull request #9554 from PieterL75/issue_9536
  • dc05e62 Documentation & clenaup for #9536

📊 Changes

9 files changed (+47 additions, -5 deletions)

View changed files

📝 docs/release-notes/version-3.3.md (+4 -0)
📝 docs/rest-api/authentication.md (+5 -0)
📝 netbox/netbox/api/authentication.py (+14 -0)
📝 netbox/netbox/tests/test_authentication.py (+4 -0)
📝 netbox/templates/users/api_tokens.html (+8 -0)
📝 netbox/users/admin/__init__.py (+1 -1)
📝 netbox/users/api/serializers.py (+1 -1)
📝 netbox/users/migrations/0003_token_allowed_ips_last_used.py (+6 -3)
📝 netbox/users/models.py (+4 -0)

📄 Description

Closes: #9536

This is an extension of work done by @PieterL75 in #9554.

  • Adds the last_used field to the Token model and records last used time upon authentication
  • Updates tests & docs

🔄 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/9595 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 6/23/2022 **Status:** ✅ Merged **Merged:** 6/23/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `9536-token-last-used` --- ### 📝 Commits (10+) - [`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 - [`4f33685`](https://github.com/netbox-community/netbox/commit/4f33685ca71c3273dbe3fb00a1a81539ee34760c) Merge pull request #9554 from PieterL75/issue_9536 - [`dc05e62`](https://github.com/netbox-community/netbox/commit/dc05e62ce030419509149634d29586f536956e91) Documentation & clenaup for #9536 ### 📊 Changes **9 files changed** (+47 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/release-notes/version-3.3.md` (+4 -0) 📝 `docs/rest-api/authentication.md` (+5 -0) 📝 `netbox/netbox/api/authentication.py` (+14 -0) 📝 `netbox/netbox/tests/test_authentication.py` (+4 -0) 📝 `netbox/templates/users/api_tokens.html` (+8 -0) 📝 `netbox/users/admin/__init__.py` (+1 -1) 📝 `netbox/users/api/serializers.py` (+1 -1) 📝 `netbox/users/migrations/0003_token_allowed_ips_last_used.py` (+6 -3) 📝 `netbox/users/models.py` (+4 -0) </details> ### 📄 Description ### Closes: #9536 This is an extension of work done by @PieterL75 in #9554. - Adds the `last_used` field to the Token model and records last used time upon authentication - Updates tests & docs --- <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:12 +01:00
adam closed this issue 2025-12-29 23:19:12 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13495