首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关于JSecurity检查的问题

关于JSecurity检查的问题
EN

Stack Overflow用户
提问于 2015-11-17 09:01:10
回答 1查看 323关注 0票数 0

我的jboss-web.xml如下所示。

代码语言:javascript
复制
<jboss-web>
    <security-domain>java:/jaas/test</security-domain>
    <valve>
        <class-name>com.test.WebFormAuthenticator</class-name>
        <param>
            <param-name>landingPage</param-name>
            <param-value>/index.html</param-value>
        </param>
    </valve>
    <context-root>mycontext</context-root>
</jboss-web>

我的web.xml有以下几行。

代码语言:javascript
复制
<login-config>
        <auth-method>FORM</auth-method>
        <realm-name>test</realm-name>
        <form-login-config>
            <form-login-page>/login.html</form-login-page>
            <form-error-page>/loginError.html</form-error-page>
        </form-login-config>
    </login-config>
<security-constraint>
        <web-resource-collection>
            <web-resource-name>My Application</web-resource-name>
            <url-pattern>/rest/*</url-pattern>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>*</role-name>
        </auth-constraint>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>My Application</web-resource-name>
            <url-pattern>/bower_components/*</url-pattern>
            <url-pattern>/scripts/*</url-pattern>
        </web-resource-collection>
    </security-constraint>

当登录成功而不是index.html成功时,url将更改为index.html

所使用的html代码如下

代码语言:javascript
复制
<form id="loginForm" method="POST" action="j_security_check">

知道为什么会这样吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-17 09:30:12

您已经保护了应用程序服务器上的所有资源。在这种情况下,它意味着浏览器请求,例如"index.jsp“,并被重定向到登录页面。然后浏览器也尝试请求该图标(您在表单登录页面中指定了它吗?),但是由于它也受到保护,所以它再次被重定向到登录页(请与浏览器调试工具检查)。

您需要知道表单登录模块保存了上次请求的资源,这些资源在登录后作为重定向目标受到保护。在这种情况下,偏好图标请求将请求覆盖到"index.jsp“,因此登录后您将被重定向到该图标。

您需要将静态资源排除在安全约束之外。Here is how to do it.

应要求抽样:

代码语言:javascript
复制
<security-constraint>
  <web-resource-collection>
    <web-resource-name>app</web-resource-name>
    <url-pattern>/src/assets/*</url-pattern>
  </web-resource-collection>
  <!-- OMIT auth-constraint -->
</security-constraint>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33752798

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档