Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
기본 요구사항
Spring Security 환경설정
프로젝트에 Spring Security 의존성을 추가하세요.
Security 설정 클래스를 생성하세요.
SecurityFilterChain Bean을 선언하세요.
가장 기본적인 SecurityFilterChain을 등록하고, 이때 등록되는 필터 목록을 디버깅해보세요. 필터 목록은 PR에 첨부하세요.
CSRF 보호 설정하기
CSRF 토큰을 발급하는 API를 구현하세요.
회원가입
인증 - 로그인
Spring Security의 formLogin 인증 흐름은 그대로 유지하면서 필요한 부분만 대체합니다.
이번 미션에서는 보라색 음영 처리된 5가지 컴포넌트를 대체합니다.
각 컴포넌트의 기본 구현체가 무엇인지 디버깅해보세요.
추가된 필터
UsernamePasswordAuthenticationFilter: 폼 로그인 요청(POST /login 등)에서 아이디/비번을 읽어 인증 시도.
DefaultResourcesFilter: 기본 로그인/로그아웃 페이지에서 쓰는 정적 리소스 제공.
DefaultLoginPageGeneratingFilter: 커스텀 로그인 페이지를 안 만들었을 때 기본 로그인 페이지 HTML 생성.
DefaultLogoutPageGeneratingFilter: 기본 로그아웃 페이지 HTML 생성.
로그인을 처리할 url을 /api/auth/login로 설정하세요.
UserDetailsService 컴포넌트를 대체하세요.
인증 정보(Principal)에 담을 수 있는 정보를 자유롭게 확장할 수 있습니다.
UserDto와 비밀번호 정보를 저장하세요.
앞서 정의한 DiscodeitUserDetailsService에서 DiscodeitUserDetails를 생성 후 반환하세요.
AuthenticationSuccessHandler 컴포넌트를 대체하세요.
인증 - 세션을 활용한 현재 사용자 정보 조회
인증 - 로그아웃
Spring Security의 logout 흐름은 그대로 유지하면서 필요한 부분만 대체합니다.
이번 미션에서는 2가지 요소를 대체합니다.
로그아웃을 처리할 url을 /api/auth/logout로 설정하세요.
인가 - 권한 정의
인가 - 권한 적용
Service의 메소드 별로 아래의 조건에 맞게 권한을 수정하세요.
적절한 권한이 없는 경우 403 응답을 반환하세요.
심화 요구 사항
세션 관리 고도화
세션의 동일성을 보장하기 위해 DiscodeitUserDetails의 equals(), hashcode() 메소드를 오버라이딩하세요.
권한이 변경된 사용자가 로그인 상태라면 세션을 무효화하세요.
로그인 고도화 - RememberMe
권한 적용 고도화