Skip to content
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

FIX #17042 - Allow non admin/bot to read profiler global config #18292

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import org.openmetadata.schema.type.csv.CsvFile;
import org.openmetadata.schema.type.csv.CsvHeader;
import org.openmetadata.schema.type.csv.CsvImportResult;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity;
import org.openmetadata.service.TypeRegistry;
import org.openmetadata.service.jdbi3.EntityRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
import org.openmetadata.schema.type.api.BulkOperationResult;
import org.openmetadata.schema.type.api.BulkResponse;
import org.openmetadata.schema.type.csv.CsvImportResult;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.schema.utils.EntityInterfaceUtil;
import org.openmetadata.service.Entity;
import org.openmetadata.service.OpenMetadataApplicationConfig;
Expand Down Expand Up @@ -1495,15 +1495,15 @@ private String getFormattedDateTimeField(
private void validateTableType(JsonNode fieldValue, String propertyConfig, String fieldName) {
TableConfig tableConfig =
JsonUtils.convertValue(JsonUtils.readTree(propertyConfig), TableConfig.class);
org.openmetadata.schema.type.customproperties.Table tableValue =
org.openmetadata.schema.type.customProperties.Table tableValue =
JsonUtils.convertValue(
JsonUtils.readTree(String.valueOf(fieldValue)),
org.openmetadata.schema.type.customproperties.Table.class);
org.openmetadata.schema.type.customProperties.Table.class);
Set<String> configColumns = tableConfig.getColumns();

try {
JsonUtils.validateJsonSchema(
tableValue, org.openmetadata.schema.type.customproperties.Table.class);
tableValue, org.openmetadata.schema.type.customProperties.Table.class);

Set<String> fieldColumns = new HashSet<>();
fieldValue.get("columns").forEach(column -> fieldColumns.add(column.asText()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.Relationship;
import org.openmetadata.schema.type.customproperties.EnumConfig;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.EnumConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity;
import org.openmetadata.service.TypeRegistry;
import org.openmetadata.service.exception.CatalogExceptionMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ protected List<MetadataOperation> getEntitySpecificOperations() {
MetadataOperation.VIEW_DATA_PROFILE,
MetadataOperation.VIEW_SAMPLE_DATA,
MetadataOperation.VIEW_USAGE,
MetadataOperation.VIEW_PROFILER_GLOBAL_CONFIGURATION,
MetadataOperation.EDIT_TESTS,
MetadataOperation.EDIT_QUERIES,
MetadataOperation.EDIT_DATA_PROFILE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.openmetadata.schema.settings.SettingsType;
import org.openmetadata.schema.system.ValidationResponse;
import org.openmetadata.schema.type.Include;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.util.EntitiesCount;
import org.openmetadata.schema.util.ServicesCount;
import org.openmetadata.sdk.PipelineServiceClientInterface;
Expand All @@ -46,6 +47,8 @@
import org.openmetadata.service.resources.Collection;
import org.openmetadata.service.security.Authorizer;
import org.openmetadata.service.security.JwtFilter;
import org.openmetadata.service.security.policyevaluator.OperationContext;
import org.openmetadata.service.security.policyevaluator.ResourceContext;
import org.openmetadata.service.util.ResultList;
import org.openmetadata.service.util.email.EmailUtil;

Expand Down Expand Up @@ -145,8 +148,18 @@ public Settings getSettingByName(
schema = @Schema(implementation = Settings.class)))
})
public Settings getProfilerConfigurationSetting(
@Context UriInfo uriInfo, @Context SecurityContext securityContext) {
authorizer.authorizeAdminOrBot(securityContext);
@Context UriInfo uriInfo,
@Context SecurityContext securityContext,
@Parameter(
description = "Entity type for which to get the global profiler configuration",
schema = @Schema(type = "string"))
@QueryParam("entityType")
@DefaultValue("table")
String entityType) {
ResourceContext resourceContext = new ResourceContext(entityType);
OperationContext operationContext =
new OperationContext(entityType, MetadataOperation.VIEW_PROFILER_GLOBAL_CONFIGURATION);
authorizer.authorize(securityContext, operationContext, resourceContext);
return systemRepository.getConfigWithKey(SettingsType.PROFILER_CONFIGURATION.value());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
import org.openmetadata.schema.type.TagLabel.TagSource;
import org.openmetadata.schema.type.TaskStatus;
import org.openmetadata.schema.type.csv.CsvImportResult;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity;
import org.openmetadata.service.exception.CatalogExceptionMessage;
import org.openmetadata.service.jdbi3.EntityRepository.EntityUpdater;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import org.openmetadata.schema.type.ChangeDescription;
import org.openmetadata.schema.type.CustomPropertyConfig;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.customproperties.EnumConfig;
import org.openmetadata.schema.type.customproperties.TableConfig;
import org.openmetadata.schema.type.customProperties.EnumConfig;
import org.openmetadata.schema.type.customProperties.TableConfig;
import org.openmetadata.service.Entity;
import org.openmetadata.service.resources.EntityResourceTest;
import org.openmetadata.service.resources.types.TypeResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"ViewTests",
"ViewQueries",
"ViewDataProfile",
"ViewProfilerGlobalConfiguration",
"ViewSampleData",
"ViewTestCaseFailedRowsSample",
"EditAll",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"title": "Table",
"description": "A table-type custom property having rows and columns where all column data types are strings.",
"type": "object",
"javaType": "org.openmetadata.schema.type.customproperties.Table",
"javaType": "org.openmetadata.schema.type.customProperties.Table",
"properties": {
"columns": {
"type": "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "EnumConfig",
"type": "object",
"javaType": "org.openmetadata.schema.type.customproperties.EnumConfig",
"javaType": "org.openmetadata.schema.type.customProperties.EnumConfig",
TeddyCr marked this conversation as resolved.
Show resolved Hide resolved
"description": "Applies to Enum type, this config is used to define list of enum values",
"properties": {
"multiSelect": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title": "TableConfig",
"description": "Custom property configuration for table-type property where all column data types are strings.",
"type": "object",
"javaType": "org.openmetadata.schema.type.customproperties.TableConfig",
"javaType": "org.openmetadata.schema.type.customProperties.TableConfig",
"properties": {
"columns": {
"type": "array",
Expand Down
Loading