feat(db): PostgreSQL RLS 도입 기반과 제한 role 검증 추가#47
Merged
Conversation
- runtime과 Flyway 데이터베이스 연결 계정을 분리 - PostgreSQL 전용 migration location 설정 - 트랜잭션 단위 tenant context 어댑터 추가 - connection pool tenant context 비누수 테스트 추가 - RLS 단계적 도입 및 복구 절차 문서화
- V1~V5의 12개 tenant 테이블에 runtime DML 권한 검증 적용 - TRUNCATE, REFERENCES, DDL 및 RLS 우회 권한 차단 확인 - RLS 단계적 도입 문서에 현재 검증 대상 테이블 반영
- 최신 공통 migration 범위를 V1~V6로 수정
36 tasks
hywznn
approved these changes
Jul 24, 2026
hywznn
left a comment
Contributor
There was a problem hiding this comment.
로컬용이랑 배포용이랑 구현이 나뉘었다고 판단하면 될 것같군요 수고하셨씁니다 !
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를 안전하게 도입하려면 실제 정책을 활성화하기 전에 Flyway와
애플리케이션의 DB 연결을 분리하고, transaction-local tenant context 및 connection
pool 비누수를 먼저 검증해야 합니다.
이 PR은 #34 전체 구현 중 foundation 단계만 다룹니다. 실제 bootstrap 함수, RLS
policy 및 RLS 활성화는 후속 PR에서 진행합니다.
무엇이 바뀌나요?
app.company_id를 설정하는 tenant context adapter를추가했습니다.
검증했습니다.
SUPERUSER,BYPASSRLS, table owner, DDL,TRUNCATE,REFERENCES권한이없음을 테스트했습니다.
.env.example에 runtime/Flyway 계정 환경변수 이름을 분리했습니다.어떻게 검증했나요?
./gradlew clean test./gradlew build/health와 Swagger UI 확인테스트 환경과 결과:
.\gradlew.bat clean test.\gradlew.bat build: BUILD SUCCESSFUL제한된 DB runtime role의 권한 부족과 transaction-local context의 connection pool
비누수를 검증했습니다. 실제 RLS policy가 아직 없으므로 다른 사업장 행의 CRUD 차단은
후속 PR에서 검증합니다. API 및 Workflow 변경이 없어 요청 입력과 상태 전이 항목은
이번 PR 범위가 아닙니다.
보안·개인정보
company_id범위를 검사합니다.request_id로 추적됩니다.Proposed로작성했습니다.
ADR-0004의 transaction-local context, 계정 분리, migration location 분리 및 단계적
RLS 활성화 결정을 따릅니다.
이번 PR은 업무 API나 감사 대상 상태를 변경하지 않으므로 AuditLog 이벤트를 추가하지
않았습니다. 실제 서비스 transaction과 RLS policy가 아직 연결되지 않아 전체 사업장
접근 검사는 후속 PR에서 완료합니다.
API·DB·운영 영향
않았습니다.
.env.example에 적었습니다.Client API 호환성 변경은 없습니다.
PostgreSQL
dev·prod실행 환경은 다음 변수를 분리해 제공해야 합니다.DB_RUNTIME_USERNAMEDB_RUNTIME_PASSWORDDB_MIGRATION_USERNAMEDB_MIGRATION_PASSWORD신규 schema migration은 없으며 현재 마지막 공통 migration은 V6입니다.
PostgreSQL 전용 RLS migration 번호는 후속 구현 직전에 최신
main과 진행 중인 PR을다시 확인해 선택합니다. 실제 DB role 생성, 최소 GRANT 및 Secret 주입은 #9와
조율합니다.
Smoke Test와 forward-only 복구 절차를 문서화했습니다. 실제 staging 적용과 Smoke
Test 실행은 #9 및 RLS 활성화 후 진행합니다.
화면 또는 응답 예시
API 및 화면 변경이 없어 첨부하지 않습니다.