From 377c505033fb555266df611e95cc285dacb7de35 Mon Sep 17 00:00:00 2001 From: "jan.kozlowski" Date: Tue, 26 Nov 2024 17:00:31 +0100 Subject: [PATCH] handle path prefix in paths --- .../listeners/filters/JwtFilterFactory.kt | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/JwtFilterFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/JwtFilterFactory.kt index b5ee3bce7..cd3bb2e27 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/JwtFilterFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/JwtFilterFactory.kt @@ -132,17 +132,20 @@ class JwtFilterFactory( methods: Set, providers: MutableSet ): RequirementRule { - val pathMatching = RouteMatch.newBuilder().setPathMatchPolicy( - TypedExtensionConfig.newBuilder() - .setName("envoy.path.match.uri_template.uri_template_matcher") - .setTypedConfig( - Any.pack( - UriTemplateMatchConfig.newBuilder() - .setPathTemplate(pathGlobPattern) - .build() - ) - ).build() - ) + + val pathMatching = + if (pathGlobPattern.matches(Regex("^[^*]*[^*/]\\*$"))) RouteMatch.newBuilder().setPrefix(pathGlobPattern) + else RouteMatch.newBuilder().setPathMatchPolicy( + TypedExtensionConfig.newBuilder() + .setName("envoy.path.match.uri_template.uri_template_matcher") + .setTypedConfig( + Any.pack( + UriTemplateMatchConfig.newBuilder() + .setPathTemplate(pathGlobPattern) + .build() + ) + ).build() + ) if (methods.isNotEmpty()) { pathMatching.addHeaders(createHeaderMatcherBuilder(methods)) }