Custom Logout Servlet

15 views
Skip to first unread message

Jean-Louis Bourlet

unread,
Oct 19, 2015, 7:13:17 AM10/19/15
to Hippo Community
Hi,

We have done some integration with an external authentication mechanism in hippo (based on Jass).
Basically we secured the "/login" url-pattern and a Tomcat valve is responsible to authenticate via an external idp.
It works, now we need a custom logout.
I tried to a add this to the web.xml :

 <servlet>
    <servlet-name>Logout</servlet-name>
    <servlet-class>be.smals.famhp.servlet.LogoutServlet</servlet-class>
  </servlet>
 <servlet-mapping>
    <servlet-name>Logout</servlet-name>
    <url-pattern>/logout</url-pattern>
  </servlet-mapping>

but when accessing /site/logout it just ignore the servlet and return a 404, is it because of the hst filter ? how can i make a custom servlet works ?

thank you

Jean-Louis Bourlet

unread,
Oct 19, 2015, 7:41:24 AM10/19/15
to Hippo Community
I just realize i had to map eveything with hst right  ?
So i created a sitemapitem "logout" that points to a custom "LogoutComponent" and in the component :
@Override
   
public void doBeforeRender(HstRequest request, HstResponse response) {
       
try {
           
System.out.println("Logging out ...");
            request
.logout();
       
} catch (ServletException e) {
           
// TODO Auto-generated catch block
            e
.printStackTrace();
       
}
       
HstResponseUtils.sendRedirect(request, response, "/");
   
}

works perfect ;-)
Reply all
Reply to author
Forward
0 new messages