-
Notifications
You must be signed in to change notification settings - Fork 332
[Catalog Federation] Add feature flag to disallow setting sub-RBAC for federated catalog at catalog level #2696
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import jakarta.ws.rs.core.SecurityContext; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
| import org.apache.iceberg.catalog.Namespace; | ||
| import org.apache.iceberg.catalog.TableIdentifier; | ||
| import org.apache.iceberg.rest.responses.ErrorResponse; | ||
|
|
@@ -124,6 +125,7 @@ public Response createCatalog( | |
| Catalog catalog = request.getCatalog(); | ||
| validateStorageConfig(catalog.getStorageConfigInfo()); | ||
| validateExternalCatalog(catalog); | ||
| validateCatalogProperties(catalog.getProperties()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need this validation when updating the catalog entity as well
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is added in line 249 https://github.com/apache/polaris/pull/2696/files#diff-da3b7ab11bab566a4c161978634dda3e2d194a81827d36edaa4fb8ee23691348R249. I also added a test to cover that case
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really want to control whether or not you can set the property? Or do we want to control whether or not RBAC settings can be applied / will get respected? (Let In other words, is it the intended use case that I can start with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great question! Here is some more context: #2688 (comment), TLDR, we want to support configuring IMHO, more limitation should be imposed on
I do not think this is the intended use-case. IMHO,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're right that there's a more general gap in the flag framework and that it might be nice to be able to, for example, configure a catalog such that no catalog overrides apply to it or can be set on it. What @dimas-b wrote in your linked comment makes sense to me. But what's being done here is specific to one setting... creating a second flag for every flag where we want this level of control seems like a bad precedent to set. Further, in this context, the message used in the implementation (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've revised the error message to contain info that
Yeah, I agree this does not scale up in the long term. But I think at this time, we probably need to identify more use-cases to make a comprehensive infra enhancement for this type of utility. How about adding a general flag So that people could register feature keys that they want to block catalog overrides in the future?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like that could work, though I could imagine wanting to set it at a catalog level as well.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 to following up on this and making config overrides and allow/block checks more general. |
||
| Catalog newCatalog = CatalogEntity.of(adminService.createCatalog(request)).asCatalog(); | ||
| LOGGER.info("Created new catalog {}", newCatalog); | ||
| return Response.status(Response.Status.CREATED).entity(newCatalog).build(); | ||
|
|
@@ -176,6 +178,23 @@ private void validateExternalCatalog(Catalog catalog) { | |
| } | ||
| } | ||
|
|
||
| private void validateCatalogProperties(Map<String, String> catalogProperties) { | ||
| if (catalogProperties != null) { | ||
| if (!realmConfig.getConfig( | ||
| FeatureConfiguration.ALLOW_SETTING_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS) | ||
| && catalogProperties.containsKey( | ||
| FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS | ||
| .catalogConfig())) { | ||
|
|
||
| throw new IllegalArgumentException( | ||
| String.format( | ||
| "Explicitly setting %s is not allowed because %s is set to false.", | ||
| FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS.catalogConfig(), | ||
| FeatureConfiguration.ALLOW_SETTING_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS.key())); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private void validateConnectionConfigInfo(ConnectionConfigInfo connectionConfigInfo) { | ||
|
|
||
| String connectionType = connectionConfigInfo.getConnectionType().name(); | ||
|
|
@@ -227,6 +246,7 @@ public Response updateCatalog( | |
| if (updateRequest.getStorageConfigInfo() != null) { | ||
| validateStorageConfig(updateRequest.getStorageConfigInfo()); | ||
| } | ||
| validateCatalogProperties(updateRequest.getProperties()); | ||
| return Response.ok(adminService.updateCatalog(catalogName, updateRequest).asCatalog()).build(); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.