码迷,mamicode.com
首页 > 编程语言 > 详细

Spring security

时间:2015-04-08 19:58:06      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:spring security

Spring security is based on URL pattern, each URL pattern has an associated chain of interceptors that handles various aspect of security


Eg.  <security:http pattern="/_ui/**" security="none" />     no security control


<security:http disable-url-rewriting="true" pattern="/checkout/**" use-expressions="true">
    <security:anonymous username="anonymous" granted-authority="ROLE_ANONYMOUS" />
    <security:access-denied-handler error-page="/login"/>
    <security:session-management session-authentication-strategy-ref="fixation" />
    .....
</security:http>        requires security control


Security:anonymous :

Still assign a user name and role for urls that does not require security control. Managed by AnonymousAuthenticationFilter and AnonymousAuthenticationProvider. An AnonymousAuthenticationToken is added into SecurityContextHolder. An AnonymousAuthenticationFilter is associated with an AnonymousAuthenticationProvider by a key/value pair.

AuthenticationTrustResolver used by the auth exception handler to distinguish between anonymous user, remember me user and normal user. The exception handler redirects to authentication entry point for anonymous user. Also used by authentication voter


Security:access-denied-handler:

Return to an error page if access is denied, usually redirects to login page


Security:intercept-url
Performs security control  based on role or allowed channel (http, https etc)


Security:session-management

SessionManagementFilter checks whether user has been authenticated by retrieving SecurityContextHolder from SecurityContextRepository. If a valid SecurityContextHolder exists, it invokes SessionAuthenticationStrategy. Otherwise, it invokes InvalidSessionStrategy, which usually just performs redirection (SimpleRedirectInvalidSessionStrategy)


Fixation protection: SessionFixationProtectionStrategy, create a new session and copy all attributes, this prevents session hijacking.


ConcurrentSessionControlAuthenticationStrategy: check number of sessions created by user, throw exception or invalidate existing session on exceed


Security:form-login
Login-processing-url:   (default /j_spring_security_check) specifies the url pattern of the filter that handles authentication request. Handled by UsernamePasswordAuthenticationFilter and delegates to authenticationManager to perform actual authentication. See CoreAuthenticationProvider and CoreUserDetailService for basic authentication logic. See AcceleratorAuthenticationProvider  which adds additional check on brutal force attack and shopping cart ownership

login-page:  the login page

authentication-failure-handler-ref:  handles authentication failure. See LoginAuthenticationFailureHandler: This performs redirect

authentication-success-handler-ref:  See GUIDAuthenticationSuccessHandler:  set the cookie, reset brutal force attack counter and handles cart creation. By default, spring security performs redirection on previously remembered resource url if any. See SavedRequestAwareAuthenticationSuccessHandler


Security:request-cache
Used to remember previously accessed url  before login page shows, see also SavedRequestAwareAuthenticationSuccessHandler

Spring security

标签:spring security

原文地址:http://shadowisper.blog.51cto.com/3189863/1630147

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!