mebegu commented on PR #21180:
URL: https://github.com/apache/superset/pull/21180#issuecomment-1231480031
Thanks for quick response. Honestly, I also think it can be improved. I was
spending time on how can it be added, and I have some pseudo implementation. My
idea was to take the key path and the passphrase in the db engine extra
parameters.
But I have not contributed superset before, so, there is an overhead time
for me to understand how to setup the local development environment, and
testing etc.
```
<new function in superset/db_engine_specs/snowflake.py>
....
@staticmethod
def get_extra_params(database: "Database") -> Dict[str, Any]:
"""
Loads private key indicated in the `connect_args`.
:param database: database instance from which to extract extras
:raises SupersetException: If database extra json payload is
unparseable
"""
try:
extra = json.loads(database.extra or "{}")
except json.JSONDecodeError as ex:
raise SupersetException("Unable to parse database extras") from
ex
engine_params = extra.get("engine_params", {})
connect_args = engine_params.get("connect_args", {})
if not connect_args.get("private_key"):
return
with open(connect_args.get("private_key"), "rb") as key:
p_key= serialization.load_pem_private_key(
key.read(),
password=connect_args.get("private_key_passphrase").encode(),
backend=default_backend()
)
pkb = p_key.private_bytes(
encoding=serialization.Encoding.DER,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption())
connect_args["private_key"] = pkb
if connect_args.get("private_key_passphrase"):
del connect_args["private_key_passphrase"]
engine_params["connect_args"] = connect_args
extra["engine_params"] = engine_params
return extra
....
```
--
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]