Role hierarchy: Unterschied zwischen den Versionen
(Erstentwurf) |
(Änderung 7897 von Fraggle (Diskussion) rückgängig gemacht.) Markierung: Rückgängigmachung |
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |
(kein Unterschied)
|
Aktuelle Version vom 13. Mai 2024, 19:31 Uhr
The fundament of our security is a customizable role hierarchy. One or multiple roles can be applied to a user. Every role itself is linked to different permissions which allow to view, edit or delete resources like geocaches, logs or users. If no permission is present it defaults to disallowing the action.
Role hierarchy
https://app.conceptboard.com/board/9qra-r8bs-bpy2-cuf2-0ikx
This diagram must be read bottom to top. Every role inherits roles above them. Example: ROLE_SOCIAL_HEAD contains ROLE_SOCIAL, ROLE_SOCIAL_TRAINEE, ROLE_TEAM and ROLE_USER. Every logged in user has ROLE_USER.
Permissions
Permissions are linked to different roles which can be seen as a permission group.
Database
-
table security_roles
-
table security_roles_hierarchy
-
example for table user_roles
Code examples
Annotations, to secure complete functions or classes:
/** * @Security("is_granted('ROLE_SOCIAL')") */
PHP, to secure parts of the code:
if ($this->isGranted('ROLE_SOCIAL')) { .. }
Twig, to secure parts of the code from being displayed or executed. But pay attention: as long as the @routes are not secured (see above) they still can be called via URL!
{% if is_granted('ROLE_SOCIAL') %} {{ 'You have access.' }} {% else %} {{ 'Sorry. You don\'t have access.' }} {% endif %}