Prevent the retrieval of API tokens after creation #6199

Closed
opened 2025-12-29 19:37:57 +01:00 by adam · 6 comments
Owner

Originally created by @jeremystretch on GitHub (Mar 11, 2022).

Originally assigned to: @arthanson, @jeremystretch on GitHub.

NetBox version

v3.1.9

Feature type

New functionality

Proposed functionality

I'm opening this FR to explore the idea of preventing the export of API tokens after their creation. Upon creating a token, users would have one opportunity to copy the token out of NetBox, after which it will be functional but no longer accessible.

As there are likely use cases where retaining the ability to retrieve tokens is necessary, this should be implemented as a configuration parameter (e.g. ALLOW_TOKEN_RETRIEVAL = False). I don't anticipate any changes to the database, unless agreement is reached to remove this ability entirely.

Use case

Provides greater security, as users can no longer retrieve API tokens from NetBox. If a token is lost, it will need to be replaced and all API consumers which used it will need to be updated with the new token.

Database changes

No response

External dependencies

No response

Originally created by @jeremystretch on GitHub (Mar 11, 2022). Originally assigned to: @arthanson, @jeremystretch on GitHub. ### NetBox version v3.1.9 ### Feature type New functionality ### Proposed functionality I'm opening this FR to explore the idea of preventing the export of API tokens after their creation. Upon creating a token, users would have one opportunity to copy the token out of NetBox, after which it will be functional but no longer accessible. As there are likely use cases where retaining the ability to retrieve tokens is necessary, this should be implemented as a configuration parameter (e.g. `ALLOW_TOKEN_RETRIEVAL = False`). I don't anticipate any changes to the database, unless agreement is reached to remove this ability entirely. ### Use case Provides greater security, as users can no longer retrieve API tokens from NetBox. If a token is lost, it will need to be replaced and all API consumers which used it will need to be updated with the new token. ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 19:37:57 +01:00
adam closed this issue 2025-12-29 19:37:57 +01:00
Author
Owner

@DanSheps commented on GitHub (Mar 18, 2022):

Just to add, as I can potentially see it being an ask in the future, maybe also have a "Allow Token Retrieval" permission so that that can be locked down to a specific user/group.

@DanSheps commented on GitHub (Mar 18, 2022): Just to add, as I can potentially see it being an ask in the future, maybe also have a "Allow Token Retrieval" permission so that that can be locked down to a specific user/group.
Author
Owner

@github-actions[bot] commented on GitHub (May 18, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@github-actions[bot] commented on GitHub (May 18, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@PieterL75 commented on GitHub (Jul 27, 2022):

you could show the first 4 and last 4 digits, so that there still is a way to link an token in a 'lost' script to an account

@PieterL75 commented on GitHub (Jul 27, 2022): you could show the first 4 and last 4 digits, so that there still is a way to link an token in a 'lost' script to an account
Author
Owner

@abhi1693 commented on GitHub (Sep 26, 2022):

Would this also somehow scramble it in the DB? Because it's a simple query to retrieve it for anyone access to the shell.

@abhi1693 commented on GitHub (Sep 26, 2022): Would this also somehow scramble it in the DB? Because it's a simple query to retrieve it for anyone access to the shell.
Author
Owner

@arthanson commented on GitHub (Oct 12, 2022):

@jeremystretch do we want to encrypt this in the database? Or just mask it on the frontend?

@arthanson commented on GitHub (Oct 12, 2022): @jeremystretch do we want to encrypt this in the database? Or just mask it on the frontend?
Author
Owner

@DanSheps commented on GitHub (Oct 12, 2022):

I personally don't see the point. Anyone who has access to the Shell has access to do a lot more then simply obtain the API key, all without logging as well.

@DanSheps commented on GitHub (Oct 12, 2022): I personally don't see the point. Anyone who has access to the Shell has access to do a lot more then simply obtain the API key, all without logging as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6199