You can use the <quickStartSecurity> element to quickly enable a simple (one user) security setup for the Liberty profile.
You can set up a secured Liberty profile server and web application by following some basic configuration steps. Configuration actions within the Liberty profile are dynamic, which means the configuration updates take effect without having to restart the server.
server.bat create MyNewServer
server.bat start MyNewServer
server create MyNewServer
server start MyNewServer
The server.xml file is in the server directory of myNewServer, for example, wlp\usr\servers\myNewServer\server.xml.
<featureManager>
<feature>appSecurity-2.0</feature>
<feature>servlet-3.0</feature>
</featureManager>
<quickStartSecurity userName="Bob" userPassword="bobpwd" />
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="myWebApp">
<!-- SERVLET DEFINITIONS -->
<servlet id="Default">
<servlet-name>myWebApp</servlet-name>
<servlet-class>com.web.app.MyWebAppServlet</servlet-class>
<load-on-startup/>
</servlet>
<!-- SERVLET MAPPINGS -->
<servlet-mapping id="ServletMapping_Default">
<servlet-name>myWebApp</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- SECURITY ROLES -->
<security-role>
<role-name>testing</role-name>
</security-role>
<!-- SECURITY CONSTRAINTS -->
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>testing</role-name>
</auth-constraint>
</security-constraint>
<!-- AUTHENTICATION METHOD: Basic authentication -->
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
<application type="war" id="myWebApp" name="myWebApp"
location="${server.config.dir}/apps/myWebApp.war">
<application-bnd>
<security-role name="testing">
<user name="Bob" />
</security-role>
</application-bnd>
</application>