laravel-json-api / laravel

JSON:API for Laravel applications
MIT License
541 stars 41 forks source link

2 Authorizers for one Schema #202

Open veneliniliev opened 2 years ago

veneliniliev commented 2 years ago

can I register 2 authorizers of one Schema?

example:

2 authorizers have very different logic and are used in different schemas

lindyhopchris commented 2 years ago

Hi. I'm not sure I understand the use case. How would we know which authorizer to use?

veneliniliev commented 2 years ago

I want to use both at the same time. if I use middleware I can't access the resource/type and the other benefits I have directly in the authorizer.

lindyhopchris commented 2 years ago

My point is that the JSON:API implementation looks up the authoriser and automatically executes the functions on it. How would we know which authorizer to use if there are two?

veneliniliev commented 2 years ago

first executes one, if successful executes the second as well. in the old version, I could have one in the resource and one from the routing like ->authorizer() and working.

in the new version, there is LaravelJsonApi::registerAuthorizer but I can't add two (or more) authorizers to run sequentially

lindyhopchris commented 2 years ago

ah ok, in the old version I don't think I intentionally supported two authorisers working: it looks like an accidental benefit of how I implemented it.

I'll have a think how this could be supported.