Skip to content

Commit 9959c00

Browse files
gichibaelenadimitrova
authored andcommitted
Edit Permissions doc to have a more straightforward example [skip ci]
1 parent bacf2e5 commit 9959c00

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

docs/_Docs_Extensions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ section: Docs
44
order: 6
55
---
66

7-
`glider` provides the option of "extensions" to the basic functionality of a colony through the use of _extensions_.
7+
`glider` provides the option of expanding the basic functionality of a colony through the use of _extensions_.
88

9-
Extensions are other smart contracts that have been given permissions to interact with a colony in a specified domain. Extensions can be used for many purposes, such as bundling transactions, automating certain actions, or something else entirely. Their implementations are intentionally disconected from the colonyNetwork codebase (stored in the [/contracts/extensions](https://github.com/JoinColony/colonyNetwork/tree/develop/contracts/extensions) folder in the network) to allow for greater design flexibility unbounded by the network protocol.
9+
Extensions are other smart contracts that have been given permissions to interact with a colony in a specified domain. Extensions can be used for many purposes, such as bundling transactions, automating certain actions, or something else entirely. Their implementations are intentionally disconnected from the colonyNetwork codebase (stored in the [/contracts/extensions](https://github.com/JoinColony/colonyNetwork/tree/develop/contracts/extensions) folder in the network) to allow for greater design flexibility unbounded by the network protocol.
1010

1111
Currently there are two extensions 'officially' supported, but more may be added in the future. These extensions are written with dapp support in mind, and emit events to inform a user interface whether a colony has an extension enabled or not. Adding and removing an extension from a colony is restricted to those with `Root` permissions on the colony.
1212

@@ -47,4 +47,4 @@ In earlier versions of the colonyNetwork, only two roles existed for permissione
4747

4848
The `OldRoles` extension bundles the roles in the `glider` release together into super-roles that have the same abilities as the original "Founder" (root) and "Admin" (funding, administration, architecture) roles.
4949

50-
Extension requires `Root` role to function.
50+
Extension requires `Root` role to function.

docs/_Docs_Permissions.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ order: 4
66

77
In the full implementation of the Colony protocol, decision making will be determined by the reputation score of an account. Actions that are currently permissioned, such as moving shared funds and creating a task, will be allowed proportionate to an account's reputation score. This functionality is planned for later releases.
88

9-
In the current `glider` release, network state changes are authorised by dedicated "authority" contracts e.g. `ColonyAuthority.sol`. These are based on the `DSRoles` implementation from [dappsys library](https://github.com/dapphub/dappsys-monolithic). Functions decorated with the `auth` and `authDomain` modifiers will perform an authorization check via the authority contracts before granting access. In future releases, this pattern will also allow us to switch to a reputation-mediated authority in colonies.
9+
In the current `glider` release, network state changes are authorized by dedicated "authority" contracts e.g. `ColonyAuthority.sol`. These are based on the `DSRoles` implementation from [dappsys](https://github.com/dapphub/dappsys-monolithic). Functions decorated with the `auth` and `authDomain` modifiers will perform an authorization check via the authority contracts before granting access. In future releases, this pattern will also allow us to switch to a reputation-mediated authority in colonies.
1010

1111
Roles are defined within `ColonyRole` struct and grant permission to call certain functions within a specific domain of the colony. These are initialized in `ColonyAuthority.sol`. An account may be given one or more of the available pre-defined roles:
1212

@@ -20,10 +20,12 @@ Note: Currently, the existing `auth` modifier is preserved and checks for permis
2020

2121
Note: Currently `Arbitration` role grants permission for no functions. It is a placeholder for the dispute resolution system, to be implemented in later releases.
2222

23-
For example, within the 'logistics' domain, any address with the `Administration` role may call the `addPayment` function to create a new payment. But to add funding for the payment, an address with the `Funding` role must call `moveFundsBetweenPots` for the payment. These two functions can be called by the same address (even in the same transaction), provided that the address has both `Administration` and `Funding` permissions.
23+
## Domain permission transitivity
24+
*Note: Domains are currently restricted to one level below the root domain. This restriction will be removed after release.*
2425

25-
**Domain permission inheritance**
26-
Domain permissions flow down in the domain tree. As an example of how domain permissions propagate, consider this tree of domains in a colony (using domainIds as identifiers):
26+
Domain permissions extend from the root domain. Permissions held in a domain are held in all child sub-domains, but not in parent domains.
27+
28+
As an example, consider this tree of domains in a colony (using domainIds as identifiers):
2729

2830
```
2931
1
@@ -33,42 +35,45 @@ Domain permissions flow down in the domain tree. As an example of how domain per
3335
3 5
3436
```
3537

36-
If you have funding permission in `3`, and funding permission in `6`, you shouldn't be able to move funds from `3` to `6`, because that would be taking them out of `2`, which you don't have the permission for. If you have funding permission in `1`, however, you should be able to move from `3` to `6`, because that's all under 'one roof'.
38+
Authority in domain `2` to call a permissioned function is valid in domains `3` and `5`, but not `6`. Authority in domain `1` to call a permissioned function is valid in all subdomains.
3739

38-
**Using permissioned functions**
40+
## Using permissioned functions
41+
Permissioned functions check two arguments, which are by convention the first and second ones expected in all permissioned functions:
3942

40-
In order to provide the necessary inputs to the authorisation logic, we have added two arguments to every permissioned function, which by convention are the first two arguments. The first is the permission domain id (`_permissionDomainId`), and the second is an index (`_childSkillIndex`) telling us where in the child array of the permission domain we can find the "domain of action". The "domain of action" itself is the domain in which state is being changed.
43+
`_permissionDomainId`: The domain that gives the caller the authority to execute an action
44+
`_childSkillIndex`: an index that specifies where to find the domain in which the action occurs.
4145

42-
For example is a colony with the domain tree below,
46+
New domains are given a unique skillId upon creation, so a colony with the following domain structure
4347
```
4448
1
4549
/ | \
4650
2 4 6
4751
/ \
4852
3 5
4953
```
50-
which has representative local skills Id as follows:
54+
might have local skillIds assigned as:
5155
```
5256
142
5357
/ | \
5458
147 254 696
5559
/ \
5660
159 307
5761
```
58-
Skill `142` has the following `children`: `[147, 159, 254, 307, 696]`
5962

60-
if we want to grant user `USER2` permission to create tasks and payments in domain `5`, and we ourselves are user `USER1` have root permissions. We need to give them permissions in that specific domain as follows:
63+
In this example,
64+
Skill `142` has children: `[147, 159, 254, 307, 696]`
65+
Skill `147` has children: `[159, 307]`
66+
Skill `254` has children: `[]`
67+
68+
If a user with "Admininstration" authority in domain `2` wants to finalize a payment in domain `5`, they would call:
6169

6270
```
63-
colony.setAdministrationRole(1, 3, USER2, 5, true, { from: USER1 });
71+
colony.finalizePayment(2, 1, _paymentId);
6472
```
6573

66-
Essentially the two additional parameters are used to perform the following checks:
67-
68-
1) Whether `USER1` has the permission to assign a new `Administrator` in `_permissionDomainId`, which is domain `1` in this case.
69-
70-
2) Whether the domain of action, if this case domain `5`, is actually a child of the permission domain `1`. This is done using `_childSkillIndex`, here passed as `3` meaning the permission domain (`1`) `skill.children` array's third member should match domain `5` skill.
74+
The `authDomain` modifier performs the following checks:
7175

72-
And for the architecture permission, checks to see that the domain is strictly a child of the permission domain (i.e. not the permission domain itself).
76+
1) Whether `msg.sender` has the "Administration" or "Root" permission in domain `2`
77+
2) Whether the domain of action (in this case domain `5`) is indeed a child of the permission domain `2`, by checking that the second item in the `childSkillIndex` matches the local skill associated with the domain, whatever that may be.
7378

74-
Note: Within `ColonyAuthority.sol` you will see this role implemented as both`Architecture` and `ArchitectureSubdomain` roles. This is in order to prohibit an architect from modifying the domain in which the role was given (which would allow them to, for example, remove their co-architect's role). Architects may alter permissions in sub-domains only.
79+
Note: Functions authorized by the "Architecture" role check to see that the domain is strictly a child of the permission domain exclusively (not the permission domain itself). Within `ColonyAuthority.sol` you will see this role implemented as both`Architecture` and `ArchitectureSubdomain` roles. This is in order to prohibit an architect from modifying the domain in which the role was given (which would allow them to, for example, remove their co-architect's role). Architects may alter permissions in sub-domains only.

0 commit comments

Comments
 (0)