【问题标题】:Correct path to static resources in order to omit them from authorization-constraint正确的静态资源路径,以便从授权约束中省略它们
【发布时间】:2021-06-15 21:07:48
【问题描述】:

我有一个使用 websphere 的 java ee-struts 应用程序,如果用户未登录,一切都会受到限制。即使是像 css 和图像这样的静态资源。我想不限制访问 2 件事,style.css 和 @ 987654323@ 文件,以便它们无需注册即可使用。我发现这篇帖子here 显示了如何做到这一点,但我不知道如何编写确切的路径来指定我需要的 2 个资源中的每一个。有人可以根据文件夹向我提供确切的路径我提供的结构?谢谢

这是我拥有的限制一切的代码。这是来自位于我的模块的 WEB-INF 文件夹中的 web.xml 文件。

<security-constraint>
   <display-name>ABC_Access<display-name>
   <web-resource-collection>
       <web-resource-name>All_resources</web-resource-name>
       <url-pattern>/*</url-pattern>
   <web-resource-collection>
   <auth-constraint>
       <description>all_authent</description>
       <role-name>all</role-name>
   </auth-constraint>
</security-constraint>

我的文件夹结构是:

src>main>webapp>WEB-INF>web.xml
               >css>style.css
               >images>blue_logo.gif

【问题讨论】:

    标签: java authentication websphere web.xml


    【解决方案1】:

    你应该有像这样的附加约束,没有auth-constraint。勾选这个——“如果没有授权约束,容器必须接受请求而不需要用户认证。” Specifying an Authorization Constraint

    <security-constraint>
       <display-name>Unprotected resources<display-name>
       <web-resource-collection>
           <web-resource-name>unprotected_resources</web-resource-name>
           <url-pattern>/images/*</url-pattern>
           <url-pattern>/css/*</url-pattern>
       <web-resource-collection>
        <!-- do not provide auth-constraint -->
    </security-constraint>
    

    【讨论】:

      猜你喜欢
      • 2014-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-15
      • 1970-01-01
      • 2017-05-30
      • 1970-01-01
      相关资源
      最近更新 更多