定义自定义 JAAS 上下文时,Websphere Liberty AdminCenter 登录不起作用

Websphere Liberty AdminCenter login does not work when custom JAAS context is defined

我是 WebSphere Liberty 配置文件的新手。我正在研究 17.0.0.4 版本。我想要实现的是为应用程序设置自定义 JAAS 登录设置。该应用程序在 WebSphere 8.5 上运行良好。

我已经从 IBM 知识中心审查了很多 link 相同的内容,但是使用 JAAS 自定义登录或使用 JAAS 自定义登录都得到了结果,但不是同时使用两者。对于 WebSphere 8.5,我们具有层次结构级别来决定将哪种身份验证机制放在哪里,但是对于 Liberty,如果我设置自定义 JAAS 身份验证机制,那么我将无法登录到 WebSphere Liberty AdminCenter,如果我为 server.xml 配置,则它不会对我的应用程序的用户进行身份验证(因为它旨在通过 JAAS 对用户进行身份验证)。

这是我的 server.xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
 <server description="new server">

     <!-- Enable features -->
     <featureManager>
         <feature>adminCenter-1.0</feature>
         <feature>ssl-1.0</feature>
         <feature>webProfile-7.0</feature>
         <feature>appSecurity-2.0</feature>
     </featureManager>

     <keyStore id="defaultKeyStore" password="WASLiberty" />

     <!-- Admin Center username/password -->
     <!--<quickStartSecurity userName="admin" userPassword="admin123" />-->
     <!-- Define an Administrator and non-Administrator -->
    <basicRegistry id="basic">
       <user name="admin" password="{xor}PjsyNjFubWw=" /> <!-- Encoded version of "admin123" -->
       <user name="nonadmin" password="nonadmin123" />
    </basicRegistry>

    <!-- Assign 'admin' to Administrator -->
    <administrator-role>
       <user>admin</user>
    </administrator-role>

     <!-- JNDI Connection configuration -->
     <dataSource id="MY_CUSTOM_DS" jndiName="jdbc/MY_CUSTOM_DS">
         <jdbcDriver libraryRef="sqlserverjdbc"/>
         <properties.microsoft.sqlserver databaseName="mydb" 
                                         serverName="localhost" portNumber="1433"
                                         user="sa" password="root" />
     </dataSource>

     <!-- JDBC Driver file location -->
     <library id="sqlserverjdbc">
         <file name="${wlp.install.dir}/lib/sqljdbc4.jar"/>
     </library>
     <library id="MyLoginModuleLib">
         <fileset dir="${wlp.install.dir}/lib" includes="custom_auth.jar"/>
     </library> 

     <!-- JAAS Login Module for web application -->
     <jaasLoginModule id="myCustom" 
                      className="com.kana.auth.websphere.MyLoginModule" 
                      controlFlag="REQUIRED" libraryRef="MyLoginModuleLib">
         <options myOption1="value1" myOption2="value2"/>
     </jaasLoginModule>

     <!-- JAAS Login Context -->
     <jaasLoginContextEntry id="system.WEB_INBOUND" name="system.WEB_INBOUND" 
                  loginModuleRef="myCustom, hashtable, userNameAndPassword, certificate, token"  />

     <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
     <httpEndpoint id="defaultHttpEndpoint"
                   host="*"
                   httpPort="9080"
                   httpsPort="9443" />

     <webApplication contextRoot="mywebapp" location="mywebapp.war" />

     <!-- Automatically expand WAR files and EAR files -->
     <applicationManager autoExpand="true"/>

     <!-- Enable remote file access -->
     <remoteFileAccess>
        <writeDir>${server.config.dir}</writeDir>
     </remoteFileAccess>
 </server>

谁能指出我哪里出错了?

如果您正在使用自定义 JAAS 登录模块,那么您的自定义 JAAS 登录模块需要忽略管理中心身份验证并让默认登录模块处理它。 更好的选择是使用自定义 TAI 来处理应用程序身份验证,并让默认登录模块处理管理中心身份验证。

此致, 乌特勒

非常感谢 Ut Le 提供解决方案。

从日志文件中,发现根本原因是ClassNotFound异常。它没有我从 <jaasLoginModule> 指向的 class。后来发现我指向的是不在那个位置的 jar 文件。所以这是我在配置时犯的一个愚蠢的错误。