【发布时间】:2016-02-11 08:00:43
【问题描述】:
我将跳过kerberos 配置,因为我确信它有效。我通过检查PHP $_SERVER 变量进行了测试,一切都设置好了。
- Apache 配置:
LoadModule auth_kerb_module /usr/lib/apache2/modules/mod_auth_kerb.so
<VirtualHost localhost:443>
SSLEngine on
SSLCertificateFile /opt/keys/localhost.crt
SSLCertificateKeyFile /opt/keys/private.pem
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyPass / ajp://localhost:8009/
<Location / >
SSLRequireSSL
AuthType Kerberos
KrbMethodNegotiate On
KrbMethodK5Passwd Off
KrbServiceName HTTP/localhost@example.com
KrbAuthRealms example.com
Krb5KeyTab /etc/krb5.keytab
require valid-user
</Location>
</VirtualHost>
-
Tomcat 配置
< Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" SSLProtocol="TLSv1+TLSv1.1+TLSv1.2" keystoreFile="/opt/keys/keystore.jks" keystorePass="changeit" /> -
设置用mvn archetype
HOOK创建项目,命名为Kerberos-Hook,然后在包com.liferay.portal.security.auth.KerberosAutoLogin.javasrc/main/java类中创建:public class KerberosAutoLogin implements AutoLogin { private static Log logger = LogFactoryUtil.getLog(KerberosAutoLogin.class); public String[] handleException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Exception e) throws AutoLoginException { logger.error("1"); return doHandleException(request, response, e); } protected String[] doHandleException( HttpServletRequest request, HttpServletResponse response, Exception e) throws AutoLoginException { logger.info("2"); if (request.getAttribute(AutoLogin.AUTO_LOGIN_REDIRECT) == null) { throw new AutoLoginException(e); } logger.error("doHandleException: " + e); return null; } public String[] login(HttpServletRequest req, HttpServletResponse res) throws AutoLoginException { logger.error("3"); try { return doLogin(req, res); } catch (Exception e) { return handleException(req, res, e); } } protected String[] doLogin(HttpServletRequest req, HttpServletResponse res) throws AutoLoginException, Exception { logger.error("4"); String[] credentials = null; String userName = (String) req.getAttribute("REMOTE_USER"); logger.info("kerberosUserName = " + userName); userName = userName.replaceAll("@.*", "").replaceAll("/.*", ""); logger.info("userName = " + userName); long companyID = PortalUtil.getCompanyId(req); logger.info("CompanyID = " + companyID); if (userName == null || userName.length() < 1) { return credentials; } else { credentials = new String[3]; User user = UserLocalServiceUtil.getUserByScreenName(companyID, userName); long userID = user.getUserId(); String userPassword = user.getPassword(); logger.info("userID = " + userID); credentials[0] = String.valueOf(userID); credentials[1] = userPassword; credentials[2] = Boolean.FALSE.toString(); return credentials; } } } - 将
liferay-hook.xml配置为指向包含auto.login.hooks=com.liferay.portal.security.auth.KerberosAutoLogin的src/main/resources/ext-portal.properties - 使用 mvn 原型
Ext和项目ext-impl创建项目com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.java创建类 - 已部署
HOOK和EXT
在KerberosAutoLogin 类中,我放了一些logs 以便看到某种debug,因为我在远程服务器上部署了应用程序,所以我无法正确调试钩子。
但是没有显示日志,因此甚至没有使用该类,谁能指出我缺少什么以便开始将我的 liferay 与 kerberos 集成?
在 apache 日志中我看到例如:
localhost:443 192.168.24.73 - mithrand1r@example.com [11/Feb/2016:09:56:57 +0100] "POST /poller/receive HTTP/1.1" 200 1011 "https://localhost/group/control_panel/manage/-/server/log-levels/update-categories?refererPlid=20184" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0"
【问题讨论】: