Skip to content

Commit

Permalink
feat(auth): view authorization (#10066)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker authored Mar 23, 2024
1 parent a0d952d commit f9e64d0
Show file tree
Hide file tree
Showing 464 changed files with 7,468 additions and 4,786 deletions.
32 changes: 32 additions & 0 deletions buildSrc/src/main/java/io/datahubproject/OpenApiEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,22 @@ private ObjectNode buildListEntityPath(Entity entity, Set<String> parameterDefin
ObjectNode postMethod = NODE_FACTORY.objectNode()
.put("summary", "Create " + upperFirst)
.put("operationId", String.format("create", upperFirst));
ArrayNode postParameters = NODE_FACTORY.arrayNode();
postMethod.set("parameters", postParameters);
postParameters.add(NODE_FACTORY.objectNode()
.put("in", "query")
.put("name", "createIfNotExists")
.put("description", "Create the aspect if it does not already exist.")
.set("schema", NODE_FACTORY.objectNode()
.put("type", "boolean")
.put("default", false)));
postParameters.add(NODE_FACTORY.objectNode()
.put("in", "query")
.put("name", "createEntityIfNotExists")
.put("description", "Create the entity ONLY if it does not already exist. Fails in case when the entity exists.")
.set("schema", NODE_FACTORY.objectNode()
.put("type", "boolean")
.put("default", false)));
postMethod.set("requestBody", NODE_FACTORY.objectNode()
.put("description", "Create " + entity.getName() + " entities.")
.put("required", true)
Expand Down Expand Up @@ -610,6 +626,22 @@ private ObjectNode buildSingleEntityAspectPath(Entity entity, String aspect) {
ObjectNode postMethod = NODE_FACTORY.objectNode()
.put("summary", String.format("Create aspect %s on %s ", aspect, upperFirstEntity))
.put("operationId", String.format("create%s", upperFirstAspect));
ArrayNode postParameters = NODE_FACTORY.arrayNode();
postMethod.set("parameters", postParameters);
postParameters.add(NODE_FACTORY.objectNode()
.put("in", "query")
.put("name", "createIfNotExists")
.put("description", "Create the aspect if it does not already exist.")
.set("schema", NODE_FACTORY.objectNode()
.put("type", "boolean")
.put("default", false)));
postParameters.add(NODE_FACTORY.objectNode()
.put("in", "query")
.put("name", "createEntityIfNotExists")
.put("description", "Create the entity if it does not already exist. Fails in case when the entity exists.")
.set("schema", NODE_FACTORY.objectNode()
.put("type", "boolean")
.put("default", false)));
postMethod.set("requestBody", NODE_FACTORY.objectNode()
.put("description", String.format("Create aspect %s on %s entity.", aspect, upperFirstEntity))
.put("required", true).set("content", NODE_FACTORY.objectNode()
Expand Down
2 changes: 1 addition & 1 deletion datahub-frontend/app/auth/AuthModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected OperationContext provideOperationContext(final Authentication systemAu
.authentication(systemAuthentication)
.build();
OperationContextConfig systemConfig = OperationContextConfig.builder()
.searchAuthorizationConfiguration(configurationProvider.getAuthorization().getSearch())
.viewAuthorizationConfiguration(configurationProvider.getAuthorization().getView())
.allowSystemAuthentication(true)
.build();

Expand Down
2 changes: 1 addition & 1 deletion datahub-graphql-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {


dependencies {
implementation project(':metadata-service:restli-client')
implementation project(':metadata-service:restli-client-api')
implementation project(':metadata-service:auth-impl')
implementation project(':metadata-service:auth-config')
implementation project(':metadata-service:configuration')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,12 @@
import com.linkedin.metadata.query.filter.SortCriterion;
import com.linkedin.metadata.query.filter.SortOrder;
import com.linkedin.metadata.recommendation.RecommendationsService;
import com.linkedin.metadata.secret.SecretService;
import com.linkedin.metadata.service.DataProductService;
import com.linkedin.metadata.service.ERModelRelationshipService;
import com.linkedin.metadata.service.FormService;
import com.linkedin.metadata.service.LineageService;
import com.linkedin.metadata.service.OwnershipTypeService;
import com.linkedin.metadata.service.QueryService;
import com.linkedin.metadata.service.RestrictedService;
import com.linkedin.metadata.service.SettingsService;
import com.linkedin.metadata.service.ViewService;
import com.linkedin.metadata.timeline.TimelineService;
Expand All @@ -368,6 +366,8 @@
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.StaticDataFetcher;
import graphql.schema.idl.RuntimeWiring;
import io.datahubproject.metadata.services.RestrictedService;
import io.datahubproject.metadata.services.SecretService;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -1023,13 +1023,14 @@ private DataFetcher getEntitiesResolver() {
return new BatchGetEntitiesResolver(
entityTypes,
(env) -> {
final QueryContext context = env.getContext();
List<String> urns = env.getArgument(URNS_FIELD_NAME);
return urns.stream()
.map(UrnUtils::getUrn)
.map(
(urn) -> {
try {
Urn entityUrn = Urn.createFromString(urn);
return UrnToEntityMapper.map(entityUrn);
return UrnToEntityMapper.map(context, urn);
} catch (Exception e) {
throw new RuntimeException("Failed to get entity", e);
}
Expand All @@ -1043,8 +1044,9 @@ private DataFetcher getEntityResolver() {
entityTypes,
(env) -> {
try {
final QueryContext context = env.getContext();
Urn urn = Urn.createFromString(env.getArgument(URN_FIELD_NAME));
return UrnToEntityMapper.map(urn);
return UrnToEntityMapper.map(context, urn);
} catch (Exception e) {
throw new RuntimeException("Failed to get entity", e);
}
Expand Down Expand Up @@ -2187,7 +2189,12 @@ private void configureDataJobResolvers(final RuntimeWiring.Builder builder) {
"dataFlow",
new LoadableTypeResolver<>(
dataFlowType,
(env) -> ((DataJob) env.getSource()).getDataFlow().getUrn()))
(env) -> {
final DataJob dataJob = env.getSource();
return dataJob.getDataFlow() != null
? dataJob.getDataFlow().getUrn()
: null;
}))
.dataFetcher(
"dataPlatformInstance",
new LoadableTypeResolver<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
import com.linkedin.metadata.graph.SiblingGraphService;
import com.linkedin.metadata.models.registry.EntityRegistry;
import com.linkedin.metadata.recommendation.RecommendationsService;
import com.linkedin.metadata.secret.SecretService;
import com.linkedin.metadata.service.DataProductService;
import com.linkedin.metadata.service.ERModelRelationshipService;
import com.linkedin.metadata.service.FormService;
import com.linkedin.metadata.service.LineageService;
import com.linkedin.metadata.service.OwnershipTypeService;
import com.linkedin.metadata.service.QueryService;
import com.linkedin.metadata.service.RestrictedService;
import com.linkedin.metadata.service.SettingsService;
import com.linkedin.metadata.service.ViewService;
import com.linkedin.metadata.timeline.TimelineService;
import com.linkedin.metadata.timeseries.TimeseriesAspectService;
import com.linkedin.metadata.version.GitVersion;
import com.linkedin.usage.UsageClient;
import io.datahubproject.metadata.services.RestrictedService;
import io.datahubproject.metadata.services.SecretService;
import lombok.Data;

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ private List<BarSegment> extractBarSegmentsFromAggregations(
.collect(Collectors.toList());
}

public Row buildRow(String groupByValue, Function<String, Cell> groupByValueToCell, int count) {
public static Row buildRow(
String groupByValue, Function<String, Cell> groupByValueToCell, int count) {
List<String> values = ImmutableList.of(groupByValue, String.valueOf(count));
List<Cell> cells =
ImmutableList.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static Cell buildCellWithEntityLandingPage(String urn) {
Cell result = new Cell();
result.setValue(urn);
try {
Entity entity = UrnToEntityMapper.map(Urn.createFromString(urn));
Entity entity = UrnToEntityMapper.map(null, Urn.createFromString(urn));
result.setEntity(entity);
result.setLinkParams(
LinkParams.builder()
Expand Down
Loading

0 comments on commit f9e64d0

Please sign in to comment.