-
Notifications
You must be signed in to change notification settings - Fork 11
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
♻️(backend) fix access rights on the invitations API endpoint #369
Conversation
5f809f3
to
878e4cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a frontend perspective, it looks good ✅
878e4cc
to
c636cdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider my comment on the permission name (you may agree or not), otherwise everything looks good to me :) Thanks for the permission aspect cleanup ❤️
Only users who have the rights to manage accesses on the document should be allowed to see and manipulate invitations. Other users can see access rights on the document but only when the corresponding user/team has actually been granted access. We added a parameter in document abilities so the frontend knows when the logged-in user can invite another user with the owner role or not.
c636cdb
to
3762dcc
Compare
Purpose
Only users who have the rights to manage accesses on a document should be allowed to see and manipulate invitations on this document.
Other users should be able to see access rights on the document but only when the corresponding user/team has actually been granted access, not during invitation.
Proposal
Refactor the invitation API endpoint to fix this issue concerning access rights on invitations.
As advised by @qbey, I took this refactoring opportunity to move any code related to permissions on invitations from the serializer to a permission class.
Tests on the invitation API endpoint were copied a bit too fast from https://github.com/numerique-gouv/people and did not respect the code style and testing strategy used in this project so I normalized them while modifying them to fix them following changes in the API code.