[
https://issues.apache.org/jira/browse/KNOX-2553?focusedWorklogId=566634&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-566634
]
ASF GitHub Bot logged work on KNOX-2553:
----------------------------------------
Author: ASF GitHub Bot
Created on: 16/Mar/21 00:12
Start Date: 16/Mar/21 00:12
Worklog Time Spent: 10m
Work Description: 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]
Issue Time Tracking
-------------------
Worklog Id: (was: 566634)
Remaining Estimate: 0h
Time Spent: 10m
> Add token management flag in generated JWT tokens
> -------------------------------------------------
>
> Key: KNOX-2553
> URL: https://issues.apache.org/jira/browse/KNOX-2553
> Project: Apache Knox
> Issue Type: Task
> Components: Server
> Affects Versions: 1.5.0
> Reporter: Sandor Molnar
> Assignee: Sandor Molnar
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Currently, the generated JWT token - by our KnoxToken service - does not
> contain the information if it was a managed token (e.g. its state is stored
> using TokenStateService).
> Recommended solution: add this information in the claim array (similar to the
> generated token id which is stored as {{knox.id}} claim).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)