nilportugues / php-json-api

JSON API transformer outputting valid (PSR-7) API Responses.
http://nilportugues.com
MIT License
71 stars 35 forks source link

Add ForbiddenException and forbidden response method #66

Closed therealcljohn closed 8 years ago

therealcljohn commented 8 years ago

I'm using this library and implemented attribute based access controll with laravels gate and policy framework. Therefore I need to check authorisation inside the action callback methods sometimes. To get a more detailed response than just http status 400 on authorisation failure I implemented a ForbiddenException that triggers a 403 forbidden response.

Usage of this exception is totaly optional but I think providing it would be quite nice for people who need to implement authorisation in their own action callback methods. If there is a better way how this can be done I would be happy to receive some feedback.

nilportugues commented 8 years ago

@floh1111 makes sense to support the 403.