You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
The documentation for authorizing subscriptions says the authorized? method...
"may return false or raise a GraphQL::ExecutionError to halt execution"
However, while returning false does ensure the payload is nil, the subscription is still registered via write_subscription. Every subsequent trigger to the topic will send these unauthorized subscriptions an empty payload. No data leaks, but unauthorized subscribers still know something happened.
Additionally, the Authorization docs state this behavior can be customized by implementing Schema.unauthorized_object, however that doesn't to get called for subscriptions. (Perhaps related to #2048?)
Versions
graphql: 1.12.5 graphql-pro: 1.17.8 rails: 5.2
GraphQL schema
Example:
classUpdateType < GraphQL::Schema::Objectfield:message,String,null: trueendclassUpdates < GraphQL::Schema::Subscriptionpayload_typeUpdateTypedefauthorized?(**)falseendendclassMySchema < GraphQL::SchemaclassSubscriptionType < GraphQL::Schema::Objectfield:updates,subscription: Updates,null: trueenduseGraphQL::Subscriptions::ActionCableSubscriptionssubscriptionSubscriptionTypedefself.unauthorized_object(error)raiseGraphQL::ExecutionError,"Unauthorized access"# <== This never gets calledenddefself.unauthorized_field(error)raiseGraphQL::ExecutionError,"Unauthorized access"endend
GraphQL query
subscriptionUpdates {
updates {
message
}
}
Expected behavior
Returning false from GraphQL::Schema::Subscription#authorized? should prevent the subscription from getting added to the subscriptions store (via write_subscription).
Describe the bug
The documentation for authorizing subscriptions says the
authorized?method...However, while returning
falsedoes ensure the payload isnil, the subscription is still registered viawrite_subscription. Every subsequenttriggerto the topic will send these unauthorized subscriptions an empty payload. No data leaks, but unauthorized subscribers still know something happened.Additionally, the Authorization docs state this behavior can be customized by implementing
Schema.unauthorized_object, however that doesn't to get called for subscriptions. (Perhaps related to #2048?)Versions
graphql: 1.12.5graphql-pro: 1.17.8rails: 5.2GraphQL schema
Example:
GraphQL query
Expected behavior
GraphQL::Schema::Subscription#authorized?should prevent the subscription from getting added to the subscriptions store (viawrite_subscription).GraphQL::Schema::Resolver#resolve_with_supportshould callSchema.unauthorized_objectinstead of returningnilas per https://graphql-ruby.org/authorization/authorization.html#handling-unauthorized-objectsThe text was updated successfully, but these errors were encountered: