即使在创建过程中选择 Oauth2 授权,
Jhipster 应用程序也没有 keycloak.json
文件。但是official Keycloak 文档告诉我们在 keycloak.json
中指定 policy-enforcer 属性。任何有关应在何处指定的线索都将受到高度赞赏。
我的application.yml
文件:-
security:
basic:
enabled: false
oauth2:
client:
access-token-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/token
user-authorization-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/auth
client-id: web_app
client-secret: web_app
client-authentication-scheme: form
scope: openid profile email
resource:
filter-order: 3
user-info-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/userinfo
token-info-uri: http://localhost:9080/auth/realms/jhipster/protocol/openid-connect/token/introspect
prefer-token-info: false
我的 keycloak.yml 和 app.yml 文件均未更改。
最佳答案
策略执行是 Keycloak specific :
Policy Enforcement Point (PEP) is a design pattern and as such you can implement it in different ways. Keycloak provides all the necessary means to implement PEPs for different platforms, environments, and programming languages. Keycloak Authorization Services presents a RESTful API, and leverages OAuth2 authorization capabilities for fine-grained authorization using a centralized authorization server.
Oauth2 规范中没有这样的功能。 Jhipster 根据 Oauth2 标准生成您的项目,您可以基于此进行 keycloak 集成,但无法使用其特定功能。为了让它工作,您需要使用 KC specific adapters并摆脱 Jhipster 的 Oauth2 自动配置。
其他解决方案可能涉及扩展 Jhipster 添加的代码(我相信它基于 Spring Security Oauth plugin ),以便使用此 KC 功能来扩展它。您需要自己编写敏感代码,所以我宁愿采用第一种方法。
关于jhipster - 如何在 jhipster 应用程序中为 keycloak 指定策略执行器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51036128/