Search code examples
tomcatauthenticationjdbcrealm

How to setup Tomcat web.xml and context.xml for 2 different (user and admin) authentication


Here's my situation:

I want stuff under

mysite/customer/*

to require form-based authentication before access (login via mysite/customer/login.jsp, with its own user_password table and role. )

BUT

I want stuff under

mysite/admin/*

to require another form-based authentication before access (login via mysite/admin/login.jsp, with another set of admin_user_password table and role. )

Is it possible to do this under Tomcat 6.0? If so, can someone briefly describe how I could go about implementing this? I've looked around and only seen examples of 1 Realm setup...havent seen multiple Realm setup before.

I use JDBCRealm.


Solution

  • I think that is not possible. You could go the filter way in which you setup a filter for the customer side of your tree and another filter for the admin side. Take a look here.

    The other way is to setup two applications in tomcat in two different contexts using single sign on within tomcat. In this way you would have /mysitecustomer and mysiteadmin as two different applications sharing one realm but having two different login pages.