Quick way to secure web application on Tomcat 6 using BASIC authentication
Posted on 9:43 PM under tomcat
You are developing a Java web application, the final application will use some complex security framework (such as Spring Security, formerly Acegi, JSecurity or Shiro, etc.). But in some first milestones, the clients want you to show them the demo of the application, and they want to secure the demo site with a username/password (for things like NDA) and they don't want to wait for later milestones to have that. In this situation, you cannot integrate the above security frameworks because of time constraint, bugs or the complexity of the security frameworks.
A quick and dirty way to do this is using a built-in authentication mechanism of Tomcat (I'm using Tomcat 6.x).
First put those into your web.xml file:
If you use Spring Security, remember to remove Spring Security filter in the web.xml file. Now in your context file (the context.xml file in your META-INF of your web archive or in ther conf/Catalina/localhost/ context file), adding the following:EntireApp /* GET POST client client BASIC
Finally, edit the tomcat-users.xml (usually located at
Now, every time the clients access the demo site, the browser will pop up a dialog asking for username and password. After successfully authenticated, the clients will use the demo site as normal.
This authentication mechanism is the Basic access authentication. As the title said, this is a quick and dirty way to secure a web application on Tomcat 6.
Hope this saves you some time.
0 comments:
Post a Comment