简体   繁体   English

如何在Alfresco Share上向JSP页面添加身份验证

[英]How to Add Authentication to JSP Page on Alfresco Share

So for the project I'm currently working on, prior to taking the Alfresco developers course, we had created a custom JSP page that we call from within the course of our workflow that is located at: C:\\Alfresco\\tomcat\\webapps\\share\\custom . 因此,对于我目前正在开展的项目,在参加Alfresco开发人员课程之前,我们创建了一个自定义JSP页面,我们在工作流程中调用它们位于: C:\\Alfresco\\tomcat\\webapps\\share\\custom Currently anyone can access this jsp page. 目前任何人都可以访问此jsp页面。 However, when we move the location to C:\\Alfresco\\tomcat\\webapps\\alfresco\\jsp\\custom , a log on is always required to acces the page, which seems strange to me. 但是,当我们将位置移动到C:\\Alfresco\\tomcat\\webapps\\alfresco\\jsp\\custom ,总是需要登录才能访问该页面,这对我来说似乎很奇怪。 However the issue here is we do not want to allow the user access to both Share and Explorer, thus we are not looking to configure an SSO here. 但是,这里的问题是我们不希望允许用户访问共享和资源管理器,因此我们不打算在此处配置SSO。 We'd like to only allow people of group “Manager”, or the currently logged in user from the group "Manager" to access this page, while it is located on the share side. 我们只允许组“管理员”的人员或“管理员”组中当前登录的用户访问此页面,而它位于共享端。 We've tried adding the following into the 我们已经尝试将以下内容添加到

C:\\Alfresco\\tomcat\\webapps\\share\\WEB-INF\\web.xml file: C:\\Alfresco\\tomcat\\webapps\\share\\WEB-INF\\web.xml文件:

<security-constraint>
        <web-resource-collection>
            <web-resource-name>All</web-resource-name>
            <url-pattern>/custom /*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
            <role-name>Manager</role-name>
        </auth-constraint>
    </security-constraint>

But this did not work. 但这没效果。 Does anyone have a suggestion as to how we might get the desired authentication? 有没有人建议我们如何获得所需的身份验证?

Thanks 谢谢

Authentication in Share is controlled by the Surf framework, and specifically it is set at the page level. Share中的身份验证由Surf框架控制,具体来说,它是在页面级别设置的。

The JSP page site-index.jsp provides an example JSP-based page which processes authenticated users for you to copy, but you must also wire it in to the framework. JSP页面site-index.jsp提供了一个基于JSP的示例页面,该页面处理经过身份验证的用户以供您复制,但您还必须将其连接到框架中。

To do this, you'll need to create a page definition similar to the following 为此,您需要创建类似于以下内容的页面定义

<?xml version='1.0' encoding='UTF-8'?>
<page>
   <title>My page</title>
   <description>What the page is for</description>
   <template-instance>my-page</template-instance>
   <authentication>user</authentication>
</page>

Add this file under WEB-INF/classes/alfresco/site-data/pages/site-index.xml . WEB-INF/classes/alfresco/site-data/pages/site-index.xml下添加此文件。

You'll see that the page references a template instance my-page , which must be declared in a second XML file under WEB-INF/classes/alfresco/site-data/template-instances , eg 您将看到该页面引用了模板实例my-page ,该模板实例必须在WEB-INF/classes/alfresco/site-data/template-instances下的第二个XML文件中声明,例如

<?xml version='1.0' encoding='UTF-8'?>
<template-instance>
   <template-type>my-page</template-type>
</template-instance>

The name of the template-instance XML file (without the .xml suffix) must match the name specified in the page's <template-instance> property. 模板实例XML文件的名称(不带.xml后缀)必须与页面的<template-instance>属性中指定的名称匹配。

Lastly create a template type file my-page.xml (this name must match the <template-type> property in the template instance file) under WEB-INF/classes/alfresco/site-data/template-types , eg 最后,在WEB-INF/classes/alfresco/site-data/template-types下创建模板类型文件my-page.xml (此名称必须与模板实例文件中的<template-type>属性匹配),例如

<?xml version="1.0" encoding="UTF-8"?>
<template-type>
        <title>Site index landing page template type</title>
        <description>Site index landing page JSP Template Type</description>

        <!-- Define the rendering processors for this template type -->
        <processor mode="view">
                <id>jsp</id>
                <jsp-path>/my-page.jsp</jsp-path>
        </processor>

</template-type>

The file my-page.jsp will contain your JSP code. 文件my-page.jsp将包含您的JSP代码。 As I mention look at the core file site-index.jsp for an example. 正如我所提到的,请查看核心文件site-index.jsp作为示例。

When you have all of this working you should package up your customisations in an AMP file. 当您完成所有这些工作后,您应该将自定义打包在AMP文件中。 You can use either Ant or Maven to do this depending on your preference. 您可以使用Ant或Maven来执行此操作,具体取决于您的偏好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM