Spring Security Authentication

Spring Security  provides comprehensive support for Authentication. Spring security Authentication has various section like,


SecurityContextHolder and SecurityContext Understanding
SecurityContextHolder Object Overview

  • SecurityContextHolder: Spring Security Stores the details of who is authenticated. SecurityContextHolder uses a ThreadLocal to store authenticated user and authenticated principal. SecurityContextHolder uses ThreadLocal. Hence, We can access its details across the method.
  • SecurityContext: It contains the Authentication of the currently authenticated user. Spring Security does not care how the securityContextHolder is populated. If it contains a value, then it is used as the currently authenticated user. The SecurityContext is obtained from the SecurityContextHolder.
  • Authetication: Can be put input to AuthenicationManager to provide the credentials a user has provided to authenticate or the current user from the SecurityContext.

    The Authentication contains: principal, credentials and authorities.Principal identifies the user. When authenticating with userName/Passsword, it is an instance of UserDetails. Credentials means often a password. Authrorities means the GrantedAuthority are high level permission that user is granted.
  • GrantedAuthority: An authority that is granted to the principal on the authentication.



    Authentication Manager and behavior in Spring Security
    Authentication Manager relevancy 
  • AuthenticationManager: the API that defines how Spring Security's Filter perform authentication. The authentication that is returned set on SecuritContextHolder.
  • ProviderManager: It is the most common implementation of AutheticationManager. ProviderManager delegates to a List of Authenticationprovider. Each AuthenticionProvider has an opportunity to indicate that authentication should be successful, fail or indicate it cannot make a decision and allow a downstream AuthenticationProvider to decide.
  • AuthenticationProvider: It is used by ProviderManager to perform a specificType of authentication. Multiple AuthenticationProvider can be injected into ProviderManager. Each AuthenticationProvider perform a specific type of authentication.
  • Request Credential with AuthenticationEntryPoint: It is used for requesting credentials from a client. AuthenticationEntryPoint  is used to send an HTTP response that requests credentials from a client. Sometime a client will proactively include credentials such as a UserName/Password to request a resource. 

Comments

Popular posts from this blog

Maven Setting Mirror

Spring Session

Hibernate Version 5.0