IQSS / dataverse

Open source research data repository software
http://dataverse.org
Other
882 stars 494 forks source link

Includes new token's expiration date in "users/token/recreate" endpoint #10858

Closed GPortas closed 1 month ago

GPortas commented 1 month ago

What this PR does / why we need it:

An optional query parameter called 'returnExpiration' has been added to the 'users/token/recreate' endpoint, which, if set to true, returns the expiration time in the response message.

Which issue(s) this PR closes:

Special notes for your reviewer:

I've kept the string messages as responses for backward compatibility, although it would be interesting to use JSON responses in the future, as multiple properties are being returned in the same response message.

Suggestions on how to test this:

For obtaining a new token without its expiration time (current behavior)

curl -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/users/token/recreate" This endpoint by default will return a response message indicating the user identifier and the new token.

For obtaining a new token with its expiration time

curl -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/users/token/recreate?returnExpiration=true" Does this PR introduce a user interface change? If mockups are available, please link/include them here:

No

Is there a release notes update needed for this change?:

Yes, attached.

Additional documentation:

No

coveralls commented 1 month ago

Coverage Status

Changes unknown when pulling bdf626b15381fd61921440fd6e5a673e20447184 on 10857-add-expiration-date-to-recreate-token-api into on develop.

github-actions[bot] commented 1 month ago

:package: Pushed preview images as

ghcr.io/gdcc/dataverse:10857-add-expiration-date-to-recreate-token-api
ghcr.io/gdcc/configbaker:10857-add-expiration-date-to-recreate-token-api

:ship: See on GHCR. Use by referencing with full name as printed above, mind the registry name.

github-actions[bot] commented 1 month ago

:package: Pushed preview images as

ghcr.io/gdcc/dataverse:10857-add-expiration-date-to-recreate-token-api
ghcr.io/gdcc/configbaker:10857-add-expiration-date-to-recreate-token-api

:ship: See on GHCR. Use by referencing with full name as printed above, mind the registry name.

ofahimIQSS commented 1 month ago

@GPortas Hey - can you please update the pull request with the latest from develop.

github-actions[bot] commented 1 month ago

:package: Pushed preview images as

ghcr.io/gdcc/dataverse:10857-add-expiration-date-to-recreate-token-api
ghcr.io/gdcc/configbaker:10857-add-expiration-date-to-recreate-token-api

:ship: See on GHCR. Use by referencing with full name as printed above, mind the registry name.

ofahimIQSS commented 1 month ago

Tested in Internal - no issues found image

ofahimIQSS commented 1 month ago

omerfahim@HMDC-HMDCs-MacBook-Pro dataverse % curl -H "X-Dataverse-key:5a6185e1-e0a2-4b7e-b6a6-62da5b854e22 " -X POST "https://dataverse-internal.iq.harvard.edu/api/users/token/recreate?returnExpiration=true" {"status":"OK","data":{"message":"New token for SmokeTest24 is a3d27fc6-5000-49d4-ac94-ff4cbeef0e50 and expires on 2025-10-02 13:38:25.443"}}%

Was testing again today and noticed that the Expiration date on the UI doesn't match up with the expiration date on the API call. - This is likely due to the UI following EST timezone and API using UTC timezone. image