You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "smolnar82 (via GitHub)" <gi...@apache.org> on 2024/05/09 09:00:26 UTC
[PR] KNOX-3038 - Added a new element in OAuthResource response called lifetime_secs [knox]
smolnar82 opened a new pull request, #907:
URL: https://github.com/apache/knox/pull/907
## What changes were proposed in this pull request?
To honor the contract of the existing expiration time field in Knox Tokens, I removed the override in the new `OAuthResource` class. Thus, everything that depends on this field will be the same as in the case of our "regular" tokens (token eviction is the most important piece here).
To indicate the actual OAuth token lifetime, I added a new field in the generated JSON response called `lifetime_secs` that indicates what @lmccay wanted to have in the `expires_in` field in his original patch.
## How was this patch tested?
Updated JUnit tests and executed manual testing:
```
$ curl -ik -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "grant_type=client_credentials" --data "client_id=$CLIENT_ID" --data-urlencode "client_secret=$CLIENT_SECRET" https://localhost:8443/gateway/tokenbased/oauth/v1/token
HTTP/1.1 200 OK
Date: Thu, 09 May 2024 08:18:18 GMT
Content-Type: application/json
Content-Length: 1098
{"access_token":"eyJqa...0ijh_g","refresh_token":"a36bafd4...9491-7e17e710a004","lifetime_secs":10368000,"issued_token_type":"urn:ietf:params:oauth:token-type:access_token","token_type":"Bearer","expires_in":1725610698544}
```
The `tokenabased` topology was configured with `knox.token.ttl = 10368000000`. As you can see, the `lifetime_secs` field in the response got populated as expected (converted the given TTL milliseconds to seconds).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KNOX-3038 - Added a new element in OAuthResource response called lifetime_secs [knox]
Posted by "lmccay (via GitHub)" <gi...@apache.org>.
lmccay commented on code in PR #907:
URL: https://github.com/apache/knox/pull/907#discussion_r1596018729
##########
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/OAuthResource.java:
##########
@@ -90,6 +91,7 @@ public Response getAuthenticationToken() {
map.put(ISSUED_TOKEN_TYPE, ISSUED_TOKEN_TYPE_ACCESS_TOKEN_VALUE);
// let's use the passcode as the refresh token
map.put(REFRESH_TOKEN, passcode);
+ map.put(LIFETIME, getTokenLifetimeInSeconds());
Review Comment:
If I am reading this correctly, then returning the actual value in the response as lifetime_secs would be unexpected by OAuth flow consumers/clients. They will be looking for expires_in.
I think what we need to do is calculate both the existing expires_in which millis since epoch as well as this OAuth expires_in which is lifetime_secs and return one in the response and store the other in the token metadata for reaping and monitoring, etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KNOX-3038 - The expires_in field in OAuthResource response returns the configured token TTL. [knox]
Posted by "smolnar82 (via GitHub)" <gi...@apache.org>.
smolnar82 merged PR #907:
URL: https://github.com/apache/knox/pull/907
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@knox.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org