Java 设置反向安全约束
我正在尝试向后设置安全约束。我想说,除了我指定的页面之外,所有页面都需要登录。我使用:Java 设置反向安全约束,java,security,jsp,Java,Security,Jsp,我正在尝试向后设置安全约束。我想说,除了我指定的页面之外,所有页面都需要登录。我使用: <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>*&
<security-constraint>
<web-resource-collection>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
/*
*
但是我不知道如何说index.jsp不需要登录 放置所有安全页面
/secure
并将安全筛选器配置为/secure/*
,或者在筛选配置中创建排除。以下示例基于spring security:
<http auto-config='true'>
<intercept-url pattern="/index.jsp*" filters="none"/>
</http>
简单的答案是,使用web.xml无法实现这一点(可以说是一件好事,因为安全机制最好尽可能简单)。正如@Johan所说,保护一些url模式,如/secure/*
或/app/*
,并将所有页面放在那里。虽然这是100%正确的,但OP询问的是web.xml部署描述符,并没有表明他们正在使用spring安全性。由于web.xml约束是在容器级别强制执行的,因此这两种方法也不容易混合使用。