aminghadersohi commented on code in PR #44705:
URL: https://github.com/apache/superset/pull/44705#discussion_r4113535019


##########
superset/db_engine_specs/databricks.py:
##########
@@ -446,7 +484,31 @@ def update_params_from_encrypted_extra(
             logger.error(ex, exc_info=True)
             raise
         encrypted_extra.pop("oauth2_client_info", None)
+        secure_connect_args = encrypted_extra.pop("connect_args", None)
         params.update(encrypted_extra)
+        if secure_connect_args is not None and not isinstance(
+            secure_connect_args, dict
+        ):
+            params["connect_args"] = secure_connect_args
+            return
+        if secure_connect_args is None and "connect_args" not in params:
+            return
+
+        secure_connect_args = secure_connect_args or {}
+        connect_args = dict(params.get("connect_args") or {})
+        if database.impersonate_user:
+            connect_args = {
+                key: value
+                for key, value in connect_args.items()
+                if key == "access_token"
+                or key not in DATABRICKS_SHARED_CREDENTIAL_CONNECT_ARGS
+            }
+            secure_connect_args = {
+                key: value
+                for key, value in secure_connect_args.items()
+                if key not in DATABRICKS_SHARED_CREDENTIAL_CONNECT_ARGS

Review Comment:
   The user's credential is still there. `impersonate_user` runs before 
`update_params_from_encrypted_extra` in `Database._get_sqla_engine` and sets 
the URL password to the user's token, and the Databricks dialect uses 
`url.password` as `access_token` (`connect_args` only override it). Dropping 
the shared token is intended, so it can't replace the user's. Added 
`test_impersonation_with_shared_token_only_in_secure_extra` in 5e30ad158b, 
which runs both calls in that order.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to