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

Add route permissions guard and controller permissions guard #238

Merged
merged 20 commits into from
Jun 19, 2014

Conversation

jmleroux
Copy link
Contributor

First commit to add permissions check on route, as discussed in #182

Discussin is open, tests to come

@@ -0,0 +1,100 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File seems to be in "tests" folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A mistake, wil move to src

@bakura10
Copy link
Member

Apart from CS problems, it looks good to me! @arekkas, @danizord, do you mind a review?

@aeneasr
Copy link
Contributor

aeneasr commented Jun 13, 2014

On first sight a very good idea and apart from the things you commented @bakura10 it looks fine to me too. However, I'd like to see some tests :)

@jmleroux
Copy link
Contributor Author

Just a note on comments and dockblocks.
I recently read this excellent book : Clean Code and i try to comment as little as possible, because a good code don't need comments. If documentation is not generated, dockblock does not seems mandatory to me.
But anyway, if you really want dockblock, i will write it. 👍

@bakura10
Copy link
Member

I want it mostly because it helps IDE :)

Envoyé de mon iPhone

Le 13 juin 2014 à 13:19, jean-marie leroux [email protected] a écrit :

Just a note on comments and dockblocks.
I recently read this excellent book : Clean Code and i try to comment as little as possible, because a good code don't need comments. If documentation is not generated, dockblock does not seems mandatory to me.
But anyway, if you really want dockblock, i will write it.


Reply to this email directly or view it on GitHub.

@jmleroux
Copy link
Contributor Author

I want it mostly because it helps IDE :)

PHPStorm don't need them : it can read the function prototype and the return type if fixed.
Maybe for Eclipse ?

@coveralls
Copy link

Coverage Status

Coverage decreased (-9.26%) when pulling b3dda6d on jmleroux:route-permissions-guard into f17bf0f on ZF-Commons:master.

@bakura10
Copy link
Member

I LIKE THEM :D. That's my reason :p

Envoyé de mon iPhone

Le 13 juin 2014 à 13:29, jean-marie leroux [email protected] a écrit :

I want it mostly because it helps IDE :)

PHPStorm don't need them : it can read the function prototype and the return type if fixed.
Maybe for Eclipse ?


Reply to this email directly or view it on GitHub.

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.59%) when pulling 78f8e66 on jmleroux:route-permissions-guard into f17bf0f on ZF-Commons:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.59%) when pulling 8e75f52 on jmleroux:route-permissions-guard into f17bf0f on ZF-Commons:master.

@bakura10
Copy link
Member

Looks perfect. Just waiting for tests for the new guard AND doc ;).

@bakura10
Copy link
Member

Additionally, I think we should change the default event priority to -10 (like ControllerGuard), so that RouteGuard is always executed first. This allows to clarify the case where you would have both a RouteGuard and RoutePermissionsGuard for the same route.

By default the RouteGuard is registered with -5, ControllerGuard with -10, and I suggest RoutePermissionsGuard to be -10 too (https://github.com/ZF-Commons/zfc-rbac/blob/master/src/ZfcRbac/Guard/ControllerGuard.php#L37)

@aeneasr
Copy link
Contributor

aeneasr commented Jun 13, 2014

👍 on the priority

@jmleroux
Copy link
Contributor Author

It would be best to execute Guards in the order declared in the config.

But for the sake of simplicity, i will change the priority

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.78%) when pulling 9539831 on jmleroux:route-permissions-guard into f17bf0f on ZF-Commons:master.

@danizord
Copy link
Member

What's the point of mapping multiple permissions for a single route? I think 1 to 1 is more reasonable.

@@ -18,6 +18,7 @@

namespace ZfcRbac\Guard;

use Doctrine\Common\Proxy\Exception\InvalidArgumentException;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What what? Doctrine exception in this part of the code? I don't like that. People can use ZfcRbac without Doctrine!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops ! PHPStorm autocompletion can be tricky...

@bakura10
Copy link
Member

I will be on holidays the next few days so I won't be able to merge this.

In overall I like it, I just don't like that you included the RULE_AND feature in this PR. Please revert that and only keeps what we need here. I'd prefer you to do that as another PR once this one is merged, so we can discuss it separately.

@jmleroux
Copy link
Contributor Author

I'd prefer you to do that as another PR once this one is merged, so we can discuss it separately.

👍 OK for a next PR. I revert.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.23%) when pulling 6984b01 on jmleroux:route-permissions-guard into 397c676 on ZF-Commons:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.14%) when pulling 7926465 on jmleroux:route-permissions-guard into 397c676 on ZF-Commons:master.

@@ -0,0 +1,141 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the whole file marked as changed? Very hard to know what has changed :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'cause it's a new one 😉

ControllerPermissionsGuard

@bakura10
Copy link
Member

Sorry but it seems a lot lot of files have a complete different change set, and all the lines are marked as strange. I could merge this but I'm a bit worried because I can't know what has changed in all those files that does not directly belong to this PR :/.

@jmleroux
Copy link
Contributor Author

I don't see wich file is worrying you.
Could you annotate ?

@jmleroux jmleroux changed the title Add route permissions guard Add route permissions guard and controller permissions guard Jun 18, 2014
@jmleroux
Copy link
Contributor Author

I have changed the title to reflect all the changes of this PR.

@aeneasr
Copy link
Contributor

aeneasr commented Jun 19, 2014

From what I can tell only the GuardPluginManager and docs have changed, all the other files are new additions?

@bakura10
Copy link
Member

Sorry, I didn't realized you added a fourth guard. Doc is missing for ControllerPermissionsGuard though.


foreach ($rules as $rule) {
$controller = strtolower($rule['controller']);
$actions = isset($rule['actions']) ? (array) $rule['actions'] : [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix alignment of "="

@bakura10
Copy link
Member

Looks good. I'll merge once doc is added for the new guard.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.14%) when pulling f26b666 on jmleroux:route-permissions-guard into 397c676 on ZF-Commons:master.

bakura10 added a commit that referenced this pull request Jun 19, 2014
Add route permissions guard and controller permissions guard
@bakura10 bakura10 merged commit ad6f08a into ZF-Commons:master Jun 19, 2014
@jmleroux
Copy link
Contributor Author

oops, i modified a test in the meanwhile.
Could you re merge, and i'll update to master

@jmleroux
Copy link
Contributor Author

nevermind, i'll do it on master.
Keep this closed.

@bakura10
Copy link
Member

I received a mail notification @davidwindell. But can't find your comment?

@davidwindell
Copy link
Contributor

@bakura10 moved it to an issue #242

@davidwindell
Copy link
Contributor

Oops I mean #262

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

Successfully merging this pull request may close these issues.

6 participants