1
0
forked from baron/baron-sso
Files
baron-sso/docs/SoT_Architecture_Policy.md

3.1 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를 대체하는 원장이 아닙니다. Ory에 저장되지 않거나 Ory API로 필요한 방식의 조회가 불가능한 업무 데이터의 read model, 감사 로그, 처리 상태, 성능 cache 보조 데이터만 허용합니다.

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는 Ory에 저장되지 않거나 Ory에서 필요한 방식으로 조회할 수 없는 Baron 운영 데이터의 read model입니다.

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

  1. 클라이언트 또는 운영 도구가 Backend API/CLI를 호출합니다.
  2. Backend가 중앙 service를 통해 Ory API를 동기 호출합니다.
  3. Ory write 성공 후 Ory ID로 재조회합니다.
  4. Redis mirror를 갱신하거나 갱신 실패 시 stale/failed 상태를 기록합니다.
  5. Ory에 저장되지 않거나 조회 불가능한 read model만 Backend DB에 갱신합니다.

3.2 Read Path

  • Self context: Ory session/token 또는 Ory API를 기준으로 검증합니다.
  • Admin/list context: Backend가 Redis mirror와 허용된 read model을 조합해 cursor 기반 API로 제공합니다.
  • API response는 identityTotal, read model count, mirror status를 구분해야 합니다.

3.3 Conflict Resolution

불일치가 발견되면 Ory Stack의 데이터를 기준으로 Redis mirror와 Backend read model을 보정합니다. Backend read model이나 token claim assembly 결과를 Ory보다 우선하는 근거로 사용하지 않습니다.