From d62220ee1574343be68df53cb28c18b6cb756d10 Mon Sep 17 00:00:00 2001 From: Esko Suomi Date: Thu, 6 Jun 2024 12:40:27 +0300 Subject: [PATCH 1/2] replace old style role checks with delegation to userContextService --- .../java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java | 2 +- .../java/no/entur/uttu/graphql/fetchers/ProviderUpdater.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java b/src/main/java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java index 2545fecd..72859509 100644 --- a/src/main/java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java +++ b/src/main/java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java @@ -37,7 +37,7 @@ public class CodespaceUpdater implements DataFetcher { private CodespaceRepository repository; @Override - @PreAuthorize("hasRole('" + ROLE_ROUTE_DATA_ADMIN + "')") + @PreAuthorize("@userContextService.isAdmin()") public Codespace get(DataFetchingEnvironment env) { ArgumentWrapper input = new ArgumentWrapper(env.getArgument(FIELD_INPUT)); String codespaceXmlns = input.get(FIELD_XMLNS); diff --git a/src/main/java/no/entur/uttu/graphql/fetchers/ProviderUpdater.java b/src/main/java/no/entur/uttu/graphql/fetchers/ProviderUpdater.java index bc53720e..2c172aeb 100644 --- a/src/main/java/no/entur/uttu/graphql/fetchers/ProviderUpdater.java +++ b/src/main/java/no/entur/uttu/graphql/fetchers/ProviderUpdater.java @@ -17,10 +17,8 @@ import static no.entur.uttu.graphql.GraphQLNames.FIELD_CODE; import static no.entur.uttu.graphql.GraphQLNames.FIELD_CODE_SPACE_XMLNS; -import static no.entur.uttu.graphql.GraphQLNames.FIELD_ID; import static no.entur.uttu.graphql.GraphQLNames.FIELD_INPUT; import static no.entur.uttu.graphql.GraphQLNames.FIELD_NAME; -import static org.rutebanken.helper.organisation.AuthorizationConstants.ROLE_ROUTE_DATA_ADMIN; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; @@ -46,7 +44,7 @@ public class ProviderUpdater implements DataFetcher { private CodespaceRepository codespaceRepository; @Override - @PreAuthorize("hasRole('" + ROLE_ROUTE_DATA_ADMIN + "')") + @PreAuthorize("@userContextService.isAdmin()") public Provider get(DataFetchingEnvironment env) { ArgumentWrapper input = new ArgumentWrapper(env.getArgument(FIELD_INPUT)); String code = input.get(FIELD_CODE); From 1e1ecbe9ed2c4149098dff09bc334f77adff0bee Mon Sep 17 00:00:00 2001 From: Esko Suomi Date: Thu, 6 Jun 2024 13:20:02 +0300 Subject: [PATCH 2/2] remove orphaned imports --- .../no/entur/uttu/graphql/fetchers/CodespaceUpdater.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java b/src/main/java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java index 72859509..c6d3d42d 100644 --- a/src/main/java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java +++ b/src/main/java/no/entur/uttu/graphql/fetchers/CodespaceUpdater.java @@ -15,15 +15,15 @@ package no.entur.uttu.graphql.fetchers; -import static no.entur.uttu.graphql.GraphQLNames.*; -import static org.rutebanken.helper.organisation.AuthorizationConstants.ROLE_ROUTE_DATA_ADMIN; +import static no.entur.uttu.graphql.GraphQLNames.FIELD_INPUT; +import static no.entur.uttu.graphql.GraphQLNames.FIELD_XMLNS; +import static no.entur.uttu.graphql.GraphQLNames.FIELD_XMLNS_URL; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; import no.entur.uttu.graphql.ArgumentWrapper; import no.entur.uttu.model.Codespace; import no.entur.uttu.repository.CodespaceRepository; -import no.entur.uttu.util.Preconditions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Component;