-
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Support OPA role mapping #582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 42 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
ba1c7ab
First skeleton of opa integration
Maleware d502af3
WIP implementation opa-role-mapping
Maleware b3c3d0f
Add SecurityManager dynamically
Maleware 25f143a
Better OPA_IMPORT
Maleware a125456
Security manager own file in Docker-Images. Fixing python expression
Maleware 1e17009
making clippy happy for now
Maleware e237a7a
Updating some approaches
Maleware 8614577
Adding more rules, more sophisticated handling of stuff
Maleware a4dda2a
Defaults are working
Maleware 50050bc
Better interfering of package path
Maleware cc35802
Happy Clippy
Maleware 9ae3dca
update OpaSupersetSecurityManager import path
labrenbe 40c5cd1
import new opa_authorizer module
labrenbe a92dac5
Removing some ToDo's. Better comments
Maleware a5c22ec
Adding OpaRolesCache with 10 minutes default
Maleware 535e2ea
pre commit becomes happy
Maleware 1a6bcbf
Merge branch 'main' into feature/opa-role-mapping
Maleware c215250
create opa test basics
labrenbe 06515ab
rename test directory
labrenbe a53c784
fix test-definition
labrenbe 5ea83bd
fix typo
labrenbe 748030f
fix opa test scaffold
labrenbe c77f0ba
Adding rule_name to be defined by the user. defaults to empty string
Maleware e19a39c
Adding default to rule_name
Maleware 5e0c32e
StackableOpaRule to string as we interfere from CRDs
Maleware 33d3f3a
Adding ttl to crds. Default to 10.
Maleware bd97146
cache_ttl now Duration type. Converted to seconds in superset_config.py
Maleware 1d27837
wip: integration tests
labrenbe 4419843
integrate feedback
labrenbe 6a8f8e7
create basic user role test
labrenbe 203e390
First documentation draft
Maleware cd6a64c
Adding reference to opa user-info-fetcher
Maleware b217dd4
Merge branch 'main' into feature/opa-role-mapping
Maleware 49da77a
Updating changelog
Maleware f76ba93
fix rego and first check in integration test
labrenbe deddd5a
fix formatting issues
labrenbe 1093fa2
Making rust fmt happy
Maleware 75f19d2
lint with ruff formatter
labrenbe f1de6ba
use TtlCache from operator-rs
labrenbe a09d2a5
Regenerate charts
Maleware 05b8b0b
Merge branch 'main' into feature/opa-role-mapping
Maleware 98a7a55
Making pre-commit happy
Maleware a7f1bb1
apply typos and formatting corrections
Maleware 48c8a52
update chart
labrenbe 8ed6194
adress feedback in PR and rename envs
labrenbe 23f08e5
Merge remote-tracking branch 'origin/main' into feature/opa-role-mapping
labrenbe 5b006b8
Merge remote-tracking branch 'origin/main' into feature/opa-role-mapping
labrenbe 4b23391
fix changelog
labrenbe a12c05d
main merge
razvan 161ac74
Update opa tests.
razvan ec8c3d5
Merge branch 'main' into feature/opa-role-mapping
razvan ef001e7
support custom image for opa tests
razvan ff0ee46
create and assign new role via API
razvan c0f2368
fix typos
razvan d02e7bb
add some comments
razvan 472817f
opa kuttl test is green (again)
razvan 5885684
silence most of Pyright errors and warnings
razvan 434232f
Update rust/crd/src/lib.rs
razvan 93819b5
Renaming fields and structs
razvan 1438a24
format code
razvan 5268e8e
make field required
razvan 95c22b1
pass on opa endpoint instead of base url to the authorizer
razvan 26e95f3
Update docs/modules/superset/pages/usage-guide/security.adoc
razvan 52a2214
Update docs/modules/superset/pages/usage-guide/security.adoc
razvan fdd8c6d
Update docs/modules/superset/pages/usage-guide/security.adoc
razvan 80136fe
Update docs/modules/superset/pages/usage-guide/security.adoc
razvan d69ff8b
update security.adoc
razvan 0d078b1
move constant
razvan bcd774f
rename opa dimension
razvan 1051900
revert changes to smoke test
razvan 63ac8cc
Update tests/templates/kuttl/opa/40_superset.yaml.j2
razvan 499d02c
remove unused image field
razvan f9f8c7e
add serde cache defaults
razvan bc9acf3
Update rust/operator-binary/src/authorization/opa.rs
razvan 16eb8e5
Update rust/operator-binary/src/superset_controller.rs
razvan 9b7d6c9
add missing EOF
razvan 26f08f0
add vector aggregator config map
razvan 416389b
add openshift ns patch
razvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod opa; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
use stackable_operator::time::Duration; | ||
use std::collections::BTreeMap; | ||
|
||
use stackable_operator::{client::Client, commons::opa::OpaApiVersion}; | ||
use stackable_superset_crd::{SupersetCluster, SupersetOpaConfig}; | ||
|
||
pub struct SupersetOpaConfigResolved { | ||
opa_base_url: String, | ||
opa_package: Option<String>, | ||
cache_max_entries: u32, | ||
cache_ttl: Duration, | ||
} | ||
|
||
impl SupersetOpaConfigResolved { | ||
pub async fn from_opa_config( | ||
client: &Client, | ||
superset: &SupersetCluster, | ||
opa_config: &SupersetOpaConfig, | ||
) -> Result<Self, stackable_operator::commons::opa::Error> { | ||
// Get opa_base_url for later use in CustomOpaSecurityManager | ||
razvan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
let opa_endpoint = opa_config | ||
.opa | ||
.full_document_url_from_config_map(client, superset, None, OpaApiVersion::V1) | ||
.await?; | ||
|
||
// striping package path from base url. Needed by CustomOpaSecurityManager. | ||
let opa_base_url = match opa_config.opa.package.clone() { | ||
Some(opa_package_name) => { | ||
let opa_path = format!("/v1/data/{opa_package_name}"); | ||
opa_endpoint.replace(&opa_path, "") | ||
} | ||
None => opa_endpoint.replace("/v1/data/", ""), | ||
}; | ||
sbernauer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Ok(SupersetOpaConfigResolved { | ||
opa_base_url, | ||
opa_package: opa_config.opa.package.to_owned(), | ||
cache_max_entries: opa_config.cache.max_entries.to_owned(), | ||
cache_ttl: opa_config.cache.entry_time_to_live.to_owned(), | ||
}) | ||
} | ||
|
||
// Adding necessary configurations. Imports are solved in config.rs | ||
pub fn as_config(&self) -> BTreeMap<String, Option<String>> { | ||
BTreeMap::from([ | ||
( | ||
"CUSTOM_SECURITY_MANAGER".to_string(), | ||
Some("OpaSupersetSecurityManager".to_string()), | ||
), | ||
( | ||
"STACKABLE_OPA_RULE".to_string(), | ||
Some("user_roles".to_string()), | ||
), | ||
( | ||
"STACKABLE_OPA_BASE_URL".to_string(), | ||
Some(self.opa_base_url.to_owned()), | ||
), | ||
( | ||
"STACKABLE_OPA_PACKAGE".to_string(), | ||
self.opa_package.to_owned(), | ||
), | ||
( | ||
"STACKABLE_OPA_CACHE_MAX_ENTRIES".to_string(), | ||
Some(self.cache_max_entries.to_string()), | ||
), | ||
( | ||
"STACKABLE_OPA_CACHE_ENTRY_TTL".to_string(), | ||
Some(self.cache_ttl.as_secs().to_string()), | ||
), | ||
]) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.