ayush786hack commented on code in PR #13676:
URL: https://github.com/apache/gravitino/pull/13676#discussion_r4243765976


##########
clients/client-java/src/main/java/org/apache/gravitino/client/OAuth2ClientUtil.java:
##########
@@ -89,10 +107,49 @@ private static Pair<String, String> parseCredential(String 
credential) {
     }
   }
 
-  private static Map<String, String> clientCredentialsRequest(
-      String credential, List<String> scopes) {
+  private static Pair<Map<String, String>, Map<String, String>> 
clientCredentialsRequest(
+      String credential,
+      List<String> scopes,
+      OAuth2ClientAuthenticationMethod authenticationMethod) {
     Pair<String, String> credentialPair = parseCredential(credential);
-    return clientCredentialsRequest(credentialPair.getLeft(), 
credentialPair.getRight(), scopes);
+
+    if (authenticationMethod == 
OAuth2ClientAuthenticationMethod.CLIENT_SECRET_BASIC) {
+      Preconditions.checkArgument(
+          StringUtils.isNotBlank(credentialPair.getLeft()),
+          "Client ID is required for client_secret_basic authentication");
+
+      String encodedClientId;
+      String encodedClientSecret;
+
+      try {
+        encodedClientId =
+            URLEncoder.encode(credentialPair.getLeft(), 
StandardCharsets.UTF_8.name());
+        encodedClientSecret =
+            URLEncoder.encode(credentialPair.getRight(), 
StandardCharsets.UTF_8.name());

Review Comment:
   Fixed. Java and Python now use matching form-encoding rules for the client 
ID and client secret before Base64 encoding, so reserved characters such as `*` 
and `~` are handled consistently. I added 
`testClientSecretBasicEncodesReservedCharacters` in Java using the same 
credential test vector as Python (`client*@id:s ecret:/+?~`) and verified that 
both produce the same expected Basic Authorization header. All 7 Java OAuth2 
provider tests and all 9 Python OAuth2 provider tests pass. Thanks for pointing 
this out!



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

Reply via email to