设想
我们正在使用 Weblogic Server 10.3.4 运行我们的 web 应用程序,该应用程序启用了安全约束,以要求用户在他/她可以使用该应用程序之前登录。用户和组信息应驻留在应用程序数据库中,身份验证应由 WLS(容器)处理。
我已经按照这篇博客文章中的描述设置了一个数据库模式,在 WLS 控制台中设置了一个新的安全领域“app.realm”并在SQLAuthenticator
其中定义了一个。
重新启动 WLS 后,我可以在 WLS Web 控制台的“app.realm”中的数据库中看到我的用户和组定义。我尝试验证的用户是该WEBAPP_USER
组的成员(我在 WLS 控制台的用户详细信息页面上看到了组成员身份)。
当我部署应用程序(使用标准设置,未在 WLS Web 控制台中进行调整)并调用受保护的 URL 时,我会login.html
按预期重定向到表单。但是,无论我尝试什么,输入(正确的)密码总是会导致身份验证失败,将我发送到该login_error.html
页面。出于调试目的,我在我的 中启用了纯文本密码SQLAuthenticator
,所以我很确定使用了正确的凭据。
更新 1
感谢 emzy 的评论,我现在看到 WLS 正在根据默认领域“myrealm”检查凭据,并尝试根据嵌入式 LDAP 解析登录用户名:
...
####<20.04.2011 09:29 Uhr MESZ> <Debug> <SecurityAtn> <hostname> <AdminServer> <[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1303284573150> <BEA-000000> <getDNForUser search("ou=people,ou=myrealm,dc=nvs_dev", "(&(uid=app.user)(objectclass=person))", base DN & below)>
####<20.04.2011 09:29 Uhr MESZ> <Debug> <SecurityAtn> <hostname> <AdminServer> <[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1303284573150> <BEA-000000> <DN for user app.user: null>
####<20.04.2011 09:29 Uhr MESZ> <Debug> <SecurityAtn> <hostname> <AdminServer> <[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1303284573150> <BEA-000000> <returnConnection conn:LDAPConnection { ldapVersion:2 bindDN:""}>
####<20.04.2011 09:29 Uhr MESZ> <Debug> <SecurityAtn> <hostname> <AdminServer> <[ACTIVE] ExecuteThread: '6' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1303284573151> <BEA-000000> <javax.security.auth.login.FailedLoginException: [Security:090302]Authentication Failed: User app.user denied
at weblogic.security.providers.authentication.LDAPAtnLoginModuleImpl.login(LDAPAtnLoginModuleImpl.java:229)
at com.bea.common.security.internal.service.LoginModuleWrapper$1.run(LoginModuleWrapper.java:110)
at java.security.AccessController.doPrivileged(Native Method)
...
更新 2
我现在执行了这些步骤并使身份验证工作:
- 在 WLS 控制台中添加
SQLAuthenticator
到默认领域“myrealm” - 在各自的提供程序设置中设置 Weblogic
DefaultAuthenticator
和新SQLAuthenticator
的SUFFICIENT
(“JAAS 控制标志”他们如何称呼它) - 重启 WLS
不过,还有一个问题:
问题
除了文件夹中的标准日志文件之外,WLS 是否还有一些额外的日志记录<domain>/server/AdminServer/logs
,我可以在其中看到发生了什么?我做错了什么/为了让我的基于表单的身份验证与我的应用程序一起工作,我错过了难题的哪一部分?- 当我在我的 中明确给出“app.realm”时,为什么 WLS 使用“myrealm”进行身份验证
web.xml
?
这是我的配置详细信息:
web.xml
...
<security-constraint>
<web-resource-collection>
<web-resource-name>Webapp Platform</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>USER</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>app-realm</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/login_error.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description>Standard user</description>
<role-name>USER</role-name>
</security-role>
...
weblogic.xml
<wls:weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wls="http://www.bea.com/ns/weblogic/weblogic-web-app"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app.xsd">
...
<security-role-assignment>
<role-name>USER</role-name>
<principal-name>WEBAPP_USER</principal-name>
</security-role-assignment>
</wls:weblogic-web-app>
登录.html
<html>
<head>
<title>Login</title>
</head>
<body>
<form method="POST" action="j_security_check">
<table>
<tr><td>Username:</td><td><input type="text" name="j_username"></td></tr>
<tr><td>Password:</td><td><input type="password" name="j_password"></td></tr>
<tr><td colspan=2 align=right><input type=submit value="Submit"></td></tr>
</table>
</form>
</body>
</html>