【发布时间】:2025-12-17 20:50:01
【问题描述】:
场景
我们正在使用 Weblogic Server 10.3.4 运行我们的 web 应用程序,该应用程序启用了安全约束,以要求用户在他/她可以使用该应用程序之前登录。用户和组信息应驻留在应用程序数据库中,身份验证应由 WLS(容器)处理。
我已将数据库架构设置为described in this blog article,在 WLS 控制台中设置了一个新的安全领域“app.realm”,并在其中定义了一个 SQLAuthenticator。
重新启动 WLS 后,我可以在 WLS Web 控制台的“app.realm”中查看数据库中的用户和组定义。我要验证的用户是 WEBAPP_USER 组的成员(我在 WLS 控制台的用户详细信息页面上看到了组成员身份)。
当我部署应用程序(使用标准设置,未在 WLS Web 控制台中进行调整)并调用受保护的 URL 时,我会按预期重定向到 login.html 表单。但是,无论我尝试什么,输入(正确的)密码总是会导致身份验证失败,将我发送到login_error.html 页面。出于调试目的,我在SQLAuthenticator 中启用了纯文本密码,因此我很确定使用了正确的凭据。
我已经看到 these two 线程,但似乎都没有帮助解决我的问题。
更新 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
我现在执行了这些步骤并让身份验证工作:
- 将
SQLAuthenticator添加到 WLS 控制台中的默认领域“myrealm” - 在各自的提供程序设置中将 Weblogic 的
DefaultAuthenticator和新的SQLAuthenticator设置为SUFFICIENT(“JAAS 控制标志”他们如何称呼它) - 重启 WLS
还有一个问题:
问题
除了<domain>/server/AdminServer/logs文件夹中的标准日志文件之外,WLS 是否还有一些额外的日志记录,我可以在其中查看发生了什么?我做错了什么/为了让我的基于表单的身份验证与我的应用程序一起工作,我错过了什么难题?- 当我在
web.xml中明确提供“app.realm”时,为什么 WLS 使用“myrealm”进行身份验证?
这是我的配置详情:
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>
login.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>
【问题讨论】:
-
你能发布你的 login.html 页面吗?只是它的登录表单部分就足够了。此外,您的用户是否属于您的安全配置中的 WEBAPP_USER 组?除此之外,正如 emzy 所建议的那样,如果您为调试树的 weblogic/security/atn 子部分启用调试,这将为您提供一些关于登录尝试发生的情况的相当有针对性的信息。
-
@kevinpowe 感谢您的评论,我添加了上面的详细信息(登录表单和用户成员资格)以进行澄清。是的,用户是
WEBAPP_USER组的成员。 -
我知道这是几年前的,但我想我会添加这个,以防其他人像我一样偶然发现这个页面。 “login-config”中的“realm”标签不是你想的那样:“注意:
元素不引用 WebLogic Server 中的系统安全领域。该元素定义了在 HTTP Basic 中使用的领域名称授权。” (docs.oracle.com/cd/E13222_01/wls/docs81/webapp/…) 也就是说,它只与作为 BASIC 的 结合使用。
标签: java security weblogic container-managed