diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java index a149f2c541..1cd91e38a3 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/GmsGraphQLEngine.java @@ -1,5 +1,6 @@ package com.linkedin.datahub.graphql; +import com.datahub.authentication.AuthenticationConfiguration; import com.datahub.authentication.token.TokenService; import com.datahub.authorization.AuthorizationConfiguration; import com.google.common.collect.ImmutableList; @@ -221,6 +222,7 @@ public class GmsGraphQLEngine { private final TimeseriesAspectService timeseriesAspectService; private final IngestionConfiguration ingestionConfiguration; + private final AuthenticationConfiguration authenticationConfiguration; private final AuthorizationConfiguration authorizationConfiguration; private final VisualConfiguration visualConfiguration; @@ -288,6 +290,7 @@ public class GmsGraphQLEngine { null, null, null, + null, false, null); } @@ -304,6 +307,7 @@ public class GmsGraphQLEngine { final EntityRegistry entityRegistry, final SecretService secretService, final IngestionConfiguration ingestionConfiguration, + final AuthenticationConfiguration authenticationConfiguration, final AuthorizationConfiguration authorizationConfiguration, final GitVersion gitVersion, final boolean supportsImpactAnalysis, @@ -325,6 +329,7 @@ public class GmsGraphQLEngine { this.timeseriesAspectService = timeseriesAspectService; this.ingestionConfiguration = Objects.requireNonNull(ingestionConfiguration); + this.authenticationConfiguration = Objects.requireNonNull(authenticationConfiguration); this.authorizationConfiguration = Objects.requireNonNull(authorizationConfiguration); this.visualConfiguration = visualConfiguration; @@ -562,6 +567,7 @@ public class GmsGraphQLEngine { .dataFetcher("appConfig", new AppConfigResolver(gitVersion, analyticsService != null, this.ingestionConfiguration, + this.authenticationConfiguration, this.authorizationConfiguration, supportsImpactAnalysis, this.visualConfiguration)) .dataFetcher("me", new AuthenticatedResolver<>( diff --git a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/config/AppConfigResolver.java b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/config/AppConfigResolver.java index d692ddf10e..8fda3c198c 100644 --- a/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/config/AppConfigResolver.java +++ b/datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/config/AppConfigResolver.java @@ -1,9 +1,11 @@ package com.linkedin.datahub.graphql.resolvers.config; +import com.datahub.authentication.AuthenticationConfiguration; import com.datahub.authorization.AuthorizationConfiguration; import com.linkedin.datahub.graphql.QueryContext; import com.linkedin.datahub.graphql.generated.AnalyticsConfig; import com.linkedin.datahub.graphql.generated.AppConfig; +import com.linkedin.datahub.graphql.generated.AuthConfig; import com.linkedin.datahub.graphql.generated.EntityType; import com.linkedin.datahub.graphql.generated.IdentityManagementConfig; import com.linkedin.datahub.graphql.generated.LineageConfig; @@ -28,6 +30,7 @@ public class AppConfigResolver implements DataFetcher { const [showModal, setShowModal] = useState(false); const [selectedTokenDuration, setSelectedTokenDuration] = useState(ACCESS_TOKEN_DURATIONS[0].duration); const authenticatedUser = useGetAuthenticatedUser(); - const canGeneratePersonalAccessTokens = authenticatedUser?.platformPrivileges.generatePersonalAccessTokens; + const isTokenAuthEnabled = useAppConfigQuery().data?.appConfig?.authConfig?.tokenAuthEnabled; + const canGeneratePersonalAccessTokens = + isTokenAuthEnabled && authenticatedUser?.platformPrivileges.generatePersonalAccessTokens; const currentUserUrn = authenticatedUser?.corpUser.urn; const [getAccessToken, { data, error }] = useGetAccessTokenLazyQuery({ @@ -94,6 +108,18 @@ export const AccessTokens = () => { Manage Access Tokens for use with DataHub APIs. + {isTokenAuthEnabled === false && ( + + + Token based authentication is currently disabled. Contact your DataHub administrator to + enable this feature. + + } + /> + )} Personal Access Tokens Personal Access Tokens allow you to make programmatic requests to DataHub's APIs. They inherit your diff --git a/datahub-web-react/src/appConfigContext.tsx b/datahub-web-react/src/appConfigContext.tsx index 7e294dd38c..0c0b3bde62 100644 --- a/datahub-web-react/src/appConfigContext.tsx +++ b/datahub-web-react/src/appConfigContext.tsx @@ -22,6 +22,9 @@ export const DEFAULT_APP_CONFIG = { visualConfig: { logoUrl: undefined, }, + authConfig: { + tokenAuthEnabled: false, + }, }; export const AppConfigContext = React.createContext<{ diff --git a/datahub-web-react/src/graphql/app.graphql b/datahub-web-react/src/graphql/app.graphql index b36f163cf6..40f7cba9d6 100644 --- a/datahub-web-react/src/graphql/app.graphql +++ b/datahub-web-react/src/graphql/app.graphql @@ -22,6 +22,9 @@ query appConfig { analyticsConfig { enabled } + authConfig { + tokenAuthEnabled + } identityManagementConfig { enabled } diff --git a/metadata-service/factories/src/main/java/com/linkedin/gms/factory/graphql/GraphQLEngineFactory.java b/metadata-service/factories/src/main/java/com/linkedin/gms/factory/graphql/GraphQLEngineFactory.java index 6e67c3e8a5..6538f4af21 100644 --- a/metadata-service/factories/src/main/java/com/linkedin/gms/factory/graphql/GraphQLEngineFactory.java +++ b/metadata-service/factories/src/main/java/com/linkedin/gms/factory/graphql/GraphQLEngineFactory.java @@ -116,6 +116,7 @@ public class GraphQLEngineFactory { _entityRegistry, _secretService, _configProvider.getIngestion(), + _configProvider.getAuthentication(), _configProvider.getAuthorization(), _gitVersion, _graphService.supportsMultiHop(), @@ -134,6 +135,7 @@ public class GraphQLEngineFactory { _entityRegistry, _secretService, _configProvider.getIngestion(), + _configProvider.getAuthentication(), _configProvider.getAuthorization(), _gitVersion, _graphService.supportsMultiHop(),