Skip to content

Commit 50050bc

Browse files
committed
Better interfering of package path
1 parent a4dda2a commit 50050bc

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

rust/crd/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub enum SupersetConfigOptions {
8787
AuthLdapTlsKeyfile,
8888
AuthLdapTlsCacertfile,
8989
CustomSecurityManager,
90-
StackableOpaEndpoint,
90+
StackableOpaBaseUrl,
9191
StackableOpaPackage,
9292
StackableOpaRule,
9393
}
@@ -139,7 +139,7 @@ impl FlaskAppConfigOptions for SupersetConfigOptions {
139139
SupersetConfigOptions::AuthLdapTlsKeyfile => PythonType::StringLiteral,
140140
SupersetConfigOptions::AuthLdapTlsCacertfile => PythonType::StringLiteral,
141141
SupersetConfigOptions::CustomSecurityManager => PythonType::Expression,
142-
SupersetConfigOptions::StackableOpaEndpoint => PythonType::StringLiteral,
142+
SupersetConfigOptions::StackableOpaBaseUrl => PythonType::StringLiteral,
143143
SupersetConfigOptions::StackableOpaPackage => PythonType::StringLiteral,
144144
SupersetConfigOptions::StackableOpaRule => PythonType::Expression,
145145
// TODO: Set new options for OpaSecurityManager like:

rust/operator-binary/src/authorization/opa.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use stackable_operator::{
77
use stackable_superset_crd::SupersetCluster;
88

99
pub 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

Comments
 (0)