Distinguish Access Rights to API routes with different roles#108
Distinguish Access Rights to API routes with different roles#108dxL1nus wants to merge 5 commits into
Conversation
|
We need to consider here that not all users may be allowed to change the status of a check. |
since these are 2 different PR's, I would firstly merge this, and then we can just use this functionality on the status branch |
b84d741 to
e76afdc
Compare
I just did this, because this branch was so old before the rebase, that there was now test scripts in the |
|
@dxL1nus will rebase this once more. |
c98fc2b to
bf4512f
Compare
|
@nuest this PR is now ready for review and can be merged if you want! Everything is now rebased to main and working |
Closes #87;
We now have a
CodecheckRoleclass which can be extended to have our won Role Sets like e.g.ReadAccessRoles. This then gets an array ofPKP\security\Rolelike the following:Next an API endpoint can now have exactly one CodecheckRole Type like the following:
When the request for the endpoint is then authorized, it is checked if the endpoint role is the same as the class from each element in the
$codecheckRolesarray that theCodecheckApiHandlergets in its constructor. If so, then the first role element is used and its actual PKP roles are retrieved and then it is checked if the user has at least on of these roles. If so, then the route is authorized as normal.and in
authorize()This way we can provide multiple different role sets and even create new ones, by creating new classes, which extend
CodecheckRole.