How-ToTomcat

How to Add User Authentication on Tomcat

1 Mins read

I have seen many people writing their own Login utilities for web application, which is like re-inventing the wheel. Tomcat supports user authentication feature which is a really useful for web applications. Authentication can be plugged in separately into your web application without changing any code.
To setup tomcat user authentication, you need to do the following steps:

  1. Create a conf/apps-.xml that contains the following
  2. 
    
        
                
        
    
    
    
  3. Create a conf/users/appname-users.xml that looks like:
  4. 
      
    
    
    
  5. Insert the following in the webapps/appname/WEB-INF/web.xml
  6. 
        
          user-resource
          pages which require login
          *.jsp
          *.html
          GET
          POST
        
        
          Must authenticate before querying the system
          rolename
        
        
          NONE
        
      
    
      
        BASIC
        default
      
    
      
        Any user of the system
        rolename
      
    
    

Note that you will have to ensure the section points to the roles you created the users at, and you may need to add another section if you have, for example, .event files. The default simply authenticates *.jsp and *.html, both for GET and POST.

Related posts
How-ToLinuxVPS

How To Set Up A VPS Server On CentOS 7 And CentOS 8

4 Mins read
A VPS is a virtual private server. It is a service that provides users with the chance to manage their own space…
How-ToMusicTechnology

Are You Passionate About Mixing Music? Here’s How to Become a DJ

2 Mins read
Welcome to the world of music! This article is dedicated to the ones passionate about music. You will assist in your journey…
AppleHow-ToiOSiPhoneMobilePerformance

How To Fix Slow iPhone

3 Mins read
Are you Owning an expensive iPhone that is slow? You are not alone in this situation. Many people struggle with the slow…
Power your team with InHype

Add some text to explain benefits of subscripton on your services.

Leave a Reply

Your email address will not be published. Required fields are marked *