-
Notifications
You must be signed in to change notification settings - Fork 43
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
Authorization for included relationships #57
Comments
Hi! Thank you, glad you're finding the package useful. Yeah, I need to look at GitHub sponsoring! So the package doesn't handle authorizing include paths out of the box, though it's possible to do this. The reason it doesn't do it automatically is it's really down to the application logic. For example, in all the APIs I've written the logic has been that if you can read the parent resource (i.e. In your use case. you will need to add form request authorization: You'll need to add that to the One thing to note is that because authorization runs before validation, you'll need to safely handle the include paths as they won't have been validated at the point you're checking them for authorization. If this answers your question, please close the issue. Otherwise let me know what your follow up questions are! |
OK I understand what your saying and I got it working. Just for your reference I used Post and Author to keep the question simple. In my actual use case I have Also a heads up that I initially tried to do: public function authorize(): ?bool
{
$includes = $this->includePaths();
...
} but got the Error:
|
Yes that won't work because authorization occurs before validation. The You'd need to use |
ah yes. my bad you mentioned that in the first reply. Thanks for your help! |
First of all this is a fantastic work! You need to turn on GitHub Sponsoring for this repo, you deserve it.
Is it possible to authorize relationship includes? ie:
mysite.com/api/v1/posts?include=author
If I visit
mysite.com/api/v1/posts/1/author
then I can authorize the request butmysite.com/api/v1/posts?include=author
seems to be a path around that authorization.The text was updated successfully, but these errors were encountered: