Customize the Delivery Tier's Form Login Pages

Introduction

Goal

Customize the form login and login error pages in Hippo's delivery tier.

Configure a Custom Form Login Page for a Mount

You can configure a custom form login page for a mount by configuring the hst:formloginpage property. For example,

hst:formloginpage: /examples/custom_form_login.jsp

So, when the mount is protected with the following properties:

hst:authenticated: true
hst:roles: everybody
hst:formloginpage: /examples/custom_form_login.jsp

the delivery tier will redirect the request for the mount to the custom form login page ( custom_form_login.jsp) if the user is not authenticated yet.

In your custom form login page, you may use the following HttpSession attributes to display the previous user name and redirecting destination after signing in:

Attribute name

Example value

Code example

org.hippoecm.hst.security.servlet.username

admin

session.getAttribute(
 "org.hippoecm.hst.security.servlet.username")

org.hippoecm.hst.security.servlet.destination

/site/preview

session.getAttribute(
 "org.hippoecm.hst.security.servlet.destination")

Also, you can customize the default login error page by setting the following session attribute in your custom form login page:

Attribute name

Example value

Code example

org.hippoecm.hst.security.servlet.loginErrorPage

/examples/custom_form_login_error.jsp

session.setAttribute(
 "org.hippoecm.hst.security.servlet.loginErrorPage",
 "/examples/custom_form_login_error.jsp");

NOTE: The custom form login error page can be set only in the custom form login page!

Configure the Default Form Login Pages

The default form login page and form login error page are included in hst-security-2.yy.xx.jar as Freemarker templates.

You may configure different default pages through the following servlet init parameters. When you configure these init parameters manually, you should configure contextrelative paths which can be dispatched by the servlet context.

Init Parameter Name

Description

Example Value

Default Value

loginFormPagePath

The initial login form page path

/WEB-INF/login/login_form.jsp or /WEB-INF/login/login_form.ftl or jcr:/hst:hst/.../login_form.ftl

classpath:/org/hippoecm/hst/security/servlet/login_form.ftl

loginErrorPage

The login error page path

/WEB-INF/login/login_failure.jsp or /WEB-INF/login/login_failure.ftl or
jcr:/hst:hst/.../login_failure.ftl

classpath:/org/hippoecm/hst/security/servlet/login_failure.ftl

Customize the Default Form Login Pages

The default form login page and form login error page are included in hst-security-2.yy.xx.jar as script templates:

The default form login page template:

classpath:/org/hippoecm/hst/security/servlet/login_form.ftl

The default form login error page template:

classpath:/org/hippoecm/hst/security/servlet/login_failure.ftl 

It's possible to customize the script templates by adding templates in your application classpath (e.g. /WEB-INF/classes) with the same names.

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?