One of the first steps in integrating CMS Ametys is to determine how contributors log in (the authentication process is detailed on the Authentication page of CMS ). One possibility is to allow contributors to enter their login and password on a HTML form.
A default form is provided in Ametys, under the extension org.ametys.runtime.plugins.core.authentication.FormBased . However, it is possible to define your own connection form.
To define a new connection form, create a new extension point of type org.ametys.runtime.authentication.CredentialsProvider . The declaration of this new extension point must be made in the file plugin.xml plugin Ametys . If necessary, you will need to create a new plugin, then follow the instructions on the page Architecture of a plugin Ametys .
Here's an example defined in a plugin "myplugin".
Sample declaration (file plugin.xml)
Oops! Copy to clipboard failed. Open the code and copy it manually.<extensions>
<extension point="org.ametys.runtime.authentication.CredentialsProvider"
id="org.ametys.plugins.myplugin.authentication.MyFormBased"
class="org.ametys.runtime.plugins.core.authentication.FormBasedCredentialsProvider"
logger="org.ametys.runtime.authentication.formbased">
<username-field>Username</username-field>
<password-field>Password</password-field>
<rememberMe-field>rememberMe</rememberMe-field>
<cookie>
<cookieEnabled>true</cookieEnabled>
<cookieLifeTime>604800</cookieLifeTime>
<cookieName>AmetysAuthentication</cookieName>
</cookie>
<loginUrl internal="true">plugins/myplugin/login.html</loginUrl>
<loginFailedUrl provideLoginParameter="true" internal="true">plugins/myplugin/login.html</loginFailedUrl>
</extension>
</extensions>
<extensions>
<extension point="org.ametys.runtime.authentication.CredentialsProvider"
id="org.ametys.plugins.myplugin.authentication.MyFormBased"
class="org.ametys.runtime.plugins.core.authentication.FormBasedCredentialsProvider"
logger="org.ametys.runtime.authentication.formbased">
<username-field>Username</username-field>
<password-field>Password</password-field>
<rememberMe-field>rememberMe</rememberMe-field>
<cookie>
<cookieEnabled>true</cookieEnabled>
<cookieLifeTime>604800</cookieLifeTime>
<cookieName>AmetysAuthentication</cookieName>
</cookie>
<loginUrl internal="true">plugins/myplugin/login.html</loginUrl>
<loginFailedUrl provideLoginParameter="true" internal="true">plugins/myplugin/login.html</loginFailedUrl>
</extension>
</extensions>
Voir le code
<extensions>
<extension point="org.ametys.runtime.authentication.CredentialsProvider"
id="org.ametys.plugins.myplugin.authentication.MyFormBased"
class="org.ametys.runtime.plugins.core.authentication.FormBasedCredentialsProvider"
logger="org.ametys.runtime.authentication.formbased">
<username-field>Username</username-field>
<password-field>Password</password-field>
<rememberMe-field>rememberMe</rememberMe-field>
<cookie>
<cookieEnabled>true</cookieEnabled>
<cookieLifeTime>604800</cookieLifeTime>
<cookieName>AmetysAuthentication</cookieName>
</cookie>
<loginUrl internal="true">plugins/myplugin/login.html</loginUrl>
<loginFailedUrl provideLoginParameter="true" internal="true">plugins/myplugin/login.html</loginFailedUrl>
</extension>
</extensions>
Theurl login form is here: http://[server_url]/plugins/myplugin/login.html
The file sitemap.xml of plugin must contain the following pipelines:
Oops! Copy to clipboard failed. Open the code and copy it manually.<map:match pattern="login.html">
<map:generate type="action-result" label="content"/>
<map:transform type="xslt" src="pages/login.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="workspaceURI" value="{request-attr:workspaceURI}"/>
<map:parameter name="workspaceName" value="{request-attr:workspaceName}"/>
</map:transform>
<map:transform type="i18n" label="xml">
<map:parameter name="locale" value="{locale:locale}"/>
<map:parameter name="default-catalogue-id" value="{request-attr:pluginName}"/>
</map:transform>
<map:serialize/>
</map:match>
<map:match pattern="login_failed.html">
<map:generate type="action-result" label="content"/>
<map:transform type="xslt" src="pages/login.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="workspaceURI" value="{request-attr:workspaceURI}"/>
<map:parameter name="workspaceName" value="{request-attr:workspaceName}"/>
<map:parameter name="login-failed" value="true"/>
</map:transform>
<map:transform type="i18n" label="xml">
<map:parameter name="locale" value="{locale:locale}"/>
<map:parameter name="default-catalogue-id" value="plugin.cms"/>
</map:transform>
<map:serialize/>
</map:match>
<map:match pattern="login.html">
<map:generate type="action-result" label="content"/>
<map:transform type="xslt" src="pages/login.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="workspaceURI" value="{request-attr:workspaceURI}"/>
<map:parameter name="workspaceName" value="{request-attr:workspaceName}"/>
</map:transform>
<map:transform type="i18n" label="xml">
<map:parameter name="locale" value="{locale:locale}"/>
<map:parameter name="default-catalogue-id" value="{request-attr:pluginName}"/>
</map:transform>
<map:serialize/>
</map:match>
<map:match pattern="login_failed.html">
<map:generate type="action-result" label="content"/>
<map:transform type="xslt" src="pages/login.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="workspaceURI" value="{request-attr:workspaceURI}"/>
<map:parameter name="workspaceName" value="{request-attr:workspaceName}"/>
<map:parameter name="login-failed" value="true"/>
</map:transform>
<map:transform type="i18n" label="xml">
<map:parameter name="locale" value="{locale:locale}"/>
<map:parameter name="default-catalogue-id" value="plugin.cms"/>
</map:transform>
<map:serialize/>
</map:match>
Voir le code
<map:match pattern="login.html">
<map:generate type="action-result" label="content"/>
<map:transform type="xslt" src="pages/login.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="workspaceURI" value="{request-attr:workspaceURI}"/>
<map:parameter name="workspaceName" value="{request-attr:workspaceName}"/>
</map:transform>
<map:transform type="i18n" label="xml">
<map:parameter name="locale" value="{locale:locale}"/>
<map:parameter name="default-catalogue-id" value="{request-attr:pluginName}"/>
</map:transform>
<map:serialize/>
</map:match>
<map:match pattern="login_failed.html">
<map:generate type="action-result" label="content"/>
<map:transform type="xslt" src="pages/login.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="workspaceURI" value="{request-attr:workspaceURI}"/>
<map:parameter name="workspaceName" value="{request-attr:workspaceName}"/>
<map:parameter name="login-failed" value="true"/>
</map:transform>
<map:transform type="i18n" label="xml">
<map:parameter name="locale" value="{locale:locale}"/>
<map:parameter name="default-catalogue-id" value="plugin.cms"/>
</map:transform>
<map:serialize/>
</map:match>
The XSL "pages/login.xsl "The login form and any errors should be displayed at plugin .
Here you can download a sample login file.xsl simplified (without css) to display the login form .