smolnar82 opened a new pull request #416:
URL: https://github.com/apache/knox/pull/416


   ## What changes were proposed in this pull request?
   
   In order to avoid adding new and confusing methods into `JWTokenAuthority`, 
I introduced a model object to store possible JWT attributes and kept only one 
method to issue a token.
   So, from now on, the `managed` flag is available in:
   
   - the JSON response as a new element
   - the issued JWT token within a claim called `managed.token`
   
   ## How was this patch tested?
   
   Updated/added/ran unit tests and executed manual testing:
   
   1. added the `KNOXTOKEN` service into `sandbox`. Set the 
`knox.token.exp.server-managed` to `false` and then changed it to `true` (see 
results below)
   2. added a new topology called `tokenbased`
   3. I could login to the Knox Home page and to Admin UI
   4. Issued the following `curl` commands
   
   4.1 `knox.token.exp.server-managed = false`
   ```
   $ curl -iku admin:admin-password 
https://localhost:8443/gateway/sandbox/knoxtoken/api/v1/token
   HTTP/1.1 200 OK
   ...
   
   
{"access_token":"eyJhbGciO...4kjahYA","token_id":"49fd0e9e-a5d9-4a14-86cf-c11e5bac151d","managed":"false","target_url":"https://localhost:8443/gateway/tokenbased","endpoint_public_cert":"MIIDeTCCAmGgAwI...M0XFRx+jhA=","token_type":"Bearer","expires_in":1615886851180}
   ```
   4.2 `knox.token.exp.server-managed = true`
   ```
   $ curl -iku admin:admin-password 
https://localhost:8443/gateway/sandbox/knoxtoken/api/v1/token
   HTTP/1.1 200 OK
   ...
   
   
{"access_token":"eyJhbGciO...F0rC4A0g","token_id":"efbed646-2210-4731-9dab-71df641943b0","managed":"true","target_url":"https://localhost:8443/gateway/tokenbased","endpoint_public_cert":"MIIDeTCCAmGgAwI...M0XFRx+jhA=","token_type":"Bearer","expires_in":1615887095677}
   ```
   5. Verified both tokens using the `tokenbased` topology.
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to