You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/01/24 20:05:26 UTC

[GitHub] merlimat closed pull request #1099: Support ztsUrl parameter in athenz client plugin

merlimat closed pull request #1099: Support ztsUrl parameter in athenz client plugin
URL: https://github.com/apache/incubator-pulsar/pull/1099
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenz.java b/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenz.java
index 85e9f8e58..d833e950d 100644
--- a/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenz.java
+++ b/pulsar-client-auth-athenz/src/main/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenz.java
@@ -56,6 +56,7 @@
     private static final String APPLICATION_X_PEM_FILE_BASE64 = "application/x-pem-file;base64";
 
     private transient ZTSClient ztsClient = null;
+    private String ztsUrl;
     private String tenantDomain;
     private String tenantService;
     private String providerDomain;
@@ -150,6 +151,9 @@ private void setAuthParams(Map<String, String> authParams) {
         if (authParams.containsKey("roleHeader")) {
             System.setProperty("athenz.auth.role.header", authParams.get("roleHeader"));
         }
+        if (authParams.containsKey("ztsUrl")) {
+            this.ztsUrl = authParams.get("ztsUrl");
+        }
     }
 
     @Override
@@ -164,7 +168,7 @@ private ZTSClient getZtsClient() {
         if (ztsClient == null) {
             ServiceIdentityProvider siaProvider = new SimpleServiceIdentityProvider(tenantDomain, tenantService,
                     privateKey, keyId);
-            ztsClient = new ZTSClient(null, tenantDomain, tenantService, siaProvider);
+            ztsClient = new ZTSClient(ztsUrl, tenantDomain, tenantService, siaProvider);
         }
         return ztsClient;
     }
diff --git a/pulsar-client-auth-athenz/src/test/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenzTest.java b/pulsar-client-auth-athenz/src/test/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenzTest.java
index c927262ed..36df7f135 100644
--- a/pulsar-client-auth-athenz/src/test/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenzTest.java
+++ b/pulsar-client-auth-athenz/src/test/java/org/apache/pulsar/client/impl/auth/AuthenticationAthenzTest.java
@@ -110,6 +110,14 @@ public void testGetAuthData() throws Exception {
         assertEquals(count, 1);
     }
 
+    @Test
+    public void testZtsUrl() throws Exception {
+        Field field = auth.getClass().getDeclaredField("ztsUrl");
+        field.setAccessible(true);
+        String ztsUrl = (String) field.get(auth);
+        assertEquals(ztsUrl, "https://localhost:4443/");
+    }
+
     @Test
     public void testLoadPrivateKeyBase64() throws Exception {
         try {
diff --git a/pulsar-client-auth-athenz/src/test/resources/authParams.json b/pulsar-client-auth-athenz/src/test/resources/authParams.json
index d7eb6902a..5d695b267 100644
--- a/pulsar-client-auth-athenz/src/test/resources/authParams.json
+++ b/pulsar-client-auth-athenz/src/test/resources/authParams.json
@@ -2,5 +2,6 @@
 	"tenantService": "test_service",
 	"privateKey": "./src/test/resources/tenant_private.pem",
 	"providerDomain": "test_provider",
-	"tenantDomain": "test_tenant"
+	"tenantDomain": "test_tenant",
+	"ztsUrl": "https://localhost:4443/"
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services