Skip to main content

08 โ€” Security Architecture

Status: ๐Ÿ”ง Partial โ€” confirmed principles from TD6 documented; implementation specifics pending Infrastructure and Security sessions
Prerequisite: TD6, 06 โ€” Authentication Flow, 07 โ€” Authorization Model

Full security design for the Miqaat Core Platform โ€” network topology, TLS, secret management, API Gateway security, audit log design, encryption at rest, and incident response.

Sections marked โณ are blocked on the Dedicated Infrastructure session or Dedicated Security session. Confirmed principles from TD6 are written as fixed decisions.


1. Security Posture (Confirmed from TD6)โ€‹

The following are confirmed security principles. They are not subject to revision without a TD6 amendment.

PrincipleDetail
Single entry pointAll external traffic reaches Core through the API Gateway only. No Core engine is directly reachable from outside the private network.
Zero trust between modules and CoreEvery module request is authenticated and authorised at the Gateway โ€” no implicit trust based on network location.
Credentials never reach enginesThe Identity Bridge strips all credentials before forwarding requests. Engines only see clean headers.
Read/write split enforced at GatewayModule API keys are rejected on write endpoints at the Gateway โ€” no write request from a module reaches an engine.
Immutable audit trailEvery state-changing operation across all Core engines is written to the Audit Log. Audit records cannot be modified or deleted โ€” append only.
Secrets not in config filesAPI keys, database credentials, and signing keys are never stored in application config files or source code. Secrets are injected at runtime from a dedicated secrets store.
TLS everywhereAll traffic โ€” external (module to Gateway) and internal (Gateway to engine, engine to engine) โ€” is encrypted in transit. No unencrypted HTTP inside the platform network.
Principle of least privilegeEach Core engine only holds credentials and network access for the data stores and services it directly needs. No engine has blanket access to the full platform.

2. Network Topologyโ€‹

โณ Exact topology โ€” pending Infrastructure session (cloud provider, VPC design, subnet layout)

Confirmed structureโ€‹

Internet
โ”‚
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ API Gateway โ”‚ โ† Only component with public IP
โ”‚ (+ Identity โ”‚
โ”‚ Bridge) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ Private network only
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Core Private Network โ”‚
โ”‚ โ”‚
โ”‚ RBAC Engine Eligibility Engine โ”‚
โ”‚ Config Cascade Miqaat Lifecycle โ”‚
โ”‚ Allocation Zone Mapping โ”‚
โ”‚ Vendor Registry HR Bank โ”‚
โ”‚ Capacity Balance Task Engine โ”‚
โ”‚ Audit Log Notification Dispatch โ”‚
โ”‚ ITS Sync Event Schema Registry โ”‚
โ”‚ โ”‚
โ”‚ Data stores (per-engine, not shared) โ”‚
โ”‚ Event Bus โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

What this means:

  • Modules call https://core.miqaat.platform/v1/... โ€” this resolves to the API Gateway's public endpoint
  • The API Gateway is the only component with an externally reachable address
  • Core engines have no public IP or DNS โ€” they are unreachable except from within the private network
  • The event bus is also internal โ€” modules do not connect to the event bus directly; they publish via the Gateway or consume via a managed subscription endpoint

โณ TBC in Infrastructure session: whether the private network is a cloud VPC, an on-premises network segment, or a hybrid. Also: whether the Gateway is a managed cloud service or self-hosted, and what the high-availability configuration is.


3. TLS and Certificate Managementโ€‹

Confirmed: all traffic is TLS-encrypted. No plaintext HTTP anywhere.

SegmentTLS requirement
Module โ†’ API GatewayTLS 1.2 minimum, TLS 1.3 preferred
API Gateway โ†’ Core engines (internal)TLS required โ€” internal traffic is not exempt
Engine โ†’ data storeTLS required where the data store supports it
Engine โ†’ event busTLS required

