The current (1.9) implementation of authz is lacking in two areas:
- Wildcard support and performance
- Performance when a large number of paths needs to be checked. Affected operations are mainly checkout / export and log.
- Support for wildcards. Subversion should support
- "*" for single (exactly one), arbitrary path segments (with no "/" in them) and
- "**" for arbitrary number (zero to infinite) of path segments.
- Classic wildcard patterns like "*foo*.bar", including escapement via the "\" prefix shall be supported. The asterisks in there match zero to many characters other than "/" making the whole segment form "/*/" a mere special case of this.
All wildcard usage applies to full path segments only, i.e. a '*' never matches a '/' except for the case of "/**/" where it matches zero to many full segments. For example, "/*/**/*" will match any path that contains at least 2 segments and is equivalent to "/**/*/*" as well as "/*/*/**".
- Better access control
- The right to know about the existence of a node (a.k.a. lookup access rights and/or directory traversal rights) is implied by read access and cannot be manipulated separately.
Wildcard Support and Performance
A path consists of segments, separated by "/". Whildcards are valid segments and their interpretation depends on the context.
An access control list (ACL) contains a number of access control elements (ACE), each describing which users shall have what access rights. Users might be specified indirectly by using groups.
A path rule specifies what ACL applies to a given path.
Inheritance and Disambiguation
These are the rules as of today, with rule 7 added to support ambiguous path matches caused by pattern matching. Please note the difference between matching (does a path fully match a given pattern?) and applying to (governing the access rights).
- An ACL is relevant to a user if the user, one of their aliases or groups that they are a member of is mentioned by at least one ACE in that ACL.
- Only path rules with ACLs relevant to the given user may match a path.
- If a path rule matches a given repository path, its ACL applies to that path.
- If no path rule matches a given repository path, the parent path's ACL applies.
- If no ACL is given for the repository root, a default ACL denying everybody access to the root path, applies.
- If repository-specific path rules as well as global path rules match a given path, only the repository-specific ones will be considered.
- If multiple path rules match a given repository path, only the one specified last in the authz file shall apply.
- If multiple ACEs of a given ACL apply to a user, the union of all individually granted access rights is granted.
The idea is to use combine the following approaches:
- Preprocessed, tree-like data structures applied to segmented paths
- Reduction of the tree to what applies to the current user
- Pre-calculate recursive rights for early exit
Putting caching aside, the workflow involved three data models, building on top of each other.
- Parsing an authz file (from file system or repository), validating its contents and creating a pre-processed in-memory representation. In comparison to the old
svn_config_tbased code, additional restrictions apply:
- No rule may appear more than once in the authz file.
- Value placeholders (
%(name)s) are not expanded.
- Filtered path rule tree
- prefix tree with one node per segment
- created on demand per user and repository
- contains only rules that apply to the respective user and repository
- multiple instances of that being cached in the svn_authz_t structure alongside the single "full model"
- ACLs being reduced to access rights + order ID
- each node knows min / max rights on all sub-nodes
- Lookup state
- access rights accordingly the latest matching path rule
- list of tree nodes that may match sub-paths as we may need to follow multiple patterns
- temporary data structure thats reused between queries to save on allocation and construction overhead
These are persistent in the sense that we will cache and reuse them. They do not cover transient data models that various algorithms may use e.g. during authz parsing.
Unless indicated otherwise, all collections are ordered.
Only abstract types / the interface view is given here; the actual implementation may be different.
Filtered path rule tree
Wildcard sequences in paths shall be normalized internally. This is merely done to reduce matching costs later on and some of the matching code may rely on normalized pattern.
Since there is always an implicit path rule at the root for all users, lookup is always necessary.
Checking whether we need to continue in our path matching is trivial, just check whether there are any potential matches to sub-paths.
One step in the lookup iteration, i.e. matching the next segment, is relatively simple as well. For simplicity, we ignore the min/max rights optimization here.
So, the full lookup without caching is as shown below. For efficiency, the implementation will check the accumulated global rights calculated by the parser before performing a tree lookup. There are probably many cases where the result of any lookup can be predicted from those rights, and therefore the lookup itself, and even creation of the filtered tree, could be skipped entirely.
Better Access Control
TODO after 1.10.
Changes from Current Behaviour
Rules Defined Only Once
The config-based parser would merge and override access entries in redefined rules. The new parser rejects authz files that define the same rule more than once.
New Rule Syntax for Wildcard Rules
Existing rules come in two flavours; repository-specific and global:
In these rules,
/path is always matched literally. The new parser supports two new forms for rules with paths that contain wildcards:
Because a glob rule is not required to actually contain wildcards in the path, two sections with different names may represent the same rule; for example,
the above two rules are identical. The new parser detects (and rejects) such collisions.
Write-only Access is Not Allowed
The config-based authz parser will allow access entries that grant only write access; e.g.,
The new parser flags such entries as invalid; our authz implementation does not support write-only access.
Only Group Definitions in the Global Groups File
The new parser allows only group definitions (i.e., only the
[groups] section) in the global groups file. The config-based parser would allow other sections there, but they would be ignored.