@davoodmehraban89 / Aram-2 Mirror · read-only
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 4, 14:15 UTC

codex/gate3-signed-year-scope-20261030
add-index-html-10623938925177053894 arena/094f314c-aram arena/2d4eda07-aram chatgpt-phase1b2-autopilot codex/adr-future-connectors-pi-v1 codex/aram-account-note-source-trace-20261031 codex/aram-actions-node24-maintenance-20261031 codex/aram-analyst-review-workbook-20261031 codex/aram-bs-candidate-statement-20261031 codex/aram-cash-flow-direct-candidate-20261031 codex/aram-clean-reference-year-integrity-20261030 codex/aram-cross-statement-controls-20261031 codex/aram-equity-changes-candidate-20261031 codex/aram-five-statement-cli-20261031 codex/aram-five-statement-integration-20261031 codex/aram-five-statement-orchestrator-20261031 codex/aram-gate3-coverage-target-guard-20261030 codex/aram-gate3-hidden-xlsx-guard-20261030 codex/aram-gate3-integration-validation-20261030 codex/aram-gate3-mapping-change-preview-20261030 codex/aram-gate3-stale-note-guard-20261030 codex/aram-income-statement-candidate-20261031 codex/aram-manifest-referential-integrity-20261031 codex/aram-mapping-source-parser-20261101 codex/aram-multidimensional-mapping-20261101 codex/aram-multistatement-mapping-20261031 codex/aram-pipeline-manifest-schema-20261031 codex/aram-readonly-mapping-coverage-20261031 codex/aram-reconciliation-review-gate-20261031 codex/aram-same-flush-fiscal-lock-20261030 codex/aram-synthetic-windows-demo-20261031 codex/aram-trial-balance-diagnostic-20261031 codex/aram-windows-background-detail-search-20261031 codex/aram-windows-detail-review-20261031 codex/aram-windows-five-statement-pilot-20261031 codex/aram-windows-statement-figures-20261031 codex/gate-2a-pilot-workbook codex/gate-2a-pilot-workbook-6864754244772568979 codex/gate3-authenticated-principal-boundary-20261030 codex/gate3-authored-draft-staging-20261030 codex/gate3-carry-forward-preview-20261023 codex/gate3-draft-staging-audit-20261030 codex/gate3-mapping-batch-freshness-20261030 codex/gate3-mapping-batch-review-20261030 codex/gate3-mapping-core codex/gate3-mapping-coverage-20261023 codex/gate3-mapping-excel-20261023 codex/gate3-note-mapping-review-20261023 codex/gate3-signed-year-scope-20261030 codex/gate3-unapproved-proposal-storage-20261030 codex/payvast-mapping-discovery-20261023 codex/phase-2a-backend-foundation codex/phase-2b-post-merge-record codex/phase-2b-source-registration codex/phase-2b-source-registration-12955190277775369594 codex/post-gate2a-control-reconciliation codex/post-pr18-acceptance-record codex/project-control-foundation codex/t1-repo-hygiene-20261023 codex/t2-ci-hardening-20261023 codex/t3-explicit-migrations-20261023 codex/t6a-readonly-diagnostics-20261023 codex/v1-01-safety-gate-hardening codex/v1-year-isolation-followup-20261023 codex/windows-native-pilot-shell-20261030 dependabot/github_actions/actions/checkout-7 dependabot/github_actions/actions/setup-node-6 dependabot/github_actions/actions/setup-python-7 dependabot/github_actions/actions/upload-artifact-7 dependabot/npm_and_yarn/frontend/eslint-plugin-react-hooks-7.1.1 dependabot/npm_and_yarn/frontend/globals-17.15.0 dependabot/npm_and_yarn/frontend/vite-8.4.0 dependabot/npm_and_yarn/frontend/vitest-5.1.2 dependabot/npm_and_yarn/frontend/vitest/coverage-v8-5.1.2 dependabot/pip/backend/mypy-gte-1.13-and-lt-3 dependabot/pip/backend/pytest-cov-gte-6.0-and-lt-8 dependabot/pip/backend/setuptools-gte-75-and-lt-85 docs/aram-master-control-plan-20261111 docs/aram-roadmap-dashboard-20261030 docs/financial-statement-reconciliation-1402-1404-20261110 feat/gate3-governed-mapping-20261101 feat/gate3-package9-1-security-20261103 feat/gate3-package9-isolated-20261103 fix/password-unicode-validation-20261111 governance/aram-5-1-3-controls-20261030 governance/role-based-operating-model jules-1168663913887856558-73b8a885 jules-gate-2b-mapping-workflow-foundation-4137724387867065330 phase-1b1-audit-report-7365389436990903239 phase-2a-backend-foundation-10237597358138521261 phase1b2-postmerge-metadata-fix refactor/drg-parent-year-id-15088443704684163304 source-data-cleanup
md 30 lines 5.87 KB
Rendered Raw
1 # ARAM Gate 3 — fail-closed, pinned RS256 identity verification boundary
2
3 **Status:** PROPOSED in unmerged [Draft PR #55](https://github.com/davoodmehraban89/Aram/pull/55). Exact parent is unmerged [Draft PR #54](https://github.com/davoodmehraban89/Aram/pull/54) at SHA `c5e3fb7f8917433a1075ece8ad1ee95a1695dad5`. Upstream #53→#52→#51→#50→#26 and migration design PR #25 remain unmerged. Accepted branch `source-data-cleanup@7dc864fd032f0c4ae4d650d89304a01286a6d914` is unchanged.
4
5 ## Scope and threat model
6
7 Previous Gate 3 drafts and system `DraftStaged` events have **NO verified human author or reviewer identity**. Treating a JSON field, client-supplied reviewer name or `X-User`/role header as authentication is unacceptable for financial approval. This PR adds a **read-only, fail-closed authenticated-principal boundary**, not a finance approval service.
8
9 - New `authenticated_identity.py` uses PyJWT with its crypto extra to verify a **pinned, operator-configured RSA PUBLIC key**, with a fixed `RS256` algorithm allowlist. Never accept `none`, HMAC, caller-provided key, JWKS URL, token header key material, or signature-disabled decode. Public-key parsing requires an actual RSA public key, minimum 2048 bits; private-key PEM and malformed PEM are refused.
10 - `Settings` supports `ARAM_AUTH_ISSUER`, `ARAM_AUTH_AUDIENCE` and `ARAM_AUTH_PUBLIC_KEY_PEM`. All default to empty (DISABLED). Issuer must be a configured HTTPS URL; audience must be nonempty; public key must be an actual RSA *verification* key. Misconfiguration yields HTTP 503. This is an **operator trust anchor**, not an external IdP automatically discovered or provisioned by the project.
11 - Tokens require signed `iss`, `aud`, `sub`, `exp`, `iat`, `nbf`, `token_use=access`, and `aram_roles`. Verify exact issuer and audience, temporal validity with zero leeway, numeric date claim types and maximum lifetime of **900 seconds**. Invalid, expired, future, missing or malformed claims return 401 with `WWW-Authenticate: Bearer`. Claims are never read before signature validation for authorization decisions.
12 - Only two currently recognized role strings: `mapping_proposer` and `mapping_reviewer`, and token must carry exactly one. Disallow unknown/duplicate or both roles simultaneously. The roles are *trusted only if in a verified RSA-signed token issued by the selected enterprise IdP*. These are **preparatory transport claims**, not actual database author/reviewer entitlements or proof of approvals.
13 - `VerifiedPrincipal` is a frozen, internal snapshot of issuer, subject, role and expiry. The server derives it only after verifying token signature and claims; the HTTP client cannot set it via headers. Python objects are not security boundaries in themselves; a future sensitive API must obtain this value through `Depends(require_verified_principal)`, not accept a client-supplied object.
14 - `GET /api/v1/auth/me` returns **only** verified identity facts for diagnostics. No token/private key is echoed; no POST on this route. The existing health and read-only schema catalog remain usable as before.
15 - No `POST approve`, reject, review, MappingRule apply or financial statement write endpoint is introduced. `mapping_draft_store` still has no author_id; do **not** infer that future author/reviewer separation is implemented.
16
17 ## Deployment requirements before any real use
18
19 1. Owner must select an actual enterprise identity provider authorized to issue ARAM API access tokens, provision aud/iss, configure a correct trusted RSA verification public key via a protected deployment secret/configuration channel, and define company/year scopes. **No private signing key should be present in this repository or backend environment.**
20 2. Enterprise IdP must actually assign/attest the intended `aram_roles`, support timely revocation, public-key rotation and identity lifecycle, and produce short-lived signed access tokens. This PR uses a single pinned key only: **no JWKS refresh/rotation, token revocation, account directory sync, SSO login flow or delegated authorization**.
21 3. Authenticate end-user identity in a future proposal submission API, store immutable `issuer+subject` of author under a reviewed migration, verify reviewer is a **different actual subject** under a separate policy, preserve year/company scoping and write authenticated audit. These services **do not exist yet**.
22 4. Only after correct database transaction isolation, compare-and-set and source financial reconciliation can a human-approved proposal be applied. Existing low-level Mapping and Excel import write paths bypass that future workflow and remain unresolved in Issues #49, #43. Real C1/C2/C3 independent reviewers remain Issue #39.
23
24 ## Synthetic acceptance cases
25
26 Generate ephemeral 2048-bit RSA keys in CI only (no real production credentials). Positive: valid 5-minute signed proposer/reviewer tokens on a read-only whoami route. Negative: missing Bearer, forged identity and reviewer HTTP headers, wrong signer, wrong issuer/audience, expiration and future time, lifetime greater than 15 min, malformed subjects, wrong token_use, unknown/dual/duplicate/non-list roles, missing required signed claims, HMAC/unsigned tokens, token payload tampering, malformed PEM, private key in public slot, 1024-bit key, oversized tokens, unconfigured key/aud/issuer. No approval endpoints created. Run exact-final-SHA remote CI, reversible disposable Alembic migrations and compileall, inspect scoped patch and reviewer state.
27
28 **No canonical accounting XLSX/PDF, `data/`, actual client DB, schema migration, prior migration revision, workflows, binary or release touched.** A new cryptographic dependency requires independent security/dependency review before merging.
29
30 **Acceptance:** this PR remains Draft/unmerged until upstream parents and **three genuine independent non-author C1/C2/C3** signoffs are recorded. A valid test token is not a finance officer signature or approval; no actual external IdP connection was configured or tested here.