Skip to content
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

Built-in conditions: user_is X, is_read, client_ip #1

Open
rsinger86 opened this issue May 5, 2019 · 0 comments
Open

Built-in conditions: user_is X, is_read, client_ip #1

rsinger86 opened this issue May 5, 2019 · 0 comments

Comments

@rsinger86
Copy link
Owner

rsinger86 commented May 5, 2019

Rather than having to always write a custom method when a statement needs to examine the contextual details of the request/user/object, some built-in conditions could be provided. I think the syntax would be to use a dictionary for these built-in checks, and have string values continue to reference a custom method on the policy.

{
   "action": "*",
   "principal": "*",
   "condition": { "<condition_type>": "<value_option>" }
}

There could be three to start with:

{
   "action": "*",
   "principal": "*",
   "condition": { "is_read": false }  # whether the request method is HEAD, GET or OPTIONS
}

{
   "action": "*",
   "principal": "*",
   "condition": { "client_ip": "203.0.113.0/24" }  # whether the requester's IP matches 
}

{
   "action": "*",
   "principal": "*",
   "condition": { "user_is": "owner" }  # Whether a field on the object instance (from view.get_object()) is equal to the request user
}

{
   "action": "*",
   "principal": "*",
   "condition": { "is_authenticated": True } # whether the user is authenticated
}

AWS IAM provides a much more feature-rich version of this: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html

However, since we have the flexibility to write custom methods, I think it's best to only cover most common and simple cases with built-in conditions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant