gpt4 book ai didi

jhipster - 在 JHipster 4.10.0 中使用 Keycloak

转载 作者:行者123 更新时间:2023-12-01 08:33:30 25 4
gpt4 key购买 nike

我使用 Jhipster 生成器 v4.10.0 生成了新应用。

我想使用由 Keycloak 提供支持的 OAuth2,该 OAuth2 在单独的(它自己的)应用程序服务器中运行,供更多应用程序使用。这意味着,不在 Docker 中。

我根据http://www.jhipster.tech/security/设置'application.yml'.. 服务器、端口、clientId、clientSecret => 重建应用程序。

mvnw -Pprod package -DskipTests

SoapUi 测试的Keycloak 功能。它像往常一样返回带有标记的 JSON 对象。


在本地主机上使用 KEYCLOAK 进行开发

key 斗篷从 http://www.keycloak.org/downloads.html 下载 Keycloak 服务器您可以按照文档“入门”进行操作。

我的脚步

  • 在服务器位置解压 C:\Servers\Keycloak\
  • standalone.xml => 设置 port-offset: 10000 因为应用服务器在零上运行
  • cmd cd C:\Servers\Keycloak\bin
  • 运行standalone.bat
  • 打开浏览器http://localhost:18080/auth
  • 转到管理控制台
  • 创建新领域“jhipster”
  • 我使用用户联合来添加 LDAP 用户(同步所有用户),下一个选项是手动添加用户
  • 添加角色(JHipster 使用 ADMIN 和 USER、SYSTEM)或同步 LDAP 角色到 key 斗篷
  • 在这个新领域创建新客户

jhipster client setting不要忘记 Web 来源处的符号 +

  • 在 Credentials 中选择 Client ID 和 secret,生成 secret 并使用它在 application.yaml 文件中

最佳答案

@Mubasher 问题:

I deployed jhipster-app.war on WildFly10 application server. See standalone.xml setting below.

您可以添加新的扩展

<extension module="org.keycloak.keycloak-adapter-subsystem"/>

然后修改配置文件元素中的安​​全子系统。

<subsystem xmlns="urn:jboss:domain:security:1.2">
<security-domains>
<security-domain name="other" cache-type="default">
<authentication>
<login-module code="Remoting" flag="optional">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
<login-module code="RealmDirect" flag="required">
<module-option name="password-stacking" value="useFirstPass"/>
</login-module>
</authentication>
</security-domain>
<security-domain name="jboss-web-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<security-domain name="jboss-ejb-policy" cache-type="default">
<authorization>
<policy-module code="Delegating" flag="required"/>
</authorization>
</security-domain>
<security-domain name="jaspitest" cache-type="default">
<authentication-jaspi>
<login-module-stack name="dummy">
<login-module code="Dummy" flag="optional"/>
</login-module-stack>
<auth-module code="Dummy"/>
</authentication-jaspi>
</security-domain>
<security-domain name="keycloak">
<authentication>
<login-module code="org.keycloak.adapters.jboss.KeycloakLoginModule" flag="required"/>
</authentication>
</security-domain>
</security-domains>
</subsystem>

最后在 profile 元素的末尾提到这一点。

<subsystem xmlns="urn:jboss:domain:keycloak:1.1"/>

application-dev.yaml

我想你设法在这个配置文件中设置了数据库。所以,我只向您展示安全部分。根据您的 Keycloak 领域设置,请更改客户端 ID 和密码。

security:
basic:
enabled: false
oauth2:
client:
access-token-uri: http://localhost:18080/auth/realms/jhipster/protocol/openid-connect/token
user-authorization-uri: http://localhost:18080/auth/realms/jhipster/protocol/openid-connect/auth
client-id: jhipster
client-secret: e0ceb945-9b56-42d3-af1a-f68221adddec
client-authentication-scheme: form
scope: openid profile email
resource:
user-info-uri: http://localhost:18080/auth/realms/jhipster/protocol/openid-connect/userinfo
token-info-uri: http://localhost:18080/auth/realms/jhipster/protocol/openid-connect/token/introspect
prefer-token-info: false
use-resource-role-mappings: true

关于jhipster - 在 JHipster 4.10.0 中使用 Keycloak,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46826838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com