Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Protection Policy at Guard Level #263

Open
davidwindell opened this issue Jul 29, 2014 · 3 comments
Open

Protection Policy at Guard Level #263

davidwindell opened this issue Jul 29, 2014 · 3 comments

Comments

@davidwindell
Copy link
Contributor

I have two route guards - role and permission based.

I already have the role guards setup with a default DENY policy, but with two guards it doesn't make sense to have them both denying, I would like the be able to make permissions ALLOW by default.

@davidwindell
Copy link
Contributor Author

@bakura10 I was able to achieve this with the below (not a real life example), but it's a bit hacky. Essentially my permission route guard has a wildcard which affects any routes not mentioned above this. That way, the role guard operates in DENY mode, whereas the permission guard operates in a pseudo ALLOW mode

'zfc_rbac' => [
    'protection_policy' => GuardInterface::POLICY_DENY,
    'guards' => [
        'ZfcRbac\Guard\RouteGuard' => [
            'app/calendar' => Role::EVENT_MANAGER,
        ],
        'ZfcRbac\Guard\RoutePermissionsGuard' => [
            'app/something*' => Permission::ALLOW_THIS,
            '*' => '*',
        ]
    ]
]

EDIT
This only works when the order is correct, so merging multiple configs leaves the wildcard rule above others which breaks the hack.

@davidwindell
Copy link
Contributor Author

I'm not sure how this would look in practice...perhaps the below as an option? Retaining the old method as a default for BC and ease of config?

'zfc_rbac' => [
    'protection_policy' => GuardInterface::POLICY_DENY,
    'guards' => [
        'ZfcRbac\Guard\RouteGuard' => [
            'app/calendar' => Role::EVENT_MANAGER,
        ],
        'ZfcRbac\Guard\RoutePermissionsGuard' => [
            'protection_policy' => GuardInterface::POLICY_ALLOW,
            'rules' => [
                'app/something*' => Permission::ALLOW_THIS,
                '*' => '*',
            ]
        ]
    ]
]

What do you think?

@jmleroux
Copy link
Contributor

jmleroux commented Sep 2, 2014

Could be interesting.
ping @bakura10

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants