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

WIP: Constraints #233

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

WIP: Constraints #233

wants to merge 2 commits into from

Conversation

Cerfoglg
Copy link
Collaborator

Proposed changes

Describe the big picture of your changes here to communicate to the
maintainers why we should accept this pull request.
If it fixes a bug or resolves a feature request, be sure to link to
that issue.

Types of changes

What types of changes does your code introduce to the project: Put
an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing
    functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after
creating the PR. If you're unsure about any of them, don't hesitate to
ask. We're here to help! This is simply a reminder of what we are going
to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the Contributor License Agreement
  • I have updated the RELEASE NOTES
  • I have added tests that prove my fix is effective or that my
    feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in
    downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion
by explaining why you chose the solution you did and what alternatives
you considered, etc...

@Cerfoglg Cerfoglg requested a review from c0c0n3 May 24, 2023 07:39
@Cerfoglg Cerfoglg self-assigned this May 24, 2023
@github-actions
Copy link
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️

@c0c0n3 c0c0n3 marked this pull request as draft May 26, 2023 14:24
Copy link
Member

@c0c0n3 c0c0n3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cerfoglg great start thanks so much for this. I've commented on some bits of the code where I think the current approach could be hard to extend. Not that we need to do anything fancy at the moment, this PR was meant to explore the solution space which IMO it accomplishes pretty well. So my comments are only meant to highlight that it could be hard for us to implement generic constraints with the current architecture.

In general, I think it'd be hard to support anything else than plain constraints. E.g. think recursion, needed to support arbitrary nested constraints. Also in general, I think it'd be hard to implement (a useful enough subset of) ODRL

Thoughts?

current_path[2] == "entities"
current_path[3] == entry.resource
constraints := split(entry.constraint, " ")
constraints[0] == "acl-oc:ResourceName"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how would we use this in teadal? every API would need to have its own rego file w/ a path_matches_policy definition I suppose. That's fair enough, but then we'd have to duplicate the constraints logic in each and every file? also, what if I want to check request fields (e.g. method) or data fields in the JSON payload in the case of a POST?

current_path[1] == "v2"
current_path[2] == "entities"
current_path[3] == entry.resource
constraints := split(entry.constraint, " ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there's extra whitespace in the constraint? e.g. " > 5 "

@@ -0,0 +1,31 @@
package envoy.authz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, but what about e.g. boolean operators? e.g. what would I do if I wanted to express a constraint like (x < 5 && x > 10) || x > 20...

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

Successfully merging this pull request may close these issues.

2 participants