authentication - Wildfly 17 Elytron:使用 EAR 类进行服务器端身份验证
问题描述
我们计划从 Picketbox 迁移到 Elytron 并面临以下问题:
使用 Picketbox,自定义登录模块可以使用(甚至可以驻留在)部署模块(例如 wildfly/standalone/deployments 中的 EAR)的功能在服务器端实现身份验证:
<subsystem xmlns="urn:jboss:domain:security:2.0">
<security-domains>
...
<security-domain name="MyDomain" cache-type="default">
<authentication>
<login-module name="MyLoginModule" code="de.example.wildfly.MyLoginModule" flag="required" module="deployment.de.example.wildfly.login"/>
</authentication>
</security-domain>
我的第一次尝试是在 Elytron 中使用自定义领域。但据我了解,自定义领域需要是“静态”模块(意味着它位于 wildfly/modules/... 下),因此无法访问“动态”部署的模块(请参阅https://developer.jboss .org/message/984198#984198)。
<subsystem xmlns="urn:wildfly:elytron:7.0" final-providers="combined-providers" disallowed-providers="OracleUcrypto">
...
<security-domains>
<security-domain name="MyDomain" default-realm="MyRealm" permission-mapper="default-permission-mapper">
<realm name="MyRealm" role-decoder="from-roles-attribute" />
</security-domain>
</security-domains>
<security-realms>
...
<custom-realm name="MyRealm" module="de.example.wildfly.login" class-name="de.example.wildfly.MyCustomRealm" />
(我省略了更多的安全域配置)
当我尝试在 MyCustomRealm 中加载 Spring 上下文(位于 EAR 中以便从 EAR 访问一些自定义类)时,我收到以下错误:
org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath:applicationContext-appServerBase.xml], factory key [applicationContextEjb]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext-appServerBase.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext-appServerBase.xml] cannot be opened because it does not exist
这并不奇怪,因为我的领域不依赖于应用程序上下文所在的耳朵或其中的任何罐子。
如何使用 Elytron 中部署模块 (EAR) 中的类在服务器端自定义身份验证(特别是针对 EJB 调用)?
解决方案
也许https://github.com/AntonYudin/wildfly-securityrealm-ejb正是您正在寻找的。它创建了一个SecurityRealm
可以使用与您的应用程序一起部署的 EJB 的地址进行配置的地址。
EJB 必须Stateless
并且必须实现使用 a和 aMap<String, Object> authenticate(String, String)
调用的方法。username
password
我猜你必须返回一个包含所有用户的地图,roles
或者groups
如果null
凭据无效。
推荐阅读
- java - Google Cloud Objectify - 保存实体时出错
- typescript - 使用装饰器正确扩展构造函数
- amazon-web-services - 推荐人政策:no-referrer-when-downgrade fetch api - AWS API
- javascript - 嵌套条件下的多个 .innerHTML
- apache-kafka - Kafka Stream固定窗口不按键分组
- python - Python:当存在多个列表时打印非空列表
- android - 文本视图未显示在滚动视图中,在 Android 模拟器中
- python - 软件包已安装但在 Python 中出现类似 No module name "plspm" 的错误?
- azure - 翻译文本 API 端点返回 404 代码,消息“找不到资源”作为 JSON 对象
- c++ - 是否有相当于 __gnu_cxx::__freeres 钩子的 clang++/libc++ ?