-
Notifications
You must be signed in to change notification settings - Fork 0
Add in_group and has_attribute policy functions #2
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
Conversation
This PR adds two policy functions. 1. in_group checks whether an Abbey user's identity is within a group 2. has_attribute checks whether an Abbey user has a custom attribute with a given value
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.
Requesting 3 changes. 2 are in review comments. Third is to add tests. See examples from prior PR: #1.
src/abbey/functions/in_group.rego
Outdated
import future.keywords.in | ||
|
||
in_group(group_name) := true if { | ||
some group in data.system.abbey.group_memberships |
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.
@Koshroy-Abbey why the extra variable instead of group_name in data.system.abbey.group_memberships
?
|
||
import future.keywords.if | ||
|
||
has_attribute(name, value) := true if { |
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.
Please add code comment to document what this function is supposed to be doing. Same for other functions.
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.
LGTM.
Some nits, but looks good. Also, as a separate PR, would be good to add in GH Actions for CI check on the tests. https://www.openpolicyagent.org/docs/latest/policy-testing/
|
||
import future.keywords.if | ||
|
||
# Function which checks whether a user has a given attribute |
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.
nit: Add a period to show this is a complete thought and the new sentence (on the next line) begins.
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.
Same nits for other code comments.
This PR adds two policy functions.
in_group checks whether an Abbey user's identity is within a group
has_attribute checks whether an Abbey user has a custom attribute with a given value