Repository navigation
JSPWIKI-1210 Advanced access rules with AND, OR, NOT and parentheses - #655
Open
arturobernalg wants to merge 3 commits into
Open
arturobernalg wants to merge 3 commits into
arturobernalg wants to merge 3 commits into
Conversation
…s, as well as parenthesis
The advanced rules are kept by the AclImpl of the page, together with its entries, instead of in a class that replaces the Acl. A page can mix simple and advanced rules in any order, and the rules of the same action add up, as the simple ones do. The AuthorizationManager grants a permission to the users that satisfy any rule that implies it, and denies it when no rule does, so a page with only an advanced rule for edit is not readable by anonymous users either. A name counts as held only when the user has the role, group or user principal, so a name that is only asserted does not satisfy a rule. AND, OR and NOT are read only in upper case, a comma cannot be mixed with them, and a rule that does not parse is reported as an invalid access rule. printAcl writes the advanced rules too. The jspwiki.authZManager property and the protected engine of the authorization manager are dropped, as nothing needs them now.
A list of names with commas is always a simple rule, as it was before, so a name with an upper case AND, OR or NOT inside it does not turn the whole line into an advanced rule that fails. AND, OR and NOT next to parentheses are operators, as the parser reads them. Parsing the same page again does not add its advanced rules again. A page that is restricted only by advanced rules is not notified to the subscribers. Renaming a user profile changes the name in the advanced rules too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This takes over #484 (JSPWIKI-1210). The first commit is the original work of Alex O'Ree, rebased on master. The next two rework it after the problems found in the review of #484 and in a second review of this change.
An access rule can now combine roles, groups and users, for example
[{ALLOW edit Editors AND (Reviewers OR NOT Banned)}].What changed on top of the first commit:
AclImplof the page, next to its entries, and no longer in a class that replaces the Acl. A page can mix simple and advanced rules in any order, and the rules of the same action add up, as the simple ones do. This fixes the lost simple rule and the "Not supported yet." error when saving a page. Parsing the same page again does not add its rules again.DefaultAuthorizationManagergrants a permission to the users that satisfy any rule that implies it, and denies it when none does. A page with only[{ALLOW edit Admin OR Editors}]is no longer readable by anonymous users, as with a simple rule.AND,ORandNOTare read only in upper case. A rule without commas is advanced when one of them is a word of its own, or is next to a parenthesis. Names such as ANDY or ORACLE and lower case words stay names. A list with commas is always a simple rule, as before. A rule that does not parse is reported as an invalid access rule.DefaultAclManager.printAclwrites the advanced rules too, and renaming a user profile changes the name in the advanced rules as it does in the entries.jspwiki.authZManagerproperty and the protected engine field are removed, as nothing needs them now.Cost and limits:
Sales OR Marketing) is now read as an advanced rule. I did not find such a rule in the default pages. With commas it stays a simple rule.Authenticated AND NOT Banned, not onlyNOT Banned, to grant to logged in users. The policy file still has to grant the permission.Tests: new
AdvancedAclAuthorizationTestwith anonymous, asserted and authenticated sessions and wiki groups, new cases inDefaultAclManagerTestandDefaultSubscriptionManagerTest, and a stricterRuleParserTest. The wholejspwiki-mainmodule passes (1222 tests). I also ran the war in Tomcat 10.1 with registered users and checked an advanced rule alone, a simple one before an advanced one, an advanced one before a simple one, andAuthenticated AND NOT: anonymous users go to the login page, the allowed users view and edit, the others cannot edit, and the page text is shown.