簡體   English   中英

Wildfly 17 Elytron:使用EAR中的類進行服務器端身份驗證

[英]Wildfly 17 Elytron: server side authentication with classes from 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並且必須實現Map<String, Object> authenticate(String, String) ,該方法使用usernamepassword調用。

我猜您必須返回一個包含用戶所屬的所有rolesgroups的映射,或者如果憑據無效,則返回null

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM