1.「web.xml」に以下の記載を追加する。
<web.xmlの格納先>
\apache-tomcat-8.5.15\webapps\ROOT\WEB-INF\web.xml
or
\apache-tomcat-8.5.15\conf\web.xml
■記載内容
<security-constraint>
<web-resource-collection>
<web-resource-name>User Basic Auth</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>role1</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>User Basic Auth</realm-name>
</login-config>
<security-role>
<role-name>role1</role-name>
</security-role>
2.「tomcat-users.xml」に以下の記載をする。
<tomcat-users.xmlの格納先>
\apache-tomcat-8.5.15\conf\tomcat-users.xml
■記載内容
<role rolename="role1"/>
<user username="sample" password="test" roles="role1"/>