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

Authorize before fetching data #6

Closed
alexander37137 opened this issue Oct 4, 2019 · 6 comments
Closed

Authorize before fetching data #6

alexander37137 opened this issue Oct 4, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@alexander37137
Copy link

Can i change authorize behavior to check policy before fetching data?

@palkan
Copy link
Owner

palkan commented Oct 5, 2019

Are you talking about GraphQL integration (and here palkan/action_policy#81 as well)?

@alexander37137
Copy link
Author

Yes, I want to make authorization api using graphql and i have to make graphql controller available without authorization. And that make problems with other apis. I made user nullable in graphql context and after that everywhere in queries i have to check presence of current_user

@palkan palkan transferred this issue from palkan/action_policy Oct 7, 2019
@palkan
Copy link
Owner

palkan commented Oct 7, 2019

There is not short syntax for this right now (though we might consider adding this in the future releases).

For now you can do the following:

field :something, SomeType

def something
  authorize! object, to: :rule?
  object.something
end

@palkan palkan added the enhancement New feature or request label Oct 7, 2019
@alexander37137
Copy link
Author

I see, thank you. I think for me it will be easier to make addition rest api for authorisation, than checking presence of current_user in every query. I think issue can be closed

@palkan
Copy link
Owner

palkan commented Oct 21, 2019

@alexander37137 Please, take a look at the proposed API: #10 (also solves the problem of combining scoping and authorization).

@alexander37137
Copy link
Author

Looks good to me

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

No branches or pull requests

2 participants