-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend the Users REST API Endpoint to support managing API Tokens #5264
Comments
Further consideration needs to be given to the permissions architecture. Allowing users to create tokens only for themselves via the REST API is of limited utility. So, how can we best handle the granting of permissions to particular users that will allow them to create/modify/delete tokens for other users? One approach is to require permissions with constraints that identify the user accounts for which tokens may be created; e.g. |
What if the permission to create tokens via the API was only given to a user with superuser permissions? |
@tagur87 I'd expect many people to be hesitant to grant an API token to superuser accounts. It's a potential solution but I'm not sure it's tenable for everyone. |
I see two paths ways here and maybe it makes sense to actually do both.
|
I have already developed a similar solution as part of a plugin, also adding an encryption layer to not let data (credentials and tokens) pass in cleartext. The whole process is done in two steps, with two differents API endpoints, the first for keys exchange, and the second to actually perform the login. Let me know it you're interested in it. |
@coloHsq - Do you have an example of this plugin that you used? I would be interested in how you did this, as I tried to do something similar, but ran into some road blocks with the user models. If you could publish the code, I would be very grateful! |
At the moment that part is incorporated in a bigger plugin with all my custom endpoints. |
https://github.com/coloHsq/netbox-auth-api It should work. |
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. |
We have the same use case (configuration mgmt) and would be very interested in a netbox-native feature |
Closes #5264: REST API endpoint for tokens
Environment
Proposed Functionality
Establish REST API endpoint at
/api/users/tokens/
for managing tokens via the API.Use Case
Enables the ability to programmatically manage the user tokens that have access to the netbox API. Currently the management of this is only via the Admin UI or user control panel.
There are a couple potential use cases that can be benefitted from.
1) Creation of API users in configuration management (IaC) platform.
nbshell
programmatically to create the API users that we need for our automated processes. Since the creation of the Users and Groups endpoint, we are almost able to do it all via the API. However since Token's is not supported, we will still have to shell out the thenbshell
to add our users.2) Dynamic API user creation
Database Changes
None
External Dependencies
None
The text was updated successfully, but these errors were encountered: