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

Added example for LIFO/FILO #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TomHAnderson
Copy link
Contributor

@ezimuel if you add this clarification I'll be appeased.

@ezimuel
Copy link
Contributor

ezimuel commented Mar 28, 2018

@TomHAnderson can you add some explanations in the docs about the example, thanks!

@TomHAnderson TomHAnderson changed the title Added example for LIFO Added example for LIFO/FILO Mar 28, 2018
@TomHAnderson
Copy link
Contributor Author

@ezimuel This PR is ready for review.


When specifying multiple parents for a role the last parent listed is the first
one searched for rules applicable to an authorization query. This Last-In-First-Out
(aka First-In-Last-Out) strategy is represented with this example.
Copy link
Member

Choose a reason for hiding this comment

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

To be honest, I have never seen it referred to as FILO, only LIFO.

When specifying multiple parents for a role the last parent listed is the first
one searched for rules applicable to an authorization query. This Last-In-First-Out
(aka First-In-Last-Out) strategy is represented with this example.
Here the `first` role is the highest order:
Copy link
Member

Choose a reason for hiding this comment

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

But first is the role being defined; shouldn't this be mentioning one of the parents (last, second, etc.)?

(aka First-In-Last-Out) strategy is represented with this example.
Here the `first` role is the highest order:

```
Copy link
Member

Choose a reason for hiding this comment

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

Examples should include a language identifier; in this case, append "php" to the code delimiters.


```
$acl->addRole(new Role('first'), ['last', 'third', 'second']);
```
Copy link
Member

Choose a reason for hiding this comment

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

For this example to have an impact, we need to demonstrate an ACL query that shows the order in which the parent roles are queried. That will require also demonstrating setup of the parent roles and their own permissions.

$acl->addRole(new Role('first'), ['last', 'third', 'second']);
```

Less-permissioned roles will be first in the parents array. For instance, where a`guest`
Copy link
Member

Choose a reason for hiding this comment

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

Here and elsewhere in the patch, please use only one space between a period and the start of the next sentence.

Copy link
Member

Choose a reason for hiding this comment

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

Explain why less-permissioned roles should be first in the parents: because they will be queried first, and as soon as a single query returns false, no other parents are queried. As such, having roles with higher-level responsibilities first ensures that a positive query lookup will occur.


Less-permissioned roles will be first in the parents array. For instance, where a`guest`
role is unauthenticated, a `user` role is authenticated, and an `admin` role has the highest
permissions. As soon as any ACL query returns false evaluation of `isAllowed` is terminated and false is returned. For this reason your least permissioned roles come first in the parents array. Adding the `admin` role is as follows:
Copy link
Member

Choose a reason for hiding this comment

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

This paragraph is confusing. First found rule is used, whether allow or deny. Right?
ACL by default is deny, so there is likely only allow rules unless role overrides inherited rules or otherwise explicitly declares deny rule.

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-permissions-acl; a new issue has been opened at laminas/laminas-permissions-acl#1.

@weierophinney
Copy link
Member

This repository has been moved to laminas/laminas-permissions-acl. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:

  • Squash all commits in your branch (git rebase -i origin/{branch})
  • Make a note of all changed files (`git diff --name-only origin/{branch}...HEAD
  • Run the laminas/laminas-migration tool on the code.
  • Clone laminas/laminas-permissions-acl to another directory.
  • Copy the files from the second bullet point to the clone of laminas/laminas-permissions-acl.
  • In your clone of laminas/laminas-permissions-acl, commit the files, push to your fork, and open the new PR.
    We will be providing tooling via laminas/laminas-migration soon to help automate the process.

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.

4 participants