我的jboss-web.xml如下所示。
<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有以下几行。
<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代码如下
<form id="loginForm" method="POST" action="j_security_check">知道为什么会这样吗?
发布于 2015-11-17 09:30:12
您已经保护了应用程序服务器上的所有资源。在这种情况下,它意味着浏览器请求,例如"index.jsp“,并被重定向到登录页面。然后浏览器也尝试请求该图标(您在表单登录页面中指定了它吗?),但是由于它也受到保护,所以它再次被重定向到登录页(请与浏览器调试工具检查)。
您需要知道表单登录模块保存了上次请求的资源,这些资源在登录后作为重定向目标受到保护。在这种情况下,偏好图标请求将请求覆盖到"index.jsp“,因此登录后您将被重定向到该图标。
您需要将静态资源排除在安全约束之外。Here is how to do it.
应要求抽样:
<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>https://stackoverflow.com/questions/33752798
复制相似问题