You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/09/21 13:39:00 UTC
[jira] [Work logged] (KNOX-2805) getUserTokens api should return all tokens which are matching either of the same metadata name passed as query param
[ https://issues.apache.org/jira/browse/KNOX-2805?focusedWorklogId=810760&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-810760 ]
ASF GitHub Bot logged work on KNOX-2805:
----------------------------------------
Author: ASF GitHub Bot
Created on: 21/Sep/22 13:38
Start Date: 21/Sep/22 13:38
Worklog Time Spent: 10m
Work Description: smolnar82 opened a new pull request, #633:
URL: https://github.com/apache/knox/pull/633
## What changes were proposed in this pull request?
If the user supplied the same metadata name with different values in Knox's `getUserTokens` API, the result only contained tokens that matched the first name/value pair. This is now fixed by including all values of each metadata name during the filter logic.
## How was this patch tested?
I manually tested this feature and added the metadata/expected result matrix in KNOX-2805.
The `curl` command I used to create the tokens:
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token?md_Name=reina&md_Score=50"
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token?md_Name=mary&md_Score=100"
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token?md_Name=mary&md_Score=20&md_Grade=A"
```
<img width="1788" alt="Screenshot 2022-09-21 at 15 30 05" src="https://user-images.githubusercontent.com/34065904/191517032-3aeb48cc-e7d5-4b60-9396-988c30cace62.png">
Here are the `curl` commands and responses I used for verifying my changes:
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token/getUserTokens?userName=admin"
{
"tokens": [{
"tokenId": "fff4eb61-09c0-4460-aba9-0ccf45e31cef",
"issueTime": "2022-09-21T14:49:32.701+0200",
"expiration": "2023-01-19T13:49:32.698+0100",
"maxLifetime": "2022-09-28T14:49:32.701+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "50",
"Name": "reina"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572701,
"expirationLong": 1674132572698,
"maxLifetimeLong": 1664369372701
}, {
"tokenId": "dec27b78-82e1-423e-bd6d-3847bf0be026",
"issueTime": "2022-09-21T14:49:32.751+0200",
"expiration": "2023-01-19T13:49:32.748+0100",
"maxLifetime": "2022-09-28T14:49:32.751+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "100",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572751,
"expirationLong": 1674132572748,
"maxLifetimeLong": 1664369372751
}, {
"tokenId": "0a68d122-f2d1-41a8-9da3-b12ff9e463e4",
"issueTime": "2022-09-21T14:49:32.808+0200",
"expiration": "2023-01-19T13:49:32.805+0100",
"maxLifetime": "2022-09-28T14:49:32.808+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "20",
"Grade": "A",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572808,
"expirationLong": 1674132572805,
"maxLifetimeLong": 1664369372808
}]
}
```
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token/getUserTokens?userName=admin&md_Name=reina"
{
"tokens": [{
"tokenId": "fff4eb61-09c0-4460-aba9-0ccf45e31cef",
"issueTime": "2022-09-21T14:49:32.701+0200",
"expiration": "2023-01-19T13:49:32.698+0100",
"maxLifetime": "2022-09-28T14:49:32.701+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "50",
"Name": "reina"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572701,
"expirationLong": 1674132572698,
"maxLifetimeLong": 1664369372701
}]
}
```
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token/getUserTokens?userName=admin&md_Name=mary"
{
"tokens": [{
"tokenId": "dec27b78-82e1-423e-bd6d-3847bf0be026",
"issueTime": "2022-09-21T14:49:32.751+0200",
"expiration": "2023-01-19T13:49:32.748+0100",
"maxLifetime": "2022-09-28T14:49:32.751+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "100",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572751,
"expirationLong": 1674132572748,
"maxLifetimeLong": 1664369372751
}, {
"tokenId": "0a68d122-f2d1-41a8-9da3-b12ff9e463e4",
"issueTime": "2022-09-21T14:49:32.808+0200",
"expiration": "2023-01-19T13:49:32.805+0100",
"maxLifetime": "2022-09-28T14:49:32.808+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "20",
"Grade": "A",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572808,
"expirationLong": 1674132572805,
"maxLifetimeLong": 1664369372808
}]
}
```
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token/getUserTokens?userName=admin&md_Score=100"
{
"tokens": [{
"tokenId": "dec27b78-82e1-423e-bd6d-3847bf0be026",
"issueTime": "2022-09-21T14:49:32.751+0200",
"expiration": "2023-01-19T13:49:32.748+0100",
"maxLifetime": "2022-09-28T14:49:32.751+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "100",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572751,
"expirationLong": 1674132572748,
"maxLifetimeLong": 1664369372751
}]
}
```
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token/getUserTokens?userName=admin&md_Name=mary&md_Score=20"
{
"tokens": [{
"tokenId": "dec27b78-82e1-423e-bd6d-3847bf0be026",
"issueTime": "2022-09-21T14:49:32.751+0200",
"expiration": "2023-01-19T13:49:32.748+0100",
"maxLifetime": "2022-09-28T14:49:32.751+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "100",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572751,
"expirationLong": 1674132572748,
"maxLifetimeLong": 1664369372751
}, {
"tokenId": "0a68d122-f2d1-41a8-9da3-b12ff9e463e4",
"issueTime": "2022-09-21T14:49:32.808+0200",
"expiration": "2023-01-19T13:49:32.805+0100",
"maxLifetime": "2022-09-28T14:49:32.808+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "20",
"Grade": "A",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572808,
"expirationLong": 1674132572805,
"maxLifetimeLong": 1664369372808
}]
}
```
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token/getUserTokens?userName=admin&md_Name=mary&md_Name=reina"
{
"tokens": [{
"tokenId": "fff4eb61-09c0-4460-aba9-0ccf45e31cef",
"issueTime": "2022-09-21T14:49:32.701+0200",
"expiration": "2023-01-19T13:49:32.698+0100",
"maxLifetime": "2022-09-28T14:49:32.701+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "50",
"Name": "reina"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572701,
"expirationLong": 1674132572698,
"maxLifetimeLong": 1664369372701
}, {
"tokenId": "dec27b78-82e1-423e-bd6d-3847bf0be026",
"issueTime": "2022-09-21T14:49:32.751+0200",
"expiration": "2023-01-19T13:49:32.748+0100",
"maxLifetime": "2022-09-28T14:49:32.751+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "100",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572751,
"expirationLong": 1674132572748,
"maxLifetimeLong": 1664369372751
}, {
"tokenId": "0a68d122-f2d1-41a8-9da3-b12ff9e463e4",
"issueTime": "2022-09-21T14:49:32.808+0200",
"expiration": "2023-01-19T13:49:32.805+0100",
"maxLifetime": "2022-09-28T14:49:32.808+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "20",
"Grade": "A",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572808,
"expirationLong": 1674132572805,
"maxLifetimeLong": 1664369372808
}]
}
```
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token/getUserTokens?userName=admin&md_Name=*"
{
"tokens": [{
"tokenId": "fff4eb61-09c0-4460-aba9-0ccf45e31cef",
"issueTime": "2022-09-21T14:49:32.701+0200",
"expiration": "2023-01-19T13:49:32.698+0100",
"maxLifetime": "2022-09-28T14:49:32.701+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "50",
"Name": "reina"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572701,
"expirationLong": 1674132572698,
"maxLifetimeLong": 1664369372701
}, {
"tokenId": "dec27b78-82e1-423e-bd6d-3847bf0be026",
"issueTime": "2022-09-21T14:49:32.751+0200",
"expiration": "2023-01-19T13:49:32.748+0100",
"maxLifetime": "2022-09-28T14:49:32.751+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "100",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572751,
"expirationLong": 1674132572748,
"maxLifetimeLong": 1664369372751
}, {
"tokenId": "0a68d122-f2d1-41a8-9da3-b12ff9e463e4",
"issueTime": "2022-09-21T14:49:32.808+0200",
"expiration": "2023-01-19T13:49:32.805+0100",
"maxLifetime": "2022-09-28T14:49:32.808+0200",
"metadata": {
"enabled": true,
"createdBy": null,
"customMetadataMap": {
"Score": "20",
"Grade": "A",
"Name": "mary"
},
"userName": "admin",
"comment": null
},
"issueTimeLong": 1663764572808,
"expirationLong": 1674132572805,
"maxLifetimeLong": 1664369372808
}]
}
```
```
curl -iku admin:admin-password --cookie "hadoop-jwt=$HADOOP_JWT_COOKIE" -X GET "https://localhost:8443/gateway/homepage/knoxtoken/api/v1/token/getUserTokens?userName=admin&md_Unknown=*"
{
"tokens": []
}
```
Issue Time Tracking
-------------------
Worklog Id: (was: 810760)
Remaining Estimate: 0h
Time Spent: 10m
> getUserTokens api should return all tokens which are matching either of the same metadata name passed as query param
> --------------------------------------------------------------------------------------------------------------------
>
> Key: KNOX-2805
> URL: https://issues.apache.org/jira/browse/KNOX-2805
> Project: Apache Knox
> Issue Type: Bug
> Affects Versions: 1.3.0
> Reporter: J.Andreina
> Assignee: Sandor Molnar
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> *Steps:*
> 1. Create token1 with md_Name=reina&md_Score=50
> 2. Create token2 with md_Name=mary&md_Score=100
> 3. Create token3 with md_Name=mary&md_Score=20&md_Grade=A
> *Scenario 1:*
> Fetch token with "md_Name=mary&md_Score=100"
> Result : returns token2 and token3
> *Scenario 2:*
> Fetch token with "md_Name=mary&md_Name=reina"
> Result : return token2 and token3
> *Expectation:*
> if the api returns all matching tokens of any of the mentioned metadata in query param , then i would expect scenario2 to return me token1,2,3 though the passed metadata name in query param ("Name") is same but with different values. But here it doesnt return token1
--
This message was sent by Atlassian Jira
(v8.20.10#820010)