0

我正在尝试将项目从使用 Legacy Security 迁移到使用 Elytron Security。

到目前为止(旧版),身份验证工作所需的全部内容是在 Subsystems -> Security 中创建一个具有正确名称的安全域(“ referencesApplicationDomain ”)。

我的 web.xml:

<web-app ..>
    ...
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>referencesApplicationDomain</realm-name>
    </login-config>
    <security-role>
        <role-name>authenticated</role-name>
    </security-role>
    <security-role>
        <role-name>anonymous</role-name>
    </security-role>
    <security-constraint>
        <web-resource-collection>
            ....
        </web-resource-collection>
    </security-constraint>
        <auth-constraint>
            <role-name>authenticated</role-name>
        </auth-constraint>
    </security-constraint>
...
</web-app>

我的 jboss-web.xml:

<jboss-web ...>
    <deny-uncovered-http-methods>false</deny-uncovered-http-methods>
    <context-root>/references</context-root>
    <security-domain>referencesApplicationDomain</security-domain>
</jboss-web>

当然,我们的想法是让我们的应用程序只与 Elytron 一起工作。

但是,问题是,我看不到在 Elytron 中创建安全域的位置。

我按照Wildfly Elytron 文档使用 jboss-cli 创建了安全域和 http 工厂。

当我签入 jboss-cli 时,我看到安全域已创建。

但是,当我尝试启动 Wildfly 服务器时,出现以下错误:

"WFLYCTL0412: Required services that are not installed:" => [
        "jboss.security.security-domain.referencesApplicationDomain"
    ],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => [
        "jboss.deployment.unit.\"references-war-1.0.11-SNAPSHOT.war\".component.BranchService.CREATE is missing [jboss.security.security-domain.java:/jaas/referencesApplicationDomain]"
    ]

似乎 jboss 正试图在旧的安全子系统而不是 Elytron 中找到安全域。但我不明白为什么?

小备注:我想使用ApplicaationRealm,来使用jboss配置文件里面的用户和组。

4

1 回答 1

0

事实证明,Elytron 不需要这样做(事实上,它仅适用于 Legacy)。所以解决方案只是从 xml 文件中删除这些:

web.xml

<web-app ..>
    ...
    <login-config>
        <auth-method>BASIC</auth-method>
        <!--<realm-name>referencesApplicationDomain</realm-name>-->
    </login-config>
</web-app>

jboss-web.xml:

<jboss-web ...>
    <deny-uncovered-http-methods>false</deny-uncovered-http-methods>
    <context-root>/references</context-root>
    <!--<security-domain>referencesApplicationDomain</security-domain>-->
</jboss-web>

这是可行的,因为默认情况下,Wildlfly 的 undertow 系统使用 ApplicationRealm 作为默认安全域。您可以通过查看您的standalone.xml 来验证这一点。

于 2019-01-18T12:32:42.237 回答