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 환경설정
필터 목록은 PR에 첨부하세요.
각 요청마다 통과하는 필터 목록을 확인할 수 있습니다.
🔒 CSRF 보호 설정하기
디스코드잇은 CSR 방식이기 때문에 CSRF 토큰은 다음과 같이 처리합니다.
클라이언트에서 페이지가 로드될 때 CSRF 토큰 발급 API를 명시적으로 호출
서버는 CSRF 토큰을 응답 헤더(Set-Cookie)를 통해 쿠키에 저장
클라이언트에서 매 요청마다 쿠키에 저장된 CSRF 토큰을 헤더(X-XSRF-TOKEN)에 포함
서버는 요청 헤더에 포함된 두 토큰 값(X-XSRF-TOKEN, Cookie)을 비교해 유효성 검증
CsrfTokenRepository 구현체를 CookieCsrfTokenRepository로 설정하세요.
디폴트 구현체는 HttpSessionCsrfTokenRepository입니다.
이때 클라이언트에서 쿠키에 저장된 CSRF 토큰에 접근해야 하므로 Http Only는 false로 설정합니다.
CsrfTokenRequestHandler 컴포넌트를 대체하세요.
Spring 공식문서에서 권장하는 CSR+SPA 환경에 적합한 구현체를 정의하세요.
CSRF 토큰을 발급하는 API를 구현하세요.
👤 회원가입
PasswordEncoder의 구현체는 BCryptPasswordEncoder를 활용하세요.
🔐 인증 - 로그인
DiscodeitUserDetailsService를 정의하세요.
DiscodeitUserDetails를 정의하세요.
(AuthApi.login, AuthController.login, AuthService.login, LoginRequest)
🧑💻 인증 - 세션을 활용한 현재 사용자 정보 조회
🚪 인증 - 로그아웃
204 Void 응답을 반환하세요.
🔑 인가 - 권한 정의
🧭 인가 - 권한 적용
(관리자 > 채널 매니저 > 일반 사용자)
⚙️ 심화
세션 관리 고도화
로그인 고도화 - RememberMe
(JSESSIONID 삭제 후 새로고침 시 인증 유지)
권한 적용 고도화
멘토에게