You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2022/03/08 11:23:22 UTC

[GitHub] [knox] smolnar82 commented on a change in pull request #542: KNOX-2712 - Managing custom Knox Token metadata

smolnar82 commented on a change in pull request #542:
URL: https://github.com/apache/knox/pull/542#discussion_r821569577



##########
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:
       This is a good idea, let me check our possibilities here.

##########
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:
       Nice catch (both the performance observation and the MD naming). I'll fix it soon.

##########
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:
       Let me add overloaded methods to support multiple cases.




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