Jin's Dev Story

[Spring Security] Authentication의 메커니즘 본문

Web & Android/Spring Security

[Spring Security] Authentication의 메커니즘

woojin._. 2023. 10. 17. 16:01

  • Authentication에는 인증된 결과 뿐만 아니라 인증을 하기 위한 정보, 인증을 받기 위한 정보가 하나의 객체에 들어가 있음
  • AuthenticationProvider는 입력된 인증을 보고 허가된 인증을 내주는 방식으로 인증 허가를 판단하며 처리 가능한 Authentication에 대해서 알려주는 support메서드를 지원
  • Authorities에는 '어디를 갈 수 있는지', '어떤 역할을 할 수 있는지'에 대한 권한 정보로 이를 구현(implement)한 GrantedAuthority에 관한 정보들이 저장되어있음
  • Authentication에 들어가 있는 Token들은 각각의 Filter들을 통해 발행된 Token들
  • Credentials은 인증을 받기 위해 필요한 정보들로 대표적인 예시로는 비밀번호
  • Principal은 인증된 결과에 대한 정보. credentials를 이용해 인증을 받고 그 결과임
  • Details은 위의 정보 외의 인증에 관여된 주변 정보들을 갖고 있음

AuthenticationProvider

  • Authentication을 제공하는 것을 Authentication Provider
  • Authentication Provider는 credentials나 Principal이 있는 Authentication을 받아서 인증을 하고 인증된 결과를 다시 Authentication객체로 전달하는 역할
  • 이때 Authentication Provider는 어떤 인증에 대해 승인을 해줄지 Authentication Manager에게 알려줘야 하기 때문에 support()라는 메서드를 제공
  • Authentication Manager은 인증 대상과 방식이 다양할 수 있어 여러개일 수 있음