[
https://issues.apache.org/jira/browse/KNOX-2712?focusedWorklogId=737823&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-737823
]
ASF GitHub Bot logged work on KNOX-2712:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Mar/22 21:57
Start Date: 07/Mar/22 21:57
Worklog Time Spent: 10m
Work Description: pzampino commented on a change in pull request #542:
URL: https://github.com/apache/knox/pull/542#discussion_r821130144
##########
File path:
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
##########
@@ -395,11 +397,22 @@ public Response doPost() {
@GET
@Path(GET_USER_TOKENS)
@Produces({APPLICATION_JSON, APPLICATION_XML})
- public Response getUserTokens(@QueryParam("userName") String userName) {
+ public Response getUserTokens(@QueryParam("userName") String userName,
@QueryParam("mdName") String metadataName, @QueryParam("mdValue") String
metadataValue) {
Review comment:
Is it not possible to specify multiple metadata NV pairs in the query
string? This seems to allow only a single pair.
##########
File path:
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/TokenResource.java
##########
@@ -729,6 +743,19 @@ private Response getAuthenticationToken() {
return Response.ok().entity("{ \"Unable to acquire token.\" }").build();
}
+ private void addArbitraryTokenMetadata(TokenMetadata tokenMetadata) {
+ final String metadataPrefix = "md_";
+ final Enumeration<String> paramNames = request.getParameterNames();
+ while (paramNames.hasMoreElements()) {
+ final String paramName = paramNames.nextElement();
+ if (paramName.startsWith(metadataPrefix)) {
+ final String metadataName = paramName.replace(metadataPrefix, "");
Review comment:
Is this less expensive than `paramName.substring(metadataPrefix.length()
+ 1)` ? What if the paramName value itself includes the metadataPrefix String
(e.g., md_MyMetadata_md_xyz)
##########
File path:
gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java
##########
@@ -1006,7 +1007,7 @@ public void
testTokenLimitChangeAfterAlreadyHavingTokens() throws Exception {
for (int i = 0; i < numberOfPreExistingTokens; i++) {
tr.doGet();
}
- Response getKnoxTokensResponse = tr.getUserTokens(USER_NAME);
+ Response getKnoxTokensResponse = tr.getUserTokens(USER_NAME, null, null);
Review comment:
Should these additional parameters be required here? I would expect the
same result from a call to `tr.getUserTokens(USER_NAME);` Is this a
backward-compatabiltiy concern?
##########
File path:
gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java
##########
@@ -1046,7 +1047,7 @@ private void testLimitingTokensPerUser(String
configuredLimit, int numberOfToken
throw new Exception(getTokenResponse.getEntity().toString());
}
}
- final Response getKnoxTokensResponse = tr.getUserTokens(USER_NAME);
+ final Response getKnoxTokensResponse = tr.getUserTokens(USER_NAME, null,
null);
Review comment:
Same as previous comment/question.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 737823)
Time Spent: 20m (was: 10m)
> Adding arbitrary metadata to a Knox Token
> -----------------------------------------
>
> Key: KNOX-2712
> URL: https://issues.apache.org/jira/browse/KNOX-2712
> Project: Apache Knox
> Issue Type: Improvement
> Components: Server
> Affects Versions: 1.6.0
> Reporter: Sandor Molnar
> Assignee: Sandor Molnar
> Priority: Critical
> Fix For: 2.0.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> We would need to enhance our GET API to accept an arbitrary list of key/value
> pairs as Knox token metadata. At the time of this Jira is being created, the
> following hard-coded metadata exists for a Knox Token:
> * userName
> * comment
> * enabled
> * passcode
> The plan is to modify our TokenResource to accept query parameters starting
> with the ‘{{{}md_{}}}’ prefix and treat them as Knox Token Metadata. For
> instance:
> {noformat}
> curl -iku admin:admin-password -X GET
> 'https://localhost:8443/gateway/sandbox/knoxtoken/api/v1/token?md_notebookName=accountantKnoxToken&md_souldBeRemovedBy=31March2022&md_otherMeaningfuMetadata=KnoxIsCool'{noformat}
> When such a token is created by Knox, we should save the following metadata
> too:
> * {{notebookName=accountantKnoxToken}}
> * {{shouldBeRemovedBy=31March2022}}
> * {{otherMeaningfulMetadata=KnoxIsCool}}
> It’s not only Knox will be able to save these metadata, but we have to update
> our existing {{getUserTokens}} API endpoint to be able to fetch basic token
> information (see
> {{{}org.apache.knox.gateway.services.security.token.KnoxToken{}}}) using the
> supplied metadata name besides the user name information.
> For instance:
> {noformat}
> curl -iku admin:admin-password -X GET
> 'https://localhost:8443/gateway/sandbox/knoxtoken/api/v1/token/getUserTokens?userName=admin&mdName=notebookName&mdValue=accountantKnoxToken'{noformat}
> will return all Knox tokens where metadata with _‘notebookName’_ exists and
> equals {_}‘accountantKnoxToken’{_}.
> Finally, the Token Management page should display metadata too.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)