You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. 사용자가 로그인 요청을 보냄
2. AuthController
- 로그인 요청에 username, password
- UsernamePasswordAuthenticationToken 생성
- 아직 인증되지 않은 상태(authenticated=false)
- AuthenticationManager가 AuthenticationProvider에게 인증 요청
3. AuthenticationManager
- 이때 AuthenticationManager는 CustomAuthenticationProvider를 갖고 있고, 얘가 처리
- AuthenticationManager.authenticate(), 인증 시도
- AuthenticationProvider에게 실제 인증 작업을 위임
- AuthenticationProvider가 loadUserByUsername(username)
- UserDetailsService는 DB에서 사용자 정보를 읽어서 사용자 정보(UserDetails)를 가져옴
- 전달된 UserDetail 정보로 AuthenticationProvider가 비밀번호 검증
4. UsernamePasswordAuthenticationToken
- 인증에 성공하면 UsernamePasswordAuthenticationToken을 authenticated=true로 변경
- SecurityContextHolder에 인증 정보 저장
5. TokenService
- JWT 토큰 생성 및 반환
1. 사용자가 권한이 필요한 요청을 보냄
2. OncePerRequestFilter
- Header에서 Jwt 꺼내서 Claim의 사용자 정보 파악 (유저네임, 활성 상태, 권한, 어드민 여부)
- 이를 UserDetail로 만들어 SecurityContextHolder에 인증 정보 저장
3. UserController
- Spring security는 이 정보를 바탕으로 PreAuthorize, 인가 처리
- 인증된 사용자 정보는 SecurityContextHolder에서 가져와서 활용 가능
The text was updated successfully, but these errors were encountered:
연휴 동안 만들어보기
내 코드를 기준으로!
The text was updated successfully, but these errors were encountered: