As said in the title, is there a way to add application users in Thorntail WilFly server, much like you would do with "add-user.sh -a" script in the full server distribution?
I understand you can provide an external configuration file to Thorntail but that seems a bit of overhead just for specifying where users are located.
Thanks
2 回答
从概念的角度来看,Thomas Herzog 的回答非常好——我特别同意使用外部 Keycloak 保护应用程序,可能在 MicroProfile JWT 的帮助下。如果您决定不这样做,我将提供几点。
您可以直接在 中定义用户project-defaults.yml
,如下所示:
thorntail:
management:
security-realms:
ApplicationRealm:
in-memory-authentication:
users:
bob:
password: tacos!
in-memory-authorization:
users:
bob:
roles:
- admin
该project-defaults.yml
文件不必在应用程序外部,您可以直接将其构建到其中。src/main/resources
通常,在您的源代码中,该文件将位于-thorntail.jar
. 当然,它可以是外部的,如果这不是一次性原型或测试,那么像这样的敏感数据应该是外部的。
您还可以使用.properties
WildFly 中的文件:
thorntail:
management:
security-realms:
ApplicationRealm:
properties-authentication:
path: .../path/to/application-users.properties
properties-authorization:
path: .../path/to/application-roles.properties
这取决于你需要什么用户?Thorntail 创建独立的微服务,这与 Wildfly 服务器中的托管应用程序不同。
thorntail中有管理控制台吗?
是的,有,但我从未使用过它。
https://docs.thorntail.io/2.2.0.Final/#_management
https://docs.thorntail.io/2.2.0.Final/#_management_console
您可能可以在那里创建的用户不应该是持久的,因为没有像您习惯使用独立的 wildfly-server 安装那样安装 wildfly-server,它全部打包在 jar 中。微服务在部署后不再需要配置,至少不需要这样。
如何保护我的应用程序?
我建议通过 keycloak 使用外部用户管理,它通过 keycloak 部分集成在 thorntail 中。使用 keycloak 部分,您可以在 web.xml 中为端点定义安全约束。
https://docs.thorntail.io/2.2.0.Final/#_keycloak
另一种方法是使用为您的微服务提供 JAAS 支持的安全部分。
https://docs.thorntail.io/2.2.0.Final/#_security
配置是通过 thorntail 特定的 project-defaults.yml 配置文件完成的,您可以在其中通过 YAML 配置分数。
什么是刺尾分数?
thorntail 部分类似于带有 spring 的 spring boot 启动依赖项,其中该部分为开发提供 API 并将实现和集成捆绑到 thorntail 中。这部分实际上是一个 jboss 模块,它在重新打包阶段被打包到独立的微服务中。
我在哪里可以找到示例?
有关如何在 thorntail 中使用安全性的示例,请参阅以下链接。你应该看看他们。
https://github.com/thorntail/thorntail-examples/tree/master/security
查看src/main/resources/projects-defaults.yml,其中包含 thorntail 分数的配置和定义使用分数的pom.xml 。