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

Add policy definitions and attachments to request context, change pol… #141

Merged
merged 2 commits into from
Jun 22, 2020

Conversation

tomeresk
Copy link
Contributor

…icy executor to use them from context instead of directly from repo

…icy executor to use them from context instead of directly from repo
@tomeresk tomeresk requested a review from a team June 18, 2020 12:02
Copy link
Contributor

@AvivRubys AvivRubys left a comment

Choose a reason for hiding this comment

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

LGTM Generally, commented on some small things

@@ -3,6 +3,7 @@ export interface ResourceGroup {
upstreams: Upstream[];
upstreamClientCredentials: UpstreamClientCredentials[];
policies: Policy[];
policyAttachments?: PolicyAttachments;
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave a comment about this being a "runtime-only" property? Since the rest are assumed to always exist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Come to think of it, it will be populated on the first call to fetchLatest same as the others, and will always exist (empty object if there are no attachments at all, same as the other fields here).
All of them are actually runtime-only properties representing what is stored in the underlying repository, with the only different between the attachments and the other properties being that the other properties are all stored in one file and the attachments are stored in other files.

However, when using this interface we don't really care that it is stored in other files than the other properties, so I'm actually leaning towards removing the ? here and treating it like any other property.

One key difference is that the contents of this property are calculated based on the policies property and not created/updated directly by a user, but it only happens once when we save the policy and then saved this way in the repository, so I would still say we should treat it like the other properties here (but I will add a comment to highlight this difference)

upstreams: [],
upstreamClientCredentials: [],
policies: [],
policyAttachments: {},
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't policyAttachments not be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is technically there because of the way we currently manage the bucket mocking, but I'll remove it to be in line with the tests in update-resources.spec (since this is not something we really test here)

@@ -17,13 +18,29 @@ export function mockResourceBucket(initialValue: ResourceGroup, initialPolicyFil
.reply(200, (_, body) => {
value.current = JSON.parse(body as string) as ResourceGroup;
})
.get(new RegExp(`/${bucketName!}\?.*prefix=${encodeURIComponent(policiesKeyPrefix!)}.*`))
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps a comment or some constants could make this more readable, because right now it's a bit hard :X

@tomeresk tomeresk force-pushed the authz_move_policy_details_to_context branch from 9729e3c to 2e656a9 Compare June 18, 2020 16:08
@tomeresk tomeresk merged commit 48fa353 into authorization Jun 22, 2020
@tomeresk tomeresk deleted the authz_move_policy_details_to_context branch June 22, 2020 13:01
AleF83 added a commit that referenced this pull request Jul 2, 2020
* Authorization - fully implemented registry part (#133)

This includes:
Create/update policy resource
Attachments support for policy resource (with support for writing the attachment to both s3 and fs repositories)
Opa policy type implementation, including compiling rego code to wasm and adding that to the policy as an attachment

* Authorization gateway - basic features (#138)

implemented full flow with basic features
Implement local policy attachment caching for all resource repositories

* Add policy definitions and attachments to request context, change pol… (#141)

* Add policy definitions and attachments to request context, change policy executor to use them from context instead of directly from repo

* PR comments

* allow jwt in param injection (policy authorization can use it through args) (#144)

* Support for policy query (#143)

* Policy directive - accept only a single policy (#146)

* change policy directive to accept only a single policy

* Refactored PolicyExecutor API to only expose static methods

Co-authored-by: Tomer Eskenazi <tomeresk@gmail.com>
AleF83 pushed a commit that referenced this pull request Jul 2, 2020
#141)

* Add policy definitions and attachments to request context, change policy executor to use them from context instead of directly from repo

* PR comments
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.

3 participants