You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "lmccay (via GitHub)" <gi...@apache.org> on 2025/03/30 18:37:42 UTC

[PR] KNOX-3112 - Add an API for CLIENT_ID and SECRET based on KNOXTOKEN API [knox]

lmccay opened a new pull request, #1011:
URL: https://github.com/apache/knox/pull/1011

   ## What changes were proposed in this pull request?
   
   This is a specialized extension of the KNOXTOKEN API to request CLIENT_ID and CLIENT_SECRET.
   This requires the use of Passcode tokens as the CLIENT_SECRET and the TokenID as the CLIENT_ID.
   
   One of the motivations for this is to provide this extension so that it can be deployed separately within the same topology as the KNOXTOKEN API. Another is to codify the conventions being used in order to use the pattern described above for CLIENT_ID and CLIENT_SECRET without having to leave it to the consumer to interpret how to do so.
   
   ## How was this patch tested?
   
   New unit tests were added for the API extension and run along with all existing unit tests.
   Manual testing of the use of CLIENT_ID and CLIENT_SECRET was done with the JWTProvider.


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


Re: [PR] KNOX-3112 - Add an API for CLIENT_ID and SECRET based on KNOXTOKEN API [knox]

Posted by "lmccay (via GitHub)" <gi...@apache.org>.
lmccay merged PR #1011:
URL: https://github.com/apache/knox/pull/1011


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


Re: [PR] KNOX-3112 - Add an API for CLIENT_ID and SECRET based on KNOXTOKEN API [knox]

Posted by "lmccay (via GitHub)" <gi...@apache.org>.
lmccay commented on code in PR #1011:
URL: https://github.com/apache/knox/pull/1011#discussion_r2021199853


##########
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/deploy/ClientCredentialsServiceDeploymentContributor.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.gateway.service.knoxtoken.deploy;
+
+import org.apache.knox.gateway.jersey.JerseyServiceDeploymentContributorBase;
+
+public class ClientCredentialsServiceDeploymentContributor extends JerseyServiceDeploymentContributorBase {
+
+    public static final String ROLE = "CLIENTID";
+
+    @Override
+    public String getRole() {
+        return ROLE;
+    }
+
+    @Override
+    public String getName() {
+        return "ClientCredentialsService";
+    }
+
+    @Override
+    protected String[] getPackages() {
+      return new String[]{ "org.apache.knox.gateway.service.knoxtoken" };
+    }
+
+    @Override
+    protected String[] getPatterns() {
+       return new String[]{ "clientid/api/**?**" };

Review Comment:
   This is fine and aligned with our other pattern definitions across APIs in Knox



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


Re: [PR] KNOX-3112 - Add an API for CLIENT_ID and SECRET based on KNOXTOKEN API [knox]

Posted by "lmccay (via GitHub)" <gi...@apache.org>.
lmccay commented on code in PR #1011:
URL: https://github.com/apache/knox/pull/1011#discussion_r2021744683


##########
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/ClientCredentialsResource.java:
##########
@@ -75,7 +75,7 @@ public Response getAuthenticationToken() {
 
         TokenResponseContext resp = getTokenResponse(context);
         if (resp.responseMap != null) {
-            String passcode = resp.responseMap.passcode;
+            String passcode = (String) resp.responseMap.map.get(PASSCODE);

Review Comment:
   Yeah, this was the source of the initial bug in the implementation. For some reason the tokenid and the passcode are surfaced at the top level but the passcode there is just the passcode portion of what ends up being the client_secret which contains both. I didn't really dig into why there are two levels but the one inside the map is put together and base64 encoded properly for use where the other is just the UUID format which can't be used directly.



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


Re: [PR] KNOX-3112 - Add an API for CLIENT_ID and SECRET based on KNOXTOKEN API [knox]

Posted by "lmccay (via GitHub)" <gi...@apache.org>.
lmccay commented on code in PR #1011:
URL: https://github.com/apache/knox/pull/1011#discussion_r2021752408


##########
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/ClientCredentialsResource.java:
##########
@@ -75,7 +75,7 @@ public Response getAuthenticationToken() {
 
         TokenResponseContext resp = getTokenResponse(context);
         if (resp.responseMap != null) {
-            String passcode = resp.responseMap.passcode;
+            String passcode = (String) resp.responseMap.map.get(PASSCODE);

Review Comment:
   I appears to be related to the fact that when there is no token state server configured that the passcode field isn't generated since it can't be persisted and it requires server side state. Why the actual passcode UUID is generated and returned in the out response is still not clear.



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


Re: [PR] KNOX-3112 - Add an API for CLIENT_ID and SECRET based on KNOXTOKEN API [knox]

Posted by "pzampino (via GitHub)" <gi...@apache.org>.
pzampino commented on code in PR #1011:
URL: https://github.com/apache/knox/pull/1011#discussion_r2021651367


##########
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/ClientCredentialsResource.java:
##########
@@ -75,7 +75,7 @@ public Response getAuthenticationToken() {
 
         TokenResponseContext resp = getTokenResponse(context);
         if (resp.responseMap != null) {
-            String passcode = resp.responseMap.passcode;
+            String passcode = (String) resp.responseMap.map.get(PASSCODE);

Review Comment:
   Why do you not need to reference the token id similarly?



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


Re: [PR] KNOX-3112 - Add an API for CLIENT_ID and SECRET based on KNOXTOKEN API [knox]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1011:
URL: https://github.com/apache/knox/pull/1011#discussion_r2020363304


##########
gateway-service-knoxtoken/src/main/java/org/apache/knox/gateway/service/knoxtoken/deploy/ClientCredentialsServiceDeploymentContributor.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.gateway.service.knoxtoken.deploy;
+
+import org.apache.knox.gateway.jersey.JerseyServiceDeploymentContributorBase;
+
+public class ClientCredentialsServiceDeploymentContributor extends JerseyServiceDeploymentContributorBase {
+
+    public static final String ROLE = "CLIENTID";
+
+    @Override
+    public String getRole() {
+        return ROLE;
+    }
+
+    @Override
+    public String getName() {
+        return "ClientCredentialsService";
+    }
+
+    @Override
+    protected String[] getPackages() {
+      return new String[]{ "org.apache.knox.gateway.service.knoxtoken" };
+    }
+
+    @Override
+    protected String[] getPatterns() {
+       return new String[]{ "clientid/api/**?**" };

Review Comment:
   The URL pattern 'clientid/api/**?**' appears to be incorrectly defined. Consider revising it to a more conventional pattern such as 'clientid/api/**' to ensure proper endpoint matching.
   ```suggestion
          return new String[]{ "clientid/api/**" };
   ```



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