fix(auth): RLS 활성화 후 프로필 조회·수정 500 오류 수정 - #209
Merged
Merged
Conversation
36 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
왜 필요한가요?
PostgreSQL RLS 활성화 후 배포 환경의 프로필 화면에서 다음 API가
500 Internal Server Error를 반환합니다.배포 환경에서 Demo 계정으로 로그인한 뒤 프로필 화면 진입 시 동일 오류를 재현했습니다.
원인은
AuthService.currentProfile()과updateProfile()이 transaction은 시작하지만,RLS가 사용하는 transaction-local tenant context인
app.company_id를 설정하지 않는 것입니다.이 상태에서는 인증된 JWT에 올바른
company_id가 있어도user_account조회가 RLS에 의해fail-closed 되어 현재 사용자 행을 찾지 못합니다.
Related: #34
무엇이 바뀌나요?
AuthService.currentProfile()에서 현재 인증 사용자의companyId를 tenant context에 설정합니다.AuthService.updateProfile()에도 동일한 tenant context 설정을 적용합니다.userId + companyIdRepository 조건과 권한 검사는 그대로 유지합니다.핵심 변경은 다음과 같습니다.
장애 영향
RLS 활성화 이후 다음 경로가 영향을 받습니다.
GET /api/v1/auth/me/profilePATCH /api/v1/auth/me/profile로그인,
/api/v1/auth/me, Worker/Task 등 기존 tenant context 적용 경로는 변경하지 않습니다.검증
GET /api/v1/auth/me/profile500 재현배포 후 Smoke
/profile진입 후 프로필 정보 정상 조회 확인이번 PR은 RLS를 비활성화하거나 우회하지 않고,
누락된 인증 프로필 transaction을 기존 tenant isolation 계약에 맞추는 핫픽스입니다.