tiagopog / jsonapi-utils

Build JSON API-compliant APIs on Rails with no (or less) learning curve.
MIT License
216 stars 80 forks source link

Support for operation processors? #77

Open jasonjho opened 7 years ago

jasonjho commented 7 years ago

@tiagopog Is there a way to use jsonapi-authorization, which plugs into JR as a custom operation processor? Based on the JR controller logic here (https://github.com/cerebris/jsonapi-resources/blob/v0.9.0/lib/jsonapi/acts_as_resource_controller.rb#L77), there seems to be some logic around how these processors are invoked -- but jsonapi-utils seems to be overriding this functionality, if I understand it correctly.

Do you have any recommendations for how best to integrate with something like jsonapi-authorization? Would love to take your ideas and make them work.

Thanks!

tiagopog commented 7 years ago

Sorry for the long delay on answering you, @jasonjho. I hope to bring something still useful for you.

I went through the gem's code/documentation and saw that it works by defining a default processor as you pointed. Since JU overrides the #process_request method only for avoiding bugs with duplicate request parsing on JR's default-generated actions, the jsonapi-authorization would work as expected only for those default actions.

Having in mind that JU works by explicitly defining/overriding the controller actions (i.e. the usual Rails way) I would suggest you to use the JU combined directly with Pundit, since it's simple to implement and it's also less "magical" for not involving the resource layer.

FYK I have a production API running with this authorization setup that I have just mentioned and the implementation got pretty neat, so maybe a new abstraction layer (i.e. jsonapi-authorization) is not required :-)

jsmestad commented 6 years ago

@tiagopog thanks for putting this together! It would be great to get some docs in the README about how to use jsonapi-authorization with JU

kceb commented 3 years ago

@tiagopog I'm finding that I need an operation processor for other reasons. Is there support for it?

https://jsonapi-resources.com/v0.9/guide/operation_processors.html