Open ChristianLee-Jobber opened 4 days ago
Hey! Sorry for the trouble and thanks for the detailed report.
The only thing that came to mind was #4726, but that was released in graphql-pro v1.26.0, so it wouldn't have affected v1.24.6. I'll take a closer look and follow up here with what I find!
Ok, I read your issue more closely and I think I've spotted the issue. In GraphQL-Ruby v2.1.0, I made the default setting reauthorize_scoped_objects(false)
, so that, by default, if a list was modified by def self.scope_items
, then the items in that list would not be passed to def self.authorized?
.
However, that default setting was a bad choice (and maybe a mistake? https://github.com/rmosolgo/graphql-ruby/pull/3994#issuecomment-1832874774), so in v2.1.7, I reverted the default to reauthorize_scoped_objects(true)
-- the same behavior as GraphQL-Ruby versions <2.1.0 (#4720).
If this is the problem that's causing the issue you found, you have two options:
reauthorize_scoped_objects(true)
to your base object class. This will bring back the pre-2.1.0 changes. Want to give one of those a try? Let me know how it goes!
Describe the bug We have a type that uses
pundits
as part of the authorization flow. When being resolved as a connection, in graphql version 2.0.24, the authorization check occurs. In graphql-ruby version2.1.0
this check no longer occurs.Versions
graphql
version:2.1.0
rails
(or other framework):7.0.8
other applicable versions (
graphql-batch
, etc):1.24.6
, and even1.29.4
was tested1.3.0
GraphQL schema
Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok). Any custom extensions, etc?
GraphQL query
Example GraphQL query and response (if query execution is involved)
Steps to reproduce
def self.authorized?
method definition to intercept the authorized callself.authorized?
method will be hit -In graphql-ruby 2.1.0, query a connection_type from a resolver that uses a punditself.authorized?
will not be hitExpected behavior The authorized checks should be identical between the 2 cases
Actual behavior The authorized checks did not trigger
Additional context I did some digging into this, especially since graphql-ruby 2.1.0 changes how connections get authorized, so I thought this was a problem on us. However, I found a file
lib/graphql/schema/field/scope_extension.rb
, in which I noticed some diverging behaviour between resolving a normalconnection
vs one whose objects usepundit_role
+pundit_policy_class
: