@@ -7,7 +7,7 @@ use stackable_operator::{
77use stackable_superset_crd:: SupersetCluster ;
88
99pub struct SupersetOpaConfig {
10- opa_endpoint : String ,
10+ opa_base_url : String ,
1111 opa_package : Option < String > ,
1212}
1313
@@ -20,18 +20,20 @@ impl SupersetOpaConfig {
2020 // Get opa_base_url for later use in CustomOpaSecurityManager
2121 let opa_endpoint = opa_config
2222 . full_document_url_from_config_map ( client, superset, None , OpaApiVersion :: V1 )
23- . await ?
24- // Not pretty.
25- // Need to remove the resource name. Appended by default.
26- // TODO: Decide where to handle this
27- // could be better in security manager!
28- . replace ( "/v1/data/superset" , "" ) ;
23+ . await ?;
2924
30- let opa_package = opa_config. package . clone ( ) ;
25+ // striping package path from base url. Needed by CustomOpaSecurityManager. TODO: <Path/to/manager.py>
26+ let opa_base_url = match opa_config. package . clone ( ) {
27+ Some ( opa_package_name) => {
28+ let opa_path = format ! ( "/v1/data/{opa_package_name}" ) ;
29+ opa_endpoint. replace ( & opa_path, "" )
30+ }
31+ None => opa_endpoint. replace ( "/v1/data/" , "" ) ,
32+ } ;
3133
3234 Ok ( SupersetOpaConfig {
33- opa_endpoint ,
34- opa_package,
35+ opa_base_url ,
36+ opa_package : opa_config . package . clone ( ) ,
3537 } )
3638 }
3739
@@ -53,14 +55,14 @@ impl SupersetOpaConfig {
5355 Some ( "os.getenv('AUTH_USER_REGISTRATION_ROLE', 'Public')" . to_string ( ) ) ,
5456 ) ,
5557 // There is no proper way to interfere this without changing e.g. CRD's.
56- // Thus, we go for an default and make it accessible through envoverrides .
58+ // Thus, we go for an default and make it accessible through envOverrides .
5759 (
5860 "STACKABLE_OPA_RULE" . to_string ( ) ,
5961 Some ( "os.getenv('STACKABLE_OPA_RULE', 'user_roles')" . to_string ( ) ) ,
6062 ) ,
6163 (
62- "STACKABLE_OPA_ENDPOINT " . to_string ( ) ,
63- Some ( self . opa_endpoint . clone ( ) ) ,
64+ "STACKABLE_OPA_BASE_URL " . to_string ( ) ,
65+ Some ( self . opa_base_url . clone ( ) ) ,
6466 ) ,
6567 (
6668 "STACKABLE_OPA_PACKAGE" . to_string ( ) ,
0 commit comments