Comments (11)
It is a classic RoR implementation of graphql. It is hard to give you a code example since it is a private repository :/ I tried overriding it in BaseMutation
/BaseObject
/ApplicationController
(root of my graphql controller) classes. I put a pry inside each of my implementations but none was reached. In each of these classes i just did this:
def authorization_namespace
::UserApplication
end
If we have for example a policy like this: UserApplication::TotoPolicy
.
I also put a pry inside the library to see the output of this method but for a mutation Mutations::UserApplication::TestMutation
, it would always return Mutations::UserApplication
.
from action_policy-graphql.
It may be good to notice that in BaseMutation
and BaseObject
I have included include ActionPolicy::GraphQL::Behaviour
from action_policy-graphql.
Sorry didn't have the time to work again on this issue, but we might try again in another context we we'll see the result
from action_policy-graphql.
Could you please provide a code example? Where do you include Action Policy behaviour and where do you override (and how) #authorization_namespace
? I will try to reproduce it
from action_policy-graphql.
Thanks for the details! (And sorry for late response)
I will do my best to work on this till the end of the year
from action_policy-graphql.
@Tyflomate I tried to reproduce the problem here but with no luck: 58e89be
Maybe, you can try to tweak our test examples to demonstrate the failing case?
from action_policy-graphql.
Hey @Tyflomate! Was this issue resolved? And if not, could you please help with the reproduction (see the prev comment)?
from action_policy-graphql.
Hello @palkan
I encountered the same problem yesterday, maybe in another form.
Our environment is pretty much the same as @Tyflomate. To deduplicate behaviour declaration between our GraphQL types and mutations, I used an ActiveSupport::Concern to include in both base mutation and base object.
So far, it looks like:
module Authorizations
extend ActiveSupport::Concern
included do
include ActionPolicy::GraphQL::Behaviour
prepend LookupMethods
end
module LookupMethods
def authorization_namespace = ::Api
def default_authorization_policy_class = ::ApiPolicy
end
end
We need to use prepend or lookup methods declared in action_policy/behaviours/namespaced.rb
take precedence over our version of authorization_namespace
.
On the other side, default_authorization_policy_class
works however we define it: prepended, included or extended. I would have expected authorization_namespace
to work the same.
from action_policy-graphql.
Hey @gael-ian!
Thanks for the snippet.
I see what's going on here: we define the #authorization_namespace
method right on the class:
That's why include
doesn't work.
Agree, this is confusing, let's fix it.
from action_policy-graphql.
Nope, the code I linked above only affects authorized?
callbacks—is this your case @gael-ian ? Otherwise, overriding #authorization_namespace
works fine, see f0129eb
from action_policy-graphql.
Okay, thanks; closing for now; will re-open if the problem occurs again.
from action_policy-graphql.
Related Issues (20)
- Using authorized_scope on input HOT 7
- Figure out mutation/resolver input or arguments authorization HOT 5
- `expose_authorization_rules` Changes HOT 4
- Graphql context in Policies? HOT 2
- Handle record with preauthorize? HOT 2
- verify_authorized HOT 2
- Exposed authorization rules can't be accessed without user context HOT 5
- can_create_object? permission location HOT 2
- Allow to use proc for authorized_scope HOT 1
- Lack of expose_authorization_rules for Interface HOT 2
- Raise AuthorizationContextMissing before resolving HOT 8
- AuthorizedField is included (prepended) multiple time into field class
- NoMethodError: undefined method `authorize_mutation_raise_exception'
- Modules reloading works incorrectly in development HOT 1
- Can ruby-next be a development-only dependency like action_policy? HOT 2
- Upgrading graphql Gem to 1.12.4 Causes Connection Error HOT 1
- how to authorize scope at resolver level HOT 3
- expose_authorization_rules with custom context
- ActionPolicy does not work well with graphql-ruby dataloaders (not thread/fiber safe) HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from action_policy-graphql.