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 docs and examples for path templating #3162

Merged
merged 5 commits into from
Apr 22, 2024

Conversation

jaellio
Copy link
Contributor

@jaellio jaellio commented Apr 18, 2024

@istio-testing
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@istio-testing istio-testing added do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 18, 2024
@jaellio
Copy link
Contributor Author

jaellio commented Apr 18, 2024

/test all

@@ -521,6 +521,18 @@ message Operation {
// for details of the path normalization.
// For gRPC service, this will be the fully-qualified name in the form of `/package.service/method`.
//
// If a path in the list contains the `{*}` or `{**}` operator, it will be interpreted as an [Envoy Uri Template](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/path/match/uri_template/v3/uri_template_match.proto).
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this technically a backward incompatible change ? I can have path /a/* or /a/{foo} - I don't think * or {} were forbidden before. After the change - they'll no longer match literally but use the template.

Also: do we have the same model for routing ? Would be really bad for them to do things differently.

I would be concerned if authz and routing diverge - in particular in the new K8SGateway world where targetRef could be used with HttpRoutes for performance/scale ( in which case path would presumably be empty ). Not entirely clear if allowing namespaces to set authz rules in shared gateways at listener level is even secure, we don't typically do security reviews for our security features...

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not against using path matches - I think it's a great feature. But it should be reviewed in the broader context - including how we can use it with HttpRoute ( is it allowed ? Do we need to extend the spec ), and than look at how routing and authz work together - both in K8SGateway/Ambient mode and in Istio v1 mode. Adding new features that only work with Istio v1 as 'extension' may not be worth it unless we are sure we understand the security implications.

Copy link
Member

Choose a reason for hiding this comment

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

{} are not valid characters in a URL which I think makes it viable

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to @howardjohn the fact that {} are not valid URL characters according to the spec means that this change isn't breaking any active policies today. With respect to the security model, this is actually a fairly narrow diff compared to our existing path matching features

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, Im not worried about collision for '{}' and there is no conflict with out path normalization so I think this is OK.

I guess there is a technical back-compat issue that if folks wrote rules that used '{}' that ALLOWED traffic, those rules would be dormant and now would start matching something. I think this is so esoteric as to be a non-concern.

I do agree with Costin we should look at this for routing and bring those into alignment. They were already misaligned to some extent anyway (routing has regex but authz does not for instance). I generally prefer UriTemplate/glob over regex for paths so Im definitely in favor of pushing on that.

Here is the list of follow-on work for UriTemplate that we should open tracking issue for

  • routing
  • attribute extraction via named sections into processing context
  • SPIFFE SAN matching improvements (they are URIs after all)
  • Query param matching in Authz

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to the follow up action items of doing this for routing. @jaellio or myself will open the tracking issues

//
// Examples:
// - `/foo/{*}` matches `/foo/bar` but not `/foo/bar/baz`
// - `/foo/{*}.txt` matches `/foo/bar.txt` but not `/foo/baz/bar.txt`
Copy link
Member

Choose a reason for hiding this comment

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

This example is not consistent with the claim that we "matches a single path segment". If its a path segment I would think you can only have .../{*} or .../{*}/....

This is more like a "glob that cannot extend beyond a path segment"?

What does /foo/{*}.txt mean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll clarify.

/foo/{*}.txt matches the glob until the specified path extension. Right now, this is supported. I can add an additional test case for foo/{*}.txt to see if it matches on /foo/bar.tmp.txt for example.

@jaellio jaellio added the release-notes-none Indicates a PR that does not require release notes. label Apr 18, 2024
@costinm
Copy link
Contributor

costinm commented Apr 18, 2024 via email

@costinm
Copy link
Contributor

costinm commented Apr 18, 2024 via email

@jaellio jaellio marked this pull request as ready for review April 18, 2024 23:03
@jaellio jaellio requested a review from a team as a code owner April 18, 2024 23:03
@istio-testing istio-testing removed the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Apr 18, 2024
@costinm
Copy link
Contributor

costinm commented Apr 19, 2024 via email

Signed-off-by: Jackie Elliott <jaellio@microsoft.com>
Signed-off-by: Jackie Elliott <jaellio@microsoft.com>
Signed-off-by: Jackie Elliott <jaellio@microsoft.com>
@costinm
Copy link
Contributor

costinm commented Apr 19, 2024 via email

Signed-off-by: Jackie Elliott <jaellio@microsoft.com>
@istio-testing istio-testing added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 19, 2024
policy.

Signed-off-by: Jackie Elliott <jaellio@microsoft.com>
@istio-testing istio-testing added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 19, 2024
Copy link
Contributor

@keithmattix keithmattix left a comment

Choose a reason for hiding this comment

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

LGTM - it's just docs, so more clarification can be added later if needed

@istio-testing istio-testing merged commit 5b08a31 into istio:master Apr 22, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants