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

replace old style role checks with delegation to userContextService #335

Merged
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 @@ -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;
Expand All @@ -37,7 +37,7 @@ public class CodespaceUpdater implements DataFetcher<Codespace> {
private CodespaceRepository repository;

@Override
@PreAuthorize("hasRole('" + ROLE_ROUTE_DATA_ADMIN + "')")
@PreAuthorize("@userContextService.isAdmin()")
esuomi marked this conversation as resolved.
Show resolved Hide resolved
public Codespace get(DataFetchingEnvironment env) {
ArgumentWrapper input = new ArgumentWrapper(env.getArgument(FIELD_INPUT));
String codespaceXmlns = input.get(FIELD_XMLNS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -46,7 +44,7 @@ public class ProviderUpdater implements DataFetcher<Provider> {
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);
Expand Down