generated from vsoch/docsy-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ACL WIP #66
Draft
Lory1990
wants to merge
2
commits into
rond-authz:master
Choose a base branch
from
Lory1990:feature/acl-doc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
ACL WIP #66
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -436,6 +436,10 @@ This collection contains all the bindings between users or groups of users and a | |
"roles": [ | ||
"TLRoleId" | ||
], | ||
"permissions": [ | ||
"canDoStuff", | ||
"canDoActions", | ||
], | ||
"resource": { | ||
"resourceId": "project1", | ||
"resourceType": "project" | ||
|
@@ -455,3 +459,77 @@ has_read_permission { | |
userRoles.permissions[_] == "can_read" | ||
} | ||
``` | ||
|
||
## ACL Data Model | ||
|
||
You can use a the [binding association collection](#bindings) to represent a ACL data model, in this case you could only use the following fields: | ||
|
||
- **bindingId** (string, required): **_unique_** id of the binding | ||
- **subject** (string array): list of user ids, _usually contains only one subject_ | ||
- **permissions**: (strings) list of permissions or grants (i.e. `canRead`, `canWrite`, ....) | ||
- **resource**: (object) with properties `type` and `id`. | ||
|
||
```json | ||
[ | ||
{ | ||
"bindingId": "bindingUniqueIdentifier", | ||
"subjects": [ | ||
"bob" | ||
], | ||
"permissions": [ | ||
"canDoStuff", | ||
"canDoActions", | ||
], | ||
"resource": { | ||
"resourceId": "project1", | ||
"resourceType": "project" | ||
} | ||
} | ||
] | ||
``` | ||
|
||
### ACL Policies for permission evaluation | ||
|
||
Let's check, in the following example, if the user have the permission to read some data: | ||
```rego | ||
package policies | ||
|
||
has_read_permission { | ||
user := input.user | ||
user.permissions[_] == "canRead" | ||
} | ||
|
||
has_read_permission_for_given_company { | ||
companyId := input.request.query["companyId"][0] | ||
user := input.user[_].resource == { resourceType: "company", resourceId: companyId } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fredmaggiowski really not sure about that |
||
user.permissions[_] == "canRead" | ||
} | ||
``` | ||
|
||
## Custom permission evaluation | ||
|
||
If you have a csutom permission model, different from ACL or RBAC you can use the built-in functions [find_one](/docs/policy-integration#custom-built-ins) and [find_many](/docs/policy-integration#custom-built-ins) function | ||
|
||
For example if you have a model like this: | ||
``` json | ||
[ | ||
{ | ||
"userId": "user01", | ||
"grants": [ | ||
"grantA", | ||
"grantB" | ||
] | ||
} | ||
] | ||
``` | ||
|
||
you can use this query to check permissions: | ||
|
||
```rego | ||
package policies | ||
|
||
has_read_permission { | ||
user := find_one("users", { "userId": input.user.id }) | ||
user.grants[_] == "grantB" | ||
} | ||
``` |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep this example free of permissions to avoid confusion, do you find it more clear with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me is essential to declare all the capabilities of RBAC so that there is no misunderstanding