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

rbac: add uri_template for path matching #31447

Merged
merged 42 commits into from
Feb 1, 2024

Conversation

kozjan
Copy link
Contributor

@kozjan kozjan commented Dec 19, 2023

Commit Message: rbac: add uri_template for path matching
Additional Description: Added uri_template with envoy.path.match extension category to allow matching with URI templates in RBAC.
Risk Level: low
Testing: unit, integration
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
Fixes #30724

Copy link

Hi @kozjan, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #31447 was opened by kozjan.

see: more, trace.

Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @htuch
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #31447 was opened by kozjan.

see: more, trace.

@@ -358,6 +362,9 @@ message Principal {
// Identifies the principal using a filter state object.
type.matcher.v3.FilterStateMatcher filter_state = 12;

// Glob URL path matching.
envoy.extensions.path.match.uri_template.v3.UriTemplateMatchConfig glob_path = 13;
Copy link
Member

@htuch htuch Dec 20, 2023

Choose a reason for hiding this comment

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

@envoyproxy/api-shepherds I'm wondering if type.matcher.v3.PathMatcher should include

// [#extension-category: envoy.path.match]
?

Copy link
Member

Choose a reason for hiding this comment

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

I.e. allow URI template matcher to be plugged in. In any case, we should not be referencing the extension config directly here and instead should have something like

// [#extension-category: envoy.path.match]
if we don't end up putting it inside PathMatcher.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey, I'm going on holiday so I will rework it once I'm back, probably next year

@adisuissa
Copy link
Contributor

/wait


// Glob URL path matching.
// [#extension-category: envoy.rbac.matchers]
core.v3.TypedExtensionConfig glob_path = 13;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think i like naming this glob_path given that it possible covers more features than just globbing, that's why it's actually called uri_template 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will replace glob everywhere with uri_template.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@kozjan
Copy link
Contributor Author

kozjan commented Jan 11, 2024

I tried to push with prepush hooks, but shellcheck doesn't work on Mac i guess:

ERROR: /private/var/tmp/_bazel_jan.kozlowski/a20ce50f1167d001f45ad8fee633e1f8/external/com_github_aignas_rules_shellcheck/BUILD.bazel:25:6: configurable attribute "actual" in @com_github_aignas_rules_shellcheck//:shellcheck doesn't match this configuration: binaries for your platform could not be found

so i fixed everything that was before the shellcheck, but i'm not sure if that's all

@kozjan
Copy link
Contributor Author

kozjan commented Jan 11, 2024

don't really see why some checks failed, envoy/prechecks build result look fine yet it failed, and in envoy/windows do not see any specific errors, so running a retest
/retest

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Jan 22, 2024
Copy link

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @htuch

🐱

Caused by: #31447 was synchronize by kozjan.

see: more, trace.

@@ -270,6 +270,10 @@ message Permission {
// Extension for configuring custom matchers for RBAC.
// [#extension-category: envoy.rbac.matchers]
core.v3.TypedExtensionConfig matcher = 12;

// URI template path matching.
// [#extension-category: envoy.rbac.uri_template]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// [#extension-category: envoy.rbac.uri_template]
// [#extension-category: envoy.path.match]

@@ -1247,6 +1248,7 @@ REPOSITORY_LOCATIONS_SPEC = dict(
"envoy.filters.network.wasm",
"envoy.stat_sinks.wasm",
"envoy.rbac.matchers.upstream_ip_port",
"envoy.rbac.uri_template.uri_template_matcher",
Copy link
Member

Choose a reason for hiding this comment

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

I don't get why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it because of an error message in Envoy/Prechecks :

Dependency validation failed, please check metadata in bazel/repository_locations.bzl
Extension envoy.rbac.matchers.uri_template depends on com_github_google_flatbuffers but com_github_google_flatbuffers does not list envoy.rbac.matchers.uri_template in its allowlist

However, it seems to me as if the checks are bugged and checkout older code, because when I run it locally I don't get this error know - I think envoy.rbac.matchers.uri_template value comes from source/extensions/extensions_build_config.bzl

# RBAC URI template matcher
#

"envoy.rbac.uri_template.uri_template_matcher": "//source/extensions/filters/common/rbac/uri_template:uri_template_lib",
Copy link
Member

Choose a reason for hiding this comment

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

There's no need to declare a new matcher here, we can use the existing URI template path matcher extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly, this is necessary if I want to use a different factory for rbac, the one that was originally implemented with URI template path matcher returns absl::StatusOr<Router::PathMatcherSharedPtr>, while the type needed in RBAC is MatcherConstSharedPtr

would it be better to use the same factory, but then wrap the PathMatcherSharedPtr into MatcherConstSharedPtr?

@@ -194,7 +194,7 @@ message Policy {
}

// Permission defines an action (or actions) that a principal can take.
// [#next-free-field: 13]
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, also made some small changes to tests and unnecessary null check, since it works the same either way

Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>

Signed-off-by: kozjan <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>

Signed-off-by: kozjan <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
This reverts commit 1db41e8.

Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
@kozjan kozjan changed the title rbac: add url glob matching rbac: add uri_template for path matching Jan 24, 2024
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
@kozjan
Copy link
Contributor Author

kozjan commented Jan 25, 2024

/retest

Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
@kozjan
Copy link
Contributor Author

kozjan commented Jan 25, 2024

don't know what to do with Envoy/Windows: https://github.com/envoyproxy/envoy/actions/runs/7651824181/job/20850377753#step:8:21416
looks like some Azure problem to me, hoped rerunning would fix it but nothing changed

@phlax
Copy link
Member

phlax commented Jan 25, 2024

looks like some Azure problem to me, hoped rerunning would fix it but nothing changed

its a backend (RBE) issue - its known but infrequent generally, and not obvious why its happening

ive kicked the CI again

@phlax
Copy link
Member

phlax commented Jan 25, 2024

@kozjan i think its failing because your branch is far behind

can you merge main please

@phlax
Copy link
Member

phlax commented Jan 25, 2024

hmm - the more i think about it the more im wondering why that would matter - and it looks like you have merged main relatively recently - and also it was passing previously

a bit of a mystery tbh - this is now failing every time, no other ci runs are mostly passing (EDITED: i saw another similar today - will follow up)

i think we may have some misbehaving backend auth server cc @adisuissa

htuch
htuch previously approved these changes Jan 25, 2024
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM for when CI passes.

@kozjan
Copy link
Contributor Author

kozjan commented Jan 26, 2024

/retest
it never works :(

Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
@phlax
Copy link
Member

phlax commented Jan 26, 2024

#32044

Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
@kozjan
Copy link
Contributor Author

kozjan commented Jan 30, 2024

hey, it passed today - do I have to contact someone for the second review?

Signed-off-by: kozjan <138656232+kozjan@users.noreply.github.com>
Signed-off-by: jan.kozlowski <jan.kozlowski@allegro.com>
@repokitteh-read-only repokitteh-read-only bot removed the api label Feb 1, 2024
@htuch htuch merged commit 20c7368 into envoyproxy:main Feb 1, 2024
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps Approval required for changes to Envoy's external dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rbac: url fragment matchers
5 participants