Closed hunhejj closed 7 months ago
Hi @hunhejj
Indeed, calling security.authorization_checker
is no longer possible since Symfony remove or inline services. The documentation is outdated.
Instead you can use @=hasRole(['ROLE_FOOBAR')
to check if the user has a particular role or @=hasAnyRole(['ROLE_FOO', 'ROLE_BAR'])
to check if the user has one of these roles.
You can find documentation about these expressions here : https://github.com/overblog/GraphQLBundle/blob/master/docs/definitions/expression-language.md#hasrole
And if you want to check roles against an object, you can use @=hasPermission
or @=hasAnyPermission
I would like to call the Authorization Checker directly within my GraphQL type definition in YAML as suggested in security/fields-public-control.md.
However this fails under Symfony 6 with the following message:
Hence the doc should be updated. Is there any nice way to achieve the above besides of creating my own dummy wrapper around the
AuthorizationChecker
?