Allow to store an "audit user" for changes via restAPI #10500

Closed
opened 2025-12-29 21:32:16 +01:00 by adam · 9 comments
Owner

Originally created by @JohannesKreuzer on GitHub (Nov 21, 2024).

NetBox version

v4.1.6

Feature type

Data model extension

Triage priority

N/A

Proposed functionality

allow to pass an username (actually an arbitrary string) via restAPI to store the user of the upstream application which triggered the rest api request for auditing purposes, it should default to the username of the netbox user triggering the request, if it is not passed in the request. Might be done via an additional HTTP-Header to be sent from restAPI client to netbox server.

Use case

Netbox is used as a Datasource for an upstream application. To be able to see who really triggered the changes in netbox, it is needed to be able to pass the username from the upstream application to netbox.

Database changes

add an additonal audit_username field of type string to ChangeLog model.

External dependencies

support in the netbox restAPI client libraries

Originally created by @JohannesKreuzer on GitHub (Nov 21, 2024). ### NetBox version v4.1.6 ### Feature type Data model extension ### Triage priority N/A ### Proposed functionality allow to pass an username (actually an arbitrary string) via restAPI to store the user of the upstream application which triggered the rest api request for auditing purposes, it should default to the username of the netbox user triggering the request, if it is not passed in the request. Might be done via an additional HTTP-Header to be sent from restAPI client to netbox server. ### Use case Netbox is used as a Datasource for an upstream application. To be able to see who really triggered the changes in netbox, it is needed to be able to pass the username from the upstream application to netbox. ### Database changes add an additonal audit_username field of type string to ChangeLog model. ### External dependencies support in the netbox restAPI client libraries
adam added the type: feature label 2025-12-29 21:32:16 +01:00
adam closed this issue 2025-12-29 21:32:16 +01:00
Author
Owner

@rboucher-me commented on GitHub (Feb 13, 2025):

Best practices is to use different users (with corresponding API keys) for each application. This should satisfy this need.

@rboucher-me commented on GitHub (Feb 13, 2025): Best practices is to use different users (with corresponding API keys) for each application. This should satisfy this need.
Author
Owner

@JohannesKreuzer commented on GitHub (Mar 24, 2025):

@rboucher-me this is not about having different applications reusing the API key, but about to be able to audit which user of the application triggered the changes in NetBox.

@JohannesKreuzer commented on GitHub (Mar 24, 2025): @rboucher-me this is not about having different applications reusing the API key, but about to be able to audit which user of the application triggered the changes in NetBox.
Author
Owner

@rboucher-me commented on GitHub (Mar 24, 2025):

Understood. You make a good point and the "audit trail" use case probably requires further consideration.

@rboucher-me commented on GitHub (Mar 24, 2025): Understood. You make a good point and the "audit trail" use case probably requires further consideration.
Author
Owner

@jeremystretch commented on GitHub (Mar 24, 2025):

to be able to audit which user of the application triggered the changes in NetBox.

The application would need to be configured to act as that user, with an API token tied to the user's account in NetBox.

@jeremystretch commented on GitHub (Mar 24, 2025): > to be able to audit which user of the application triggered the changes in NetBox. The application would need to be configured to act as that user, with an API token tied to the user's account in NetBox.
Author
Owner

@JohannesKreuzer commented on GitHub (Mar 24, 2025):

@jeremystretch
In the upstream application, you don't want every user (which is unaware of NetBox, and would have no direct access to NetBox) to have to go to NetBox to create an API token and feed to the upstream Application and store there.

e.g. think about a Managed hosting system, managing VMs on the hypervisor and also storing the information in NetBox. Users are only allowed to access the application itself, but have no access to the hypervisor and NetBox. Only the application has access with restricted service credentials, only granting the least necessary privileges to the application. The changes in NetBox should then be traceable to the application user which triggered the change (creating a tuple to identify the original user (NetBox User + audit user).

@JohannesKreuzer commented on GitHub (Mar 24, 2025): @jeremystretch In the upstream application, you don't want every user (which is unaware of NetBox, and would have no direct access to NetBox) to have to go to NetBox to create an API token and feed to the upstream Application and store there. e.g. think about a Managed hosting system, managing VMs on the hypervisor and also storing the information in NetBox. Users are only allowed to access the application itself, but have no access to the hypervisor and NetBox. Only the application has access with restricted service credentials, only granting the least necessary privileges to the application. The changes in NetBox should then be traceable to the application user which triggered the change (creating a tuple to identify the original user (NetBox User + audit user).
Author
Owner

@jeremystretch commented on GitHub (Mar 24, 2025):

In the upstream application, you don't want every user (which is unaware of NetBox, and would have no direct access to NetBox) to have to go to NetBox to create an API token and feed to the upstream Application and store there.

It seems you're conflating two authentication systems. If the user of a remote application has no equivalent account in NetBox, then it makes no sense for NetBox to associate that user with a change made in NetBox: That information would need to be recorded within the remote application. NetBox knows only about the users which have accounts created within it.

@jeremystretch commented on GitHub (Mar 24, 2025): > In the upstream application, you don't want every user (which is unaware of NetBox, and would have no direct access to NetBox) to have to go to NetBox to create an API token and feed to the upstream Application and store there. It seems you're conflating two authentication systems. If the user of a remote application has no equivalent account in NetBox, then it makes no sense for NetBox to associate that user with a change made in NetBox: That information would need to be recorded within the remote application. NetBox knows only about the users which have accounts created within it.
Author
Owner

@JohannesKreuzer commented on GitHub (Mar 24, 2025):

@jeremystretch We don't want to associate an additional NetBox user, but from DB perspective a string field in the ChangeLog entry, to store this info.

@JohannesKreuzer commented on GitHub (Mar 24, 2025): @jeremystretch We don't want to associate an additional NetBox user, but from DB perspective a string field in the ChangeLog entry, to store this info.
Author
Owner

@jeremystretch commented on GitHub (Mar 24, 2025):

Right; a string that represents a user completely foreign to NetBox. It's arbitrary metadata, extraneous to the intended purpose of change logging in NetBox.

@jeremystretch commented on GitHub (Mar 24, 2025): Right; a string that represents a user completely foreign to NetBox. It's arbitrary metadata, extraneous to the intended purpose of change logging in NetBox.
Author
Owner

@jnovinger commented on GitHub (Mar 27, 2025):

While we can appreciate this and related use cases, we don't think this is the proper way to attack this. This points to a larger feature that would require more exploration and design work.

@jnovinger commented on GitHub (Mar 27, 2025): While we can appreciate this and related use cases, we don't think this is the proper way to attack this. This points to a larger feature that would require more exploration and design work.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10500