【问题标题】:Wildfly 17 Elytron: server side authentication with classes from EARWildfly 17 Elytron:使用 EAR 类的服务器端身份验证
【发布时间】:2019-11-04 02:40:49
【问题描述】:

我们计划从 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 调用)?

【问题讨论】:

    标签: authentication ejb wildfly elytron


    【解决方案1】:

    也许https://github.com/AntonYudin/wildfly-securityrealm-ejb 正是您要找的。 它会创建一个SecurityRealm,可以使用与您的应用程序一起部署的 EJB 的地址进行配置。

    EJB 必须是 Stateless 并且必须实现方法 Map&lt;String, Object&gt; authenticate(String, String),该方法使用 usernamepassword 调用。

    我猜你必须返回包含用户所属的所有rolesgroups 的地图,如果凭据无效,则返回null

    【讨论】:

    • 时间不多了,所以我们选择不迁移到 Elytron,而是继续使用 Picketbox。由于时间不够,我无法确认建议的解决方法是否真的有效,但我很确定它会。所以我接受这个答案是一个正确的答案,并在我们软件的下一个版本中记住它。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2022-06-13
    • 2021-11-19
    • 2018-02-26
    • 2011-11-04
    • 2019-05-01
    • 1970-01-01
    • 2020-04-22
    • 2012-08-28
    相关资源
    最近更新 更多