You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/04/04 06:04:15 UTC

[GitHub] [pulsar] kkoderok commented on a diff in pull request #13339: [Issue 10816][Proxy] Refresh client auth token

kkoderok commented on code in PR #13339:
URL: https://github.com/apache/pulsar/pull/13339#discussion_r841390236


##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java:
##########
@@ -439,11 +451,65 @@ ClientConfigurationData createClientConfiguration() throws UnsupportedAuthentica
     private PulsarClientImpl createClient(final ClientConfigurationData clientConf, final AuthData clientAuthData,
             final String clientAuthMethod, final int protocolVersion) throws PulsarClientException {
         this.connectionPool = new ProxyConnectionPool(clientConf, service.getWorkerGroup(),
-                () -> new ProxyClientCnx(clientConf, service.getWorkerGroup(), clientAuthRole, clientAuthData,
-                        clientAuthMethod, protocolVersion));
+            () -> new ProxyClientCnx(clientConf, service.getWorkerGroup(), clientAuthRole,
+                this::getOrRefreshClientAuthData, clientAuthMethod, protocolVersion,
+                service.getConfiguration().isForwardAuthorizationCredentials()));
         return new PulsarClientImpl(clientConf, service.getWorkerGroup(), connectionPool, service.getTimer());
     }
 
+    private void updateClientAuthData(AuthData clientData) {
+        this.clientAuthData = clientData;
+        authFutureList.getAndSet(Collections.emptyList())
+            .forEach(future -> future.complete(clientData));
+    }
+
+    private CompletableFuture<AuthData> getOrRefreshClientAuthData() {

Review Comment:
   When client auth data expired and proxy configured with forward authentication data, then this method requests a new token. This method is thread safe, because one ProxyConnection has multiple ProxyClientCnx, and potentially at same time, they request
   auth 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: dev-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org