diqiu50 commented on code in PR #10730:
URL: https://github.com/apache/gravitino/pull/10730#discussion_r3085242900


##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoConnector.java:
##########
@@ -64,6 +83,39 @@ public GravitinoConnector(CatalogConnectorContext 
catalogConnectorContext) {
     this.catalogConnectorContext = catalogConnectorContext;
     this.connectorMetadata =
         new CatalogConnectorMetadata(catalogConnectorContext.getMetalake(), 
this.catalogIdentifier);
+
+    GravitinoConfig config = catalogConnectorContext.getConfig();
+    Map<String, String> clientConfig = config.getClientConfig();
+    this.forwardUser =
+        Boolean.parseBoolean(
+            
clientConfig.getOrDefault(GravitinoAuthProvider.FORWARD_SESSION_USER_KEY, 
"false"));
+    String authTypeStr = 
clientConfig.getOrDefault(GravitinoAuthProvider.AUTH_TYPE_KEY, "none");
+    this.authType = GravitinoAuthProvider.parseAuthType(authTypeStr);
+    this.oauth2CredentialKey = 
clientConfig.get(GravitinoAuthProvider.OAUTH2_TOKEN_CREDENTIAL_KEY);
+
+    if (forwardUser && authType == GravitinoAuthProvider.AuthType.OAUTH2) {
+      Preconditions.checkArgument(
+          StringUtils.isNotBlank(oauth2CredentialKey),
+          "oauth2 with forwardUser=true requires '%s' to be set",
+          GravitinoAuthProvider.OAUTH2_TOKEN_CREDENTIAL_KEY);
+    }
+
+    if (forwardUser) {
+      this.perUserSessionCache =
+          CacheBuilder.newBuilder()
+              .maximumSize(500)
+              .expireAfterAccess(1, TimeUnit.HOURS)
+              .removalListener(
+                  (RemovalNotification<String, UserSession> notification) -> {
+                    UserSession session = notification.getValue();
+                    if (session != null) {
+                      session.close();
+                    }
+                  })
+              .build();

Review Comment:
   Not a issue in the runtime



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