【问题标题】:Authentication without Role in web.xml in JBoss AS 7JBoss AS 7 中 web.xml 中没有角色的身份验证
【发布时间】:2012-01-21 02:06:39
【问题描述】:

对于 RESTful 企业应用程序,我需要对所有调用进行身份验证,但我无法提供系统的所有用户都拥有的公共组/角色。我通过 LDAP 进行身份验证和授权(这对这个问题没有影响)。

如果我在下面的 web.xml 中将元素注释掉,我根本不会获得任何身份验证。如何在不需要通用角色的情况下进行身份验证?此外,空的身份验证约束不起作用。

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee       http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <!-- fpe: This one is necessary. -->
        <param-name>resteasy.role.based.security</param-name>
        <param-value>true</param-value>
    </context-param>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Resteasy</web-resource-name>
            <url-pattern>/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>PUT</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
<!--        <auth-constraint> -->
<!--            <role-name>*</role-name> -->
<!--        </auth-constraint> -->
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>Login</realm-name>
    </login-config>
<!--    <security-role> -->
<!--        <role-name>the_common_role</role-name> -->
<!--    </security-role> -->
</web-app>

【问题讨论】:

    标签: authentication restful-authentication web.xml jboss7.x


    【解决方案1】:

    正确使用 * 就可以了:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee       http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
        <context-param>
            <!-- fpe: This one is necessary. -->
            <param-name>resteasy.role.based.security</param-name>
            <param-value>true</param-value>
        </context-param>
        <security-constraint>
            <web-resource-collection>
                <web-resource-name>Resteasy</web-resource-name>
                <url-pattern>/*</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
                <http-method>PUT</http-method>
                <http-method>DELETE</http-method>
            </web-resource-collection>
            <auth-constraint>
                <role-name>*</role-name>
            </auth-constraint>
            <user-data-constraint>
                <transport-guarantee>CONFIDENTIAL</transport-guarantee>
            </user-data-constraint>
        </security-constraint>
        <login-config>
            <auth-method>BASIC</auth-method>
            <realm-name>Login</realm-name>
        </login-config>
        <security-role>
            <role-name>*</role-name>
        </security-role>
    </web-app>
    

    【讨论】:

      猜你喜欢
      • 2013-04-15
      • 2012-05-13
      • 2016-11-13
      • 1970-01-01
      • 2021-03-10
      • 2012-02-08
      • 2016-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多