Skip to content
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

Support for setting expiration time when using the API token provisioning endpoint (/api/users/tokens/provision/) #12870

Closed
iamroddo opened this issue Jun 12, 2023 · 2 comments · Fixed by #13618
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@iamroddo
Copy link

NetBox version

v3.5.3

Python version

3.10

Steps to Reproduce

API ignores "expires" attribute when generating a token for a user and sets value to null.

curl 'https://<netbox hostname>/api/users/tokens/provision/' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
    "username": "admin",
    "password": "<admin password>",
    "expires": "2023-06-12T12:47:47.245Z"
}'

{"id":40,"url":"https://<netbox hostname>/api/users/tokens/40/","display":"<key>","user":{"id":1,"url":"https://<netbox hostname>/api/users/users/1/","display":"admin","username":"admin"},"created":"2023-06-12T12:51:57.222273Z","expires":null,"last_used":null,"key":"<key>","write_enabled":true,"description":"","allowed_ips":null}

If an invalid date string is set to the value of "expires" the same thing happens.

Expected Behavior

The response should be that the "expires" is set to that which is in the request payload, or an error if it is invalid and not setting it to null which has the result that the token has unlimited validity.

Observed Behavior

All tokens set via the API have unlimited validity.

@iamroddo iamroddo added the type: bug A confirmed report of unexpected behavior in the application label Jun 12, 2023
@iamroddo iamroddo changed the title Unable to set expiry time for token via API Unable to set expiry time for token via API (api/users/tokens/provision/) Jun 12, 2023
@jeremystretch jeremystretch changed the title Unable to set expiry time for token via API (api/users/tokens/provision/) Support for setting expiration time when using the API token provisioning endpoint (/api/users/tokens/provision/) Jun 14, 2023
@jeremystretch jeremystretch added type: feature Introduction of new functionality to the application status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation and removed type: bug A confirmed report of unexpected behavior in the application labels Jun 14, 2023
stuntguy3000 added a commit to stuntguy3000/netbox that referenced this issue Jun 15, 2023
@abhi1693
Copy link
Member

@stuntguy3000 Can you please comment on the issue so that I can it this to you?

@stuntguy3000
Copy link
Contributor

@stuntguy3000 Can you please comment on the issue so that I can it this to you?

Sure

@abhi1693 abhi1693 added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Jun 16, 2023
@abhi1693 abhi1693 assigned abhi1693 and unassigned stuntguy3000 Aug 30, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
4 participants