@@ -77,7 +77,7 @@ use strum::{EnumDiscriminants, IntoStaticStr};
7777use crate :: {
7878 authorization:: opa:: SupersetOpaConfig ,
7979 commands:: add_cert_to_python_certifi_command,
80- config:: { self , PYTHON_IMPORTS } ,
80+ config:: { self , OPA_IMPORTS , PYTHON_IMPORTS } ,
8181 controller_commons:: { self , CONFIG_VOLUME_NAME , LOG_CONFIG_VOLUME_NAME , LOG_VOLUME_NAME } ,
8282 operations:: { graceful_shutdown:: add_graceful_shutdown_config, pdb:: add_pdbs} ,
8383 product_logging:: {
@@ -426,6 +426,7 @@ pub async fn reconcile_superset(
426426 & rolegroup,
427427 rolegroup_config,
428428 & auth_config,
429+ & superset_opa_config,
429430 & config. logging ,
430431 vector_aggregator_address. as_deref ( ) ,
431432 ) ?;
@@ -553,11 +554,12 @@ fn build_rolegroup_config_map(
553554 rolegroup : & RoleGroupRef < SupersetCluster > ,
554555 rolegroup_config : & HashMap < PropertyNameKind , BTreeMap < String , String > > ,
555556 authentication_config : & SupersetClientAuthenticationDetailsResolved ,
557+ superset_opa_config : & Option < SupersetOpaConfig > ,
556558 logging : & Logging < Container > ,
557559 vector_aggregator_address : Option < & str > ,
558560) -> Result < ConfigMap , Error > {
559561 let mut config_properties = BTreeMap :: new ( ) ;
560-
562+ let imports = PYTHON_IMPORTS ;
561563 // TODO: this is true per default for versions 3.0.0 and up.
562564 // We deactivate it here to keep existing functionality.
563565 // However this is a security issue and should be configured properly
@@ -567,6 +569,18 @@ fn build_rolegroup_config_map(
567569 config:: add_superset_config ( & mut config_properties, authentication_config)
568570 . context ( AddSupersetConfigSnafu ) ?;
569571
572+ // Adding opa configuration properties to config_properties.
573+ // This will be injected as key/value pair in superset_config.py
574+ if let Some ( opa_config) = superset_opa_config {
575+ for ( k, v) in opa_config. as_config ( ) {
576+ config_properties. insert ( k, v. unwrap_or_default ( ) ) ;
577+ }
578+ // If opa role mapping is configured, insert CustomOpaSecurityManager import
579+ for opa_import in OPA_IMPORTS {
580+ imports. to_vec ( ) . push ( & opa_import) ;
581+ }
582+ }
583+
570584 // The order here should be kept in order to preserve overrides.
571585 // No properties should be added after this extend.
572586 config_properties. extend (
@@ -590,7 +604,7 @@ fn build_rolegroup_config_map(
590604 flask_app_config_writer:: write :: < SupersetConfigOptions , _ , _ > (
591605 & mut config_file,
592606 config_properties. iter ( ) ,
593- PYTHON_IMPORTS ,
607+ imports ,
594608 )
595609 . with_context ( |_| BuildRoleGroupConfigFileSnafu {
596610 rolegroup : rolegroup. clone ( ) ,
0 commit comments