roryqi commented on code in PR #10503:
URL: https://github.com/apache/gravitino/pull/10503#discussion_r2978638168
##########
server-common/src/test/java/org/apache/gravitino/server/authentication/TestStaticSignKeyValidator.java:
##########
@@ -527,4 +516,50 @@ public void testValidateTokenWithGroups() {
assertTrue(userPrincipal.getGroups().stream().anyMatch(g ->
g.getGroupname().equals("group1")));
assertTrue(userPrincipal.getGroups().stream().anyMatch(g ->
g.getGroupname().equals("group2")));
}
+
+ @Test
+ public void testValidateRealKeycloakTokenWithGroups() {
+ Map<String, String> config = new HashMap<String, String>();
+ config.put("gravitino.authenticator.oauth.groupsFields", "groups");
+ config.put("gravitino.authenticator.oauth.groupMapper.regex.pattern",
"^/(.*)");
+ config.put("gravitino.authenticator.oauth.principalFields",
"preferred_username");
+ config.put("gravitino.authenticator.oauth.allowSkewSecs", "315360000");
+ config.put(
+ "gravitino.authenticator.oauth.defaultSignKey",
+ "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0J4W"
+ +
"fjgnb/nyrkOuVefHoGu17pIpiUm/TaTeVKoZcYxphcL8HAg2jKTQYov4SvlWZ4wXHZ1FayPm5+e74W5vSGOgZzjyzMZKithGkYa"
+ +
"gbRuXbUeo4sw6f7t4BsAmgpAUgyBYE/1fdEghHtKHia1Er1grQVsvGVAAbYoFjh+OfcnRLYFAel+ADvX83RmsK16laxXpY+LeFk"
+ +
"jugOsCaD5mnGfgqQC96t9H4/QlsqJacg+9YImZWxUHtqN/itrV/VCdGVfywih6Dk9F2jxt4rL9++3xVdG/OrvFDtNW98xhKqgqF"
+ + "iXLsjKPT5WmqzbGCaQi/29Cdu9QOmd/IxmVeRy0+wIDAQAB");
+ config.put("gravitino.authenticator.oauth.serverUri",
"http://localhost:8080");
+ config.put(
+ "gravitino.authenticator.oauth.tokenPath",
+ "/realms/gravitinorealm/protocol/openid-connect/token");
+ config.put("gravitino.authenticator.oauth.signAlgorithmType", "RS256");
+
+ validator.initialize(createConfig(config));
+ String token =
Review Comment:
Could u add comment for json data?
##########
server-common/src/test/java/org/apache/gravitino/server/authentication/TestStaticSignKeyValidator.java:
##########
@@ -527,4 +516,50 @@ public void testValidateTokenWithGroups() {
assertTrue(userPrincipal.getGroups().stream().anyMatch(g ->
g.getGroupname().equals("group1")));
assertTrue(userPrincipal.getGroups().stream().anyMatch(g ->
g.getGroupname().equals("group2")));
}
+
+ @Test
+ public void testValidateRealKeycloakTokenWithGroups() {
+ Map<String, String> config = new HashMap<String, String>();
+ config.put("gravitino.authenticator.oauth.groupsFields", "groups");
+ config.put("gravitino.authenticator.oauth.groupMapper.regex.pattern",
"^/(.*)");
+ config.put("gravitino.authenticator.oauth.principalFields",
"preferred_username");
+ config.put("gravitino.authenticator.oauth.allowSkewSecs", "315360000");
+ config.put(
+ "gravitino.authenticator.oauth.defaultSignKey",
+ "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0J4W"
+ +
"fjgnb/nyrkOuVefHoGu17pIpiUm/TaTeVKoZcYxphcL8HAg2jKTQYov4SvlWZ4wXHZ1FayPm5+e74W5vSGOgZzjyzMZKithGkYa"
+ +
"gbRuXbUeo4sw6f7t4BsAmgpAUgyBYE/1fdEghHtKHia1Er1grQVsvGVAAbYoFjh+OfcnRLYFAel+ADvX83RmsK16laxXpY+LeFk"
+ +
"jugOsCaD5mnGfgqQC96t9H4/QlsqJacg+9YImZWxUHtqN/itrV/VCdGVfywih6Dk9F2jxt4rL9++3xVdG/OrvFDtNW98xhKqgqF"
+ + "iXLsjKPT5WmqzbGCaQi/29Cdu9QOmd/IxmVeRy0+wIDAQAB");
+ config.put("gravitino.authenticator.oauth.serverUri",
"http://localhost:8080");
+ config.put(
+ "gravitino.authenticator.oauth.tokenPath",
+ "/realms/gravitinorealm/protocol/openid-connect/token");
+ config.put("gravitino.authenticator.oauth.signAlgorithmType", "RS256");
+
+ validator.initialize(createConfig(config));
+ String token =
Review Comment:
Could u add the comment for json data?
--
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]