OPA球模式不包括在其路径中具有特定部分的URL

发布于 2025-02-07 04:33:50 字数 662 浏览 3 评论 0原文

我正在尝试写一个 opa glob tatter 没有字符串/Special-part/{whywhing}/callback的URL路径,其中{whywhing}是一个路径参数,此路径可能有可能具有字符之前和之后。

我的车轮旋转了很多,但我已经一无所获(现在!),所以我想知道是否有人可以帮助我。

以下是一些匹配/不匹配的案例:

// match
/signup/activate-account
/v1/signup/activate-account
/v2/signup/activate-account
/signup/hello/world
/signup/hello-world
/something/else

// no match
/special-part/abc123/callback
/special-part/xyz/callback
/v1/special-part/abc123/callback
/v2/special-part/abc123/callback/123

I'm trying to write an OPA glob pattern that matches any URL path that does NOT have the string /special-part/{whatever}/callback in it, where {whatever} is a path parameter, and this path can potentially have characters before and after it.

I've spun my wheels a good deal and I've gotten nowhere (yet!), so I was wondering if someone could help me out.

Here are some match/no-match cases:

// match
/signup/activate-account
/v1/signup/activate-account
/v2/signup/activate-account
/signup/hello/world
/signup/hello-world
/something/else

// no match
/special-part/abc123/callback
/special-part/xyz/callback
/v1/special-part/abc123/callback
/v2/special-part/abc123/callback/123

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒尘 2025-02-14 04:33:50

也许是这样的:

package test

match(path) {
    glob.match("**/special-part/*/callback", [], path)
}

match(path) {
    glob.match("**/special-part/*/callback/**", [], path)
}

matches[path] {
    path := input.paths[_]
    not match(path)
}

可在

Something like this perhaps:

package test

match(path) {
    glob.match("**/special-part/*/callback", [], path)
}

match(path) {
    glob.match("**/special-part/*/callback/**", [], path)
}

matches[path] {
    path := input.paths[_]
    not match(path)
}

Executable on the Rego playground

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文