我的要求是仅保护登录页面以保护用户凭据。成功登录后,用户可以在http模式下访问受限页面。 由于SSL过载,这是一项要求。用户需要访问包含大量数据的受保护页面。
我想知道是否可以这样做,尽管它不像维护https上下文那样安全。
这是我的配置:
<security:http auto-config="true">
<security:intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
<security:intercept-url pattern="/welcome*" access="ROLE_USER, ROLE_ADMIN" />
<security:form-login login-page="/login" authentication-failure-handler-ref="customAuthenticationFailureHandler" default-target-url="/welcome" />
<security:access-denied-handler ref="openIdAuthFailureHandler"/>
</security:http>
如果我尝试将/ login设置为https,则所有内容都处于https模式。我怎么能设法做到这一点?
编辑:
正如s.kwiotek建议我添加了requires-channel =&#34; http&#34;到其他网址模式:
<security:http auto-config="true">
<security:intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
<security:intercept-url pattern="/welcome*" access="ROLE_USER, ROLE_ADMIN" requires-channel="http"/>
<security:intercept-url pattern="/user/*" access="ROLE_USER, ROLE_ADMIN" requires-channel="http" />
<security:intercept-url pattern="/rest/*" access="ROLE_USER, ROLE_ADMIN" requires-channel="http" />
<security:intercept-url pattern="/admin/*" access="ROLE_ADMIN" requires-channel="http" />
<security:session-management session-fixation-protection="none"/>
<security:port-mappings>
<security:port-mapping http="8080" https="8443"/>
</security:port-mappings>
<security:form-login login-page="/login" authentication-failure-handler-ref="customAuthenticationFailureHandler" always-use-default-target="true" default-target-url="/user/home" />
<security:logout logout-success-url="/" />
<security:access-denied-handler ref="openIdAuthFailureHandler"/>
</security:http>
我添加了session-fixation-protection =&#34; none&#34;因为如果我只包含requires-channel =&#34; http&#34;它没有从登录中走得更远。我尝试登录但是我回到了登录状态。
如果我添加会话固定保护,它会转到用户的家中,但是在第二次登录尝试时。当您访问/ myapp / login时,会创建两个jsessionid:
JSESSIONID=5B37413F33DF0AA45F31D711754C3704; path=/myapp; domain=localhost
JSESSIONID=658F9F8669AF6B296A77D448C1A64B71; path=/myapp/; domain=localhost; HttpOnly
然后我尝试登录并返回登录,但网址不同:
https://myapp/login;jsessionid=C1EC352C42D6AC379DB1B65A9295E8A1
当jsessionid在URL中时,我尝试登录并成功重定向到用户主页(/ user / home)。如果我删除了session-fixation-protection,则jessesionid位于URL中,但我没有成功重定向到用户的家中。
我不知道是谁创造了两个第一个jsessionid以及如何解释这种行为。我唯一想做的就是通过ssl保护登录,然后通过http访问。
答案 0 :(得分:1)
(这应该是评论。但我的帐户信誉有限。)
&#xA;&#xA;您可能想重新考虑允许以http模式访问受限制的网页。
&#xA;&#xA;根据 http://www.troyhunt.com/2011/11/owasp-top-10-for-net-developers-part-9.html ,
&#XA;&#XA;&#XA;&#xA;许多人认为TLS纯粹是一种加密传输中敏感用户数据的方法。例如,您经常会看到登录表单通过HTTPS发布凭据,然后在其会话的剩余时间内将经过身份验证的用户发送回HTTP。我们的想法是,一旦密码成功受到保护,TLS就不再具有发挥作用。上面的示例显示需要保护整个经过身份验证的会话,而不仅仅是传输中的凭据。这是去年Firesheep教授的一个教训,可以说是Facebook实施在经过身份验证的会话中使用TLS的选择的催化剂。
&#xA;
答案 1 :(得分:0)
尝试示例:
<security:intercept-url pattern="/**" access="ROLE_USER" requires-channel="http"/>