forked from baron/baron-sso
3.4 KiB
3.4 KiB
Baron SSO Data SoT Architecture Policy
1. Core Principle: Ory Stack is the Single Source of Truth
Baron SSO에서 인증 identity, 권한 관계, OAuth/OIDC 위임의 원장은 Ory Stack입니다.
- Identity/profile 인증 원장: Ory Kratos
- Authorization/ReBAC 원장: Ory Keto
- OAuth/OIDC client, consent, token state 원장: Ory Hydra
Backend DB는 Ory를 대체하는 원장이 아닙니다. 특히 사용자 identity/profile/소속/조직도 노출 데이터에 대해 Backend DB users를 원장 또는 read model로 사용하지 않습니다. Ory와 무관한 감사 로그, 처리 상태, 외부 연동 작업 상태처럼 별도 원장이 명시된 데이터만 Backend DB에 둘 수 있습니다.
Ory에서 Redis cache로 웜업된 데이터는 Backend가 cursor 기반 API로 front 또는 외부 API에 제공합니다. frontend는 Redis나 Backend DB 복제본을 원장처럼 직접 소비하지 않습니다.
2. Component Policies
2.1 Identity & User Profile
- Ory Kratos identity가 subject, credentials, recovery/verification address, 인증 식별자의 원장입니다.
- Kratos identity 변경은 Backend의 중앙
IdentityWriteService를 경유해야 합니다. - Redis identity mirror는 빠른 단건/목록/검색 조회를 위한 cache입니다. stale 가능성을 API 응답에 드러내야 합니다.
- Backend DB
users는 사용자 identity/profile/소속 조회 read model이 아닙니다. 남은 의존은 제거 대상이며, 조회 API는 Kratos identity mirror 또는 Kratos Admin API fallback을 기준으로 해야 합니다.
2.2 Permissions & Relationships
- 권한 판단과 관계 tuple의 원장은 Ory Keto입니다.
- Backend DB는 relation command outbox, 처리 상태, 조직 표시/검색에 필요한 read model을 보관할 수 있습니다.
- 보안상 중요한 권한 판정은 Backend DB metadata나 token claim만으로 수행하지 않고 Keto check를 거쳐야 합니다.
2.3 OAuth2 Clients & Sessions
- OAuth2 client, consent, token state의 프로토콜 원장은 Ory Hydra입니다.
client_consents같은 Backend read model은 Hydra가 제공하지 않는 조회 축을 보완하기 위한 모델입니다.- client secret 원문처럼 Hydra가 해시만 보관하는 값은 재발급/운영 목적의 별도 보관 정책과 감사 로그를 가져야 합니다.
3. Data Flow & Synchronization Strategy
3.1 Write Path
- 클라이언트 또는 운영 도구가 Backend API/CLI를 호출합니다.
- Backend가 중앙 service를 통해 Ory API를 동기 호출합니다.
- Ory write 성공 후 Ory ID로 재조회합니다.
- Redis mirror를 갱신하거나 갱신 실패 시
stale/failed상태를 기록합니다. - 사용자 identity/profile/소속 데이터는 Backend DB
users에 read model로 갱신하지 않습니다. Ory와 별도 원장이 명시된 처리 상태만 Backend DB에 기록합니다.
3.2 Read Path
- Self context: Ory session/token 또는 Ory API를 기준으로 검증합니다.
- Admin/list context: Backend가 Redis identity mirror 또는 Ory Admin API fallback을 기준으로 cursor 기반 API를 제공합니다.
- API response는
identityTotal, read model count, mirror status를 구분해야 합니다.
3.3 Conflict Resolution
불일치가 발견되면 Ory Stack의 데이터를 기준으로 Redis mirror를 보정합니다. Backend DB users나 token claim assembly 결과를 Ory보다 우선하는 근거로 사용하지 않습니다.