Skip to content

Commit

Permalink
Support ztsUrl parameter in athenz client plugin (apache#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsakai authored and merlimat committed Jan 24, 2018
1 parent a6e02bf commit da4bd4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class AuthenticationAthenz implements Authentication, EncodedAuthenticati
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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion pulsar-client-auth-athenz/src/test/resources/authParams.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
}

0 comments on commit da4bd4a

Please sign in to comment.