โณ TBC in Infrastructure session:

  • Certificate authority (managed cloud CA vs Let's Encrypt vs internal CA)
  • Certificate rotation policy and tooling
  • Whether mTLS (mutual TLS) is required on internal engine-to-engine calls
  • TLS termination point โ€” does the Gateway terminate and re-encrypt, or pass through?

4. Secret Managementโ€‹

Confirmed from TD6: secrets are never in config files or source code. All credentials are injected at runtime.

Secret typeExamples
Database credentialsEngine-specific DB username and password
API keys (inbound)Module API keys issued by Platform Admin
Signing keysITS token public key for JWT validation
Event bus credentialsPer-engine topic access credentials
Internal service credentialsEngine-to-engine call credentials

Principle: each engine's runtime environment receives only the secrets it needs. No engine has access to another engine's database credentials or internal keys.

โณ TBC in Infrastructure session:

  • Secrets management tooling (HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, or similar)
  • Secret rotation schedule and automation
  • Who has access to the secrets store (Core technical team only vs ops team access)
  • Audit logging of secret access

5. API Gateway Securityโ€‹

The API Gateway is the security enforcement layer. Everything documented here is confirmed from TD2 and TD3.

Enforced at Gateway โ€” no engine involvement neededโ€‹

ControlHow it's enforced
ITS token validationIdentity Bridge validates signature and expiry on every user-initiated request
API key validationBridge checks key exists and is not revoked before routing
Read/write splitModule API keys rejected on write endpoints โ€” AUTH_MODULE_NOT_PERMITTED (403)
Rate limitingPer-module rate limits configured in Platform Admin โ€” RATE_LIMIT_EXCEEDED (429) on breach
X-Module-Id enforcementModule's declared ID must match the API key โ€” mismatch rejected
Credential strippingRaw token and API key removed before request reaches any engine

What the Gateway does NOT doโ€‹

  • RBAC permission evaluation โ€” that is the RBAC Engine's job
  • Business logic validation โ€” that belongs in each engine
  • Response content filtering โ€” engines return what they return; the Gateway passes it through

6. Audit Log Designโ€‹

The Audit Log Backbone is the immutable record of all state-changing operations across the platform. It is not a debugging log โ€” it is a compliance and accountability record.

What is auditedโ€‹

Every write operation across all Core engines is recorded. This includes:

CategoryExamples
Role operationsRole assigned, role revoked
Allocation operationsAllocation confirmed, waitlisted, released
Miqaat operationsMiqaat created, phase changed, archived
Config operationsConfig key set or overridden
Rule operationsRule set created or modified
Registration and eligibilityRegistration confirmed, eligibility status changed
Khidmat and HRKhidmat assigned, completed
API key operationsKey issued, revoked, rotated
Platform Admin actionsAny write performed by a Platform Admin user

Module-published events (registration, attendance, scanning, etc.) are also written to the Audit Log via the event bus subscription โ€” the Audit Log is a subscriber to all events.

Audit record structureโ€‹

Each audit record captures:

FieldDescription
auditIdUnique record identifier
engineWhich Core engine produced this record
actionWhat happened (e.g. allocation.confirmed, role.assigned)
miqaatIdMiqaat scope โ€” present on all person or Miqaat-specific actions
itsIdThe Mumin the action concerns โ€” absent on structural actions
actorItsIdThe person who triggered the action (Platform Admin user or module user)
moduleIdThe module that initiated the call, if applicable
detailsEngine-specific context (e.g. allocationId, roleId, ruleSetId)
recordedAtWhen the audit record was written โ€” server time, UTC
correlationIdThe X-Correlation-Id of the originating request โ€” links audit record to request trace

Immutabilityโ€‹

Audit records are append-only. There is no update or delete operation on the Audit Log โ€” not even for Platform Admin. If a record needs to be corrected (e.g. a mis-attributed action), a new compensating record is appended, not an edit to the original.

โณ TBC in Security session:

  • Storage backend for the Audit Log (separate database, write-once object storage, or managed audit service)
  • Retention period per record type (see Event Catalog Section 6 for initial tiers โ€” subject to compliance review)
  • Whether audit log access requires a separate credential beyond PLATFORM_ADMIN
  • Export format for compliance reporting

7. Encryption at Restโ€‹

Confirmed principle from TD6: sensitive data is encrypted at rest. The exact scope and tooling are pending.

โณ TBC in Infrastructure and Security sessions:

  • Which data stores require encryption at rest (likely all of them โ€” confirm scope)
  • Encryption standard (AES-256 or equivalent)
  • Key management for data-at-rest encryption keys (separate from secret management in Section 4)
  • Whether encryption is handled at the storage layer (cloud-managed) or at the application layer
  • ITS sync data โ€” how personal data from ITS is stored and whether additional protection beyond standard encryption applies

8. Module Security Requirementsโ€‹

Modules integrating with Core must meet these security requirements before going live. These are enforced as part of the module onboarding checklist.

RequirementDetail
API key in secrets storeModule API key must not be in source code, config files, or .env files committed to version control
HTTPS onlyModule must call Core over HTTPS โ€” no HTTP fallback
RBAC caching implementedModule must implement the permission caching pattern (see 03 โ€” API Contracts, C-010) โ€” not per-action calls
X-Request-Id on every callModules must generate and pass a UUID per request for tracing
Idempotency key on mutationsMutation calls must use X-Idempotency-Key to prevent duplicate operations on retry
Error handling โ€” no credential exposureModule must not surface Core error details (including error.details) directly in its UI โ€” log internally only

โณ Full module security checklist โ€” pending Security session (additional requirements around data handling, logging, and vulnerability disclosure may be added)


9. Incident Responseโ€‹

โณ Pending Dedicated Security session

The incident response plan covers:

  • Compromised API key procedure โ€” revocation, audit log review, module notification
  • Compromised Platform Admin account โ€” immediate revocation, audit trail review, escalation path
  • Data breach response โ€” notification obligations, containment steps
  • Core engine outage during a live Miqaat โ€” escalation path and communication plan
  • Event bus failure โ€” fallback procedures for modules dependent on Core events

10. Open Questionsโ€‹

QuestionBlocked On
Cloud provider and network topology (VPC, subnets, AZs)Infrastructure session
API Gateway product selection (managed vs self-hosted)Infrastructure session
Whether mTLS is required on internal engine trafficInfrastructure session + Security session
Certificate authority and rotation toolingInfrastructure session
Secrets management tooling selectionInfrastructure session
Audit log storage backend and retention periodsSecurity session
Encryption at rest โ€” scope, standard, and key managementInfrastructure + Security session
Whether ITS personal data requires additional protection beyond standard at-rest encryptionSecurity session + ITS Technical session
Full module security checklistSecurity session
Incident response planSecurity session
Penetration testing schedule and scopeSecurity session