我有一个REST服务在Open Liberty上的Docker中运行。这是Docker文件:
FROM open-liberty:kernel
COPY server.xml /config/
COPY jvm.options /config/
COPY tlscertificate.p12 /opt/ol/wlp/output/defaultServer/resources/security/
ADD aa-lookup-1.war /config/dropins/
server.xml:
<server description="AA Lookup">
<featureManager>
<feature>jaxrs-2.1</feature>
<feature>cdi-2.0</feature>
<feature>ejb-3.2</feature>
<feature>appSecurity-3.0</feature>
<feature>transportSecurity-1.0</feature>
</featureManager>
<keyStore id="defaultKeyStore" location="tlscertificate.p12" password="{xor}jsdjdksjdk=" type="PKCS12"/>
<basicRegistry id="basic" realm="BasicRealm">
<group name="aa-reader">
<member name="MyUser"></member>
</group>
<user password="{hash}DJKJDKLSJDJKDJSKLD7D7JJ" name="MyUser"></user>
</basicRegistry>
<webApplication id="aa-lookup" location="aa-lookup-1.war" name="aa-lookup" contextRoot="aa">
<application-bnd>
<security-role name="aa-reader">
<user name="MyUser" />
</security-role>
</application-bnd>
</webApplication>
</server>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<security-constraint>
<web-resource-collection>
<web-resource-name>REST</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>aa-reader</role-name>
</auth-constraint>
</security-constraint>
</web-app>
Java代码中没有与身份验证相关的内容,并且基本身份验证工作正常。然后我的Docker莫名其妙地损坏了,我启动了一个新的云实例,在其中重建并运行Docker映像。
现在不再接受用户名和密码。在我的本地计算机上,我正在运行带有Eclipse的Open Liberty 18.0.0.2,并且身份验证在此处可以正常工作。 OpenLiberty存储库不再包含该版本。在Docker中,我尝试使用18.0.0.4和更高版本。
我已经使用IBM instructions从头开始设置了身份验证,但这没有帮助。当我启用FINE级别跟踪日志记录时,我基本上发现它说需要[aa-reader}角色->返回401。
如何在最新版本的Open Liberty中设置简单的基本身份验证?