authentication.adoc 1.0 KB

123456789101112131415161718
  1. [[servlet-authentication-authentication]]
  2. = Authentication
  3. The {security-api-url}org/springframework/security/core/Authentication.html[`Authentication`] serves two main purposes within Spring Security:
  4. * An input to <<servlet-authentication-authenticationmanager,`AuthenticationManager`>> to provide the credentials a user has provided to authenticate.
  5. When used in this scenario, `isAuthenticated()` returns `false`.
  6. * Represents the currently authenticated user.
  7. The current `Authentication` can be obtained from the <<servlet-authentication-securitycontext>>.
  8. The `Authentication` contains:
  9. * `principal` - identifies the user.
  10. When authenticating with a username/password this is often an instance of <<servlet-authentication-userdetails,`UserDetails`>>.
  11. * `credentials` - often a password.
  12. In many cases this will be cleared after the user is authenticated to ensure it is not leaked.
  13. * `authorities` - the <<servlet-authentication-granted-authority,``GrantedAuthority``s>> are high level permissions the user is granted.
  14. A few examples are roles or scopes.