Securiry 인증순서 > 스프링 부트

본문 바로가기

[이론] Securiry 인증순서

필기자
2022-11-03 16:12 1,920 0

본문

Securiry 인증순서

1. UserDetailsService에서 사용자의 정보를 조회, UserDetails로 반환하여 AuthenticationsProvider에게 전달

UserDetailsService의 loadUserByUserName(string) 메소드로 db에서 사용자 정보를 조회 후 UserDetails객체로 변환

2. ProviderManager에서 AuthenticationProvider에게 인증을 위임

AuthenticationProvider에서는 UserDetailsService, UserDetails, PasswordEncoding등을 이용하여 조회한 사용자와 접속사용자 비교 후 인증처리

3. 인증에 성공하면 Authentication 객체를 리턴. 리턴한 Authentication은 SecurityContext에 저장, 클라이언트에 session id(JSESSIONID)를 전달.

4. 클라이언트는 전달받은 JSESSIONID로 최종 인증 완료

 

20221103160922_b7e01d0501d844f992b5c6d5592b1e1a_liq4.png

 



<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layouts/layout1}">

<div layout:fragment="content">
  <h1>상품등록 페이지입니다.</h1>
  <p th:text="${#authentication.name}"></p>
  <p th:text="${#authentication.getDetails().getRemoteAddress()}"></p>
</div>
</html>

최종 로그인된 사용자 정보는 위 코드에서

${#authentication.name}, ${#authentication.getDetails()} 등으로 알수 있음

 

댓글목록0

등록된 댓글이 없습니다.
게시판 전체검색