From 90e76fe650c4f60412a9db72e2ba6ba4c0c1591c Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Wed, 17 Aug 2022 11:56:53 +0100 Subject: [PATCH] docs: improve encrypted field adapter docs --- superset/config.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/superset/config.py b/superset/config.py index 2336f61212ee1..cc566fe6ee132 100644 --- a/superset/config.py +++ b/superset/config.py @@ -201,8 +201,31 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]: # to the DB. # # Note: the default impl leverages SqlAlchemyUtils' EncryptedType, which defaults -# to AES-128 under the covers using the app's SECRET_KEY as key material. +# to AesEngine that uses AES-128 under the covers using the app's SECRET_KEY +# as key material. Do note that AesEngine allows for queryability over the +# encrypted fields. # +# To change the default engine you need to define your own adapter: +# +# e.g.: +# +# class AesGcmEncryptedAdapter( # pylint: disable=too-few-public-methods +# AbstractEncryptedFieldAdapter +# ): +# def create( +# self, +# app_config: Optional[Dict[str, Any]], +# *args: List[Any], +# **kwargs: Optional[Dict[str, Any]], +# ) -> TypeDecorator: +# if app_config: +# return EncryptedType( +# *args, app_config["SECRET_KEY"], engine=AesGcmEngine, **kwargs +# ) +# raise Exception("Missing app_config kwarg") +# +# +# SQLALCHEMY_ENCRYPTED_FIELD_TYPE_ADAPTER = AesGcmEncryptedAdapter SQLALCHEMY_ENCRYPTED_FIELD_TYPE_ADAPTER = ( # pylint: disable=invalid-name SQLAlchemyUtilsAdapter )