TorbatYar/docs/architecture/security-architecture.md
Mortezakoohjani 12c8615615 Ship enterprise Accounting FE/API with CRUD parity and production wiring.
Adds accounting-service PATCH/archive, fiscal helpers, COA templates and setup status, plus SuperApp Accounting UI (DS, scoreboard, masters, vouchers, ledger, ops modules) with session refresh and HTTPS public API URLs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-24 15:26:43 +03:30

1.4 KiB

Security Architecture

Principles

  1. Least privilege per role and service token scope.
  2. Secrets only in environment / secret stores — never in git.
  3. Tenant isolation on every business query.
  4. Auditable business actions (audit log).
  5. TLS at the edge for all public hosts.

Authentication Surfaces

Surface Mechanism
Platform / tenant staff Keycloak OIDC JWT (RS256)
Local OTP (Core) HS256 JWT after SMS verify
Service-to-service Internal service token (hashed at rest)
Public tenant site Unauthenticated read of public theme/site data only

Token Rules

  • Frontend sends Authorization: Bearer <token>.
  • Services validate via shared JWT helpers (shared/auth/jwt.py).
  • Internal tokens carry scopes; callers must hold required scope.

Edge

Nginx enforces HTTPS for platform hosts; tenant hosts redirect to HTTPS when SSL map marks them ready. ACME challenge paths remain HTTP.

Data Protection

  • Passwords only in Keycloak (not Core).
  • OTP codes are short-lived (OTP_EXPIRE_SECONDS).
  • Token hashes stored for internal service tokens — raw tokens never persisted.