gpt4 book ai didi

启用 RBAC 时,Java 表单登录不起作用

转载 作者:行者123 更新时间:2023-12-01 19:50:03 24 4
gpt4 key购买 nike

遵循 https://docs.oracle.com/cd/E19226-01/820-7627/bncby/index.html 上的文档我的表单登录工作正常。

我尝试了各种变体:首先,带有 action="j_security_check" 的表单。其次,在JSP中使用它:

<%
if(request.getRemoteUser() == null ){
try{
request.login("hussain", "mypassword");
out.println( "Logged in" );
}catch(Exception e){
out.println( "Error: " + e.getMessage() );
}
}else{
out.println( request.getRemoteUser() + " is already logged in");
}
%>

我在 Windows 上使用 WildFly 12。

我使用 add-user.bat 添加了用户。用户被添加到\standalone\configuration\application-users.properties。我在 web.xml 中保护了一个页面:

    <security-constraint>
<display-name>SecurityConstraint</display-name>
<web-resource-collection>
<web-resource-name>WRCollection</web-resource-name>
<url-pattern>/test.jsp</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>AuthConstraint</description>
<role-name>TutorialUser</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login</form-login-page>
<form-error-page>/loginerror</form-error-page>
</form-login-config>
</login-config>

<security-role>
<role-name>TutorialUser</role-name>
</security-role>

除非我登录,否则/test.jsp 不会显示。所以,一切都很好。

接下来,我使用以下方法启用了基于角色的身份验证:

cd /core-service=management/access=authorization
:write-attribute(name=provider, value=rbac)

卡在这一步了。登录停止工作。

帮忙?

最佳答案

您的用例适用于我的 Linux 计算机。您可以尝试启用详细的安全日志记录,并从日志输出中查找问题所在。

这些是用于重新配置日志记录的 JBoss CLI 命令:

/subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=ALL)
/subsystem=logging/logger=org.jboss.security:add(level=ALL)
/subsystem=logging/logger=org.jboss.as.security:add(level=ALL)
/subsystem=logging/logger=org.picketbox:add(level=ALL)
/subsystem=logging/logger=org.apache.catalina.authenticator:add(level=ALL)
/subsystem=logging/logger=org.jboss.as.web.security:add(level=ALL)
/subsystem=logging/logger=org.jboss.as.domain.management.security:add(level=ALL)
/subsystem=logging/logger=org.wildfly.security:add(level=ALL)
顺便说一句。 RBAC 配置仅针对管理界面有效,与应用程序安全无关。 (或者至少不应该是这样。如果是,那么它就是一个错误。)

关于启用 RBAC 时,Java 表单登录不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59094227/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com