[英]amazon beanstalk tomcat basic authentication
我有一個Java應用程序,最近已遷移到Amazon AWS,帶有tomcat7的Beanstalk和一個MySQL數據庫(RDS)。
我想合並基本的Tomcat身份驗證,並在WEB_INF下創建了以下文件:
web.xml中
<security-constraint>
<display-name>UserConstraint</display-name>
<web-resource-collection>
<web-resource-name>UserConstraint</web-resource-name>
<description/>
<url-pattern>/text.txt</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>authz-user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>file</realm-name>
</login-config>
<security-role>
<description>Application user role</description>
<role-name>authz-user</role-name>
</security-role>
users.xml中
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<role rolename="authz-user"/>
<user username="name" password="pass" roles="authz-user"/>
</tomcat-users>
WEB-INF / .ebextensions / context.xml的
<?xml version='1.0' encoding='utf-8'?>
<Context antiJARLocking="true" path="/APPNAME>
<WatchedResource>WEB-INF/users.xml</WatchedResource>
</Context>
我收到登錄請求,但不接受用戶/密碼。 我來自不同的來源,所以我不確定在這種環境下是否應該這樣做。 如何使用戶被接受? 這是創建用戶的另一種方法嗎?
找到幾個錯誤:
.ebextensions文件夾必須位於Web應用程序的ROOT中。
此文件夾中的server-update.config文件必須包含:
container_commands:
replace-config:
command: "cp .ebextensions/tomcat-users.xml /usr/share/tomcat7/conf/tomcat-users.xml"
users.xml重命名為tomcat-users.xml。
現在可以了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.