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

Security Token #76

Open
zerlpaMMT opened this issue Apr 28, 2018 · 2 comments
Open

Security Token #76

zerlpaMMT opened this issue Apr 28, 2018 · 2 comments

Comments

@zerlpaMMT
Copy link

Hi,

is there any possibility to get the token into the resolve function of a type?
https://graphql.org/learn/authorization/ says that accessibility control for some kind of data should be in the business logic layer.

kind regards.

@mwarnaar
Copy link

@zerlpaMMT did you find a solution to this? It seems that (in Symfony 4) the result of container[...]->get('security.token_storage')->getToken()->getUser() returns 'anon.' instead of the currently logged in user. Therefore, using symfony.authorization_checker->isGranted() inside fields/mutations does not seem to work like you would expect.

This happens when following the comments in #68, with the following in services.yaml:

graphql.processor:
        public: true
        class: Youshido\GraphQLBundle\Execution\Processor
        arguments:
            $executionContext: '@graphql.execution_context'
        calls:
            - [setSecurityManager, ['@graphql.security_manager']]

@mwarnaar
Copy link

mwarnaar commented Jun 27, 2018

It turned out that it was a missing Apollo client setting. In front-end javascript, passing credentials: 'same-origin' with createHttpLink did the trick for session-based authentication (https://www.apollographql.com/docs/react/recipes/authentication.html). Might not be related to this issue, but this could help you in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants