使用给定的URL路径或使用keycloak rest admin api基于正则表达式模式获取资源

问题描述 投票:0回答:1

是否有一种方法可以使用rest admin api获取给定部分URL的资源ID?

下面是我呼叫的端点-http://localhost:8180/auth/realms/quickstart-serv-springboot/authz/protection/resource_set?uri=/wb/customer以获取资源ID。

我想知道是否可以在uri的查询字符串中传递通配符,以便它返回资源ID。例如-http://localhost:8180/auth/realms/quickstart-serv-springboot/authz/protection/resource_set?uri=/wb/customer/*http://localhost:8180/auth/realms/quickstart-serv-springboot/authz/protection/resource_set?uri=/wb/cust*或提供正则表达式模式以获取匹配的资源ID。

Thx

rest api authorization keycloak
1个回答
0
投票

从源代码来看,它似乎可以以其他方式工作:

  1. [第一个Keycloak尝试找到完全匹配的内容
  2. 然后,如果找不到匹配项,并且有参数“ matchingUri = true”,它将尝试通过模式匹配来查找资源。

我没有检查,但建议向您的查询中添加“ matchingUri = true”,然后重试。

还要注意,不支持复杂的模式。 Keycloak Documentation说:

Currently a very basic logic for path matching is supported. Examples of valid paths are:
Wildcards: /*
Suffix: /*.html
Sub-paths: /path/*
Path parameters: /resource/{id}
Exact match: /resource
Patterns: /{version}/resource, /api/{version}/resource, /api/{version}/resource/*
© www.soinside.com 2019 - 2024. All rights reserved.