laravel icon indicating copy to clipboard operation
laravel copied to clipboard

2 Authorizers for one Schema

Open veneliniliev opened this issue 3 years ago • 5 comments

can I register 2 authorizers of one Schema?

example:

  • one for permission (as resource authorizer)
  • one for premium service (register in AuthServiceProvider with LaravelJsonApi::registerAuthorizer)

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

veneliniliev avatar Jun 28 '22 07:06 veneliniliev

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

lindyhopchris avatar Jul 02 '22 17:07 lindyhopchris

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.

veneliniliev avatar Jul 14 '22 09:07 veneliniliev

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?

lindyhopchris avatar Jul 14 '22 09:07 lindyhopchris

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

veneliniliev avatar Jul 14 '22 09:07 veneliniliev

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.

lindyhopchris avatar Jul 14 '22 16:07 lindyhopchris