通过CAS登录Liferay登录,通过登录Portlet创建帐户功能



我们使用Liferay 6.1.0,OpenLDAP来存储用户,而CAS则用于SSO。我配置了Liferay将CAS用于登录。但是,仅当一个单击右上角的"登录"链接时,通过CAS登录工作。用户也可以通过登录portlet登录,但不使用CAS。首先,我认为我可以隐藏或删除登录portlet,以迫使用户通过CAS登录,但是随后我丢失了登录Portlet提供的"创建帐户"链接。我需要Liferay的创建帐户功能,因为它非常实用(例如,将新用户导出到LDAP)。

我怎么能吃蛋糕去吃它?IE。提供Liferay的创建帐户链接,而不显示其余的登录portlet,而仅通过CAS登录的" force"已经注册的用户?任何帮助,将不胜感激。谢谢。

回答我自己的问题,因为我终于弄清楚了...

我创建了一个钩子来替换JSP文件$TOMCAT/webapps/ROOT/html/portlet/login/login.jsp,其中$TOMCAT是Liferay Bundle中的Tomcat Server目录。(检查如何创建JSP钩的Liferay指南。)

这个想法是测试是否启用CA,如果是,则"隐藏"用户名,密码字段和表单中的登录按钮。我在Liferay Shibboleth插件中发现的测试条件。这是JSP的相关部分,从第101行左行左行开始:

        <liferay-ui:error exception="<%= UserPasswordException.class %>" message="authentication-failed" />
        <liferay-ui:error exception="<%= UserScreenNameException.class %>" message="authentication-failed" />
    <%-- When CAS is enabled, don't show the normal login fields --%>
    <c:choose>
        <c:when test="<%= PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.CAS_AUTH_ENABLED, PropsValues.CAS_AUTH_ENABLED) %>" >
            <%-- CAS is enabled --%>
            <div><p>
            Please sign in via CAS using the "Sign In" link in the upper right corner.
            </p></div>
        </c:when>
        <c:otherwise>   <%-- original login fields --%>
            <aui:fieldset> 
                <%
                String loginLabel = null;
                if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
                    loginLabel = "email-address";
                }
                else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
                    loginLabel = "screen-name";
                }
                else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
                    loginLabel = "id";
                }
                %>
                <aui:input label="<%= loginLabel %>" name="login" showRequiredLabel="<%= false %>" type="text" value="<%= login %>">
                    <aui:validator name="required" />
                </aui:input>
                <aui:input name="password" showRequiredLabel="<%= false %>" type="password" value="<%= password %>">
                    <aui:validator name="required" />
                </aui:input>
                <span id="<portlet:namespace />passwordCapsLockSpan" style="display: none;"><liferay-ui:message key="caps-lock-is-on" /></span>
                <c:if test="<%= company.isAutoLogin() && !PropsValues.SESSION_DISABLED %>">
                    <aui:input checked="<%= rememberMe %>" inlineLabel="left" name="rememberMe" type="checkbox" />
                </c:if>
            </aui:fieldset>
            <aui:button-row>
                <aui:button type="submit" value="sign-in" />
            </aui:button-row>
        </c:otherwise>
        </c:choose>
        <%-- end of CAS-dependent login field part --%>
    </aui:form>

诚然,这是一个黑客,但有效。: - )

最新更新