Configuring security for a web application in Apache Karaf
This recipe will handle how to build a web application with authentication enabled. As we are running within Apache Karaf and Karaf supports Java Authentication and Authorization Service (JAAS) out of the box, we will show you everything that is needed to run a basic authentication with JAAS on Karaf.
Getting ready
The prerequisite is to install the WAR feature. The source code for this recipe is available at https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter4/chapter4-recipe7.
How to do it…
The first step is configuring the user/password combination in Karaf. Let's start with the user configuration. Let's make sure that the
users.properties
file in the/etc
folder contains the following setup (it's the default configuration):karaf = karaf,_g_:admingroup _g_\:admingroup = group,admin,manager,viewer
The
users.properties
file follows the following syntax:USER=PASSWORD, ROLE1, ROLE2, …
It can also have the following syntax...