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

问题描述 投票:0回答:1

按照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)

此时卡住。登录停止工作。

帮助?

java wildfly forms-authentication
1个回答
0
投票

您的用例可在我的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配置对管理接口有效,与应用程序安全性无关。 (或者至少不应该这样。如果是,那就是一个错误。)

© www.soinside.com 2019 - 2024. All rights reserved.