Tomcat User Base
The Tomcat User Base Realm is using a JNDI resource to store user information. By default, the JNDI resource is configured in an XML file. The default file is tomcat-users.xml in the Apache Tomcat conf folder.
We strongly recommend using this authentication approach for your test or local environment. It is easy to setup and configure. However, it is not designed to be used for large-scale production or when you have a large number of users.
The following Realm has to be added in the server.xml file in the Apache Tomcat conf folder:
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
The users and roles are managed in the tomcat-users.xml file in the Apache Tomcat conf folder. In this file, you can add users and roles as well as assign roles to users.
Add the following role and user to your tomcat-users.xml file:
<role rolename="admin"/>
<user username="John" password="john" roles="admin"/>
By adding these two lines you have achieved the following:
- Created a new role named admin
- Created a new user with username John and password john
- Assigned the newly created user the role admin
(c) 2023 Altair Engineering Inc. All Rights Reserved.