Repository navigation
feat(auth): two-factor (TOTP) login seam + enterprise-gated UI (trinity-enterprise#5) - #1247
Merged
Merged
Conversation
|
Resolve by running |
OSS side of two-factor auth (enterprise issue #5). All IP (TOTP verify, secret store, recovery codes, policy) lives in the private trinity-enterprise submodule; this PR adds only the edition-agnostic seam + the entitlement-gated Vue surface, consistent with the open-core pattern (#847). Backend seam: - services/mfa_gate.py — single hook the enterprise provider registers into. No provider (OSS-only build) → gate_login() returns None → login unchanged. Fail-open on provider error (never lock everyone out of login). - dependencies.py — create_mfa_challenge_token / decode_mfa_challenge; a challenge-scoped token is rejected as a session token in get_current_user and decode_token. - routers/auth.py — /token and /api/auth/email/verify consult mfa_gate after the first factor; when a second factor is required they return a short-lived challenge token instead of an access token (audited as mfa_challenge_issued). - models.py — Token gains optional mfa_required / challenge_token fields. - Dockerfile — pyotp (used by the enterprise module running in this image). Frontend (gated by `2fa` in GET /api/settings/feature-flags): - Settings → Security tab (TwoFactorPanel): self-service enroll/confirm/ disable/recovery; admin-only org policy. - Login.vue: second-factor step (verify + forced-enroll) after the password/ email factor; QrCode.vue renders the otpauth URI (graceful manual-key fallback). auth store carries the challenge through to the real token. OSS-only builds: no Security tab, no login step, /api/enterprise/2fa/* → 404. Related to Abilityai/trinity-enterprise#5 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
frontend-build npm ci failed — package.json added qrcode@^1.5.4 but package-lock.json was not regenerated, leaving it out of sync. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
Author
vybe
approved these changes
Jun 19, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validated via /validate-pr: OSS 2FA login seam (trinity-enterprise#5). Verified security-critical property — challenge tokens carry mfa_challenge scope and are rejected as session tokens in both decode_token and get_current_user; OSS-only build is byte-for-byte inert (provider is None). pyotp pinned, architecture.md updated, E2E + 20/20 enterprise pytest. Inert without the enterprise provider, so no half-ship risk. Approving.
This was referenced Jun 22, 2026
vybe
added a commit
that referenced
this pull request
Jul 1, 2026
…or) (#1374) Brings the private enterprise submodule 1e916f6 -> f1c8cae, registering three modules whose OSS seams are now all present on dev: - two_factor (trinity-enterprise#5) -- seam: services/mfa_gate.py (#1247, merged) - sso (trinity-enterprise#32) -- seam: entitlement + create_access_token (core) - mcp_connector (trinity-enterprise#46) -- seam: resolve_mcp_url + register_agent_owned_table + connector-scope keys (#1356, merged) Sequenced after #1356 so the enterprise build's register_enterprise() resolves its imports cleanly on dev (a pre-#1356 bump would ImportError-crash the enterprise backend at startup). Co-authored-by: Eugene Vyborov <[email protected]>
trinity-ability
pushed a commit
that referenced
this pull request
Nov 14, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
vybe
added a commit
that referenced
this pull request
Nov 14, 2026
…yai/trinity-enterprise#1105) (#4492) * feat(executions): attribution seam — record at every creation site, explicit project_id checked first (Abilityai/trinity-enterprise#1105) An edition may attribute an execution to a project. The platform side is an inert seam, services/execution_attribution.py: - every create_task_execution( site offers its row to record_row right after it exists: /chat, /task, execute_task, both Workspace turn sites, loop iterations, fan-out children (project resolved once at request time and carried, since children are created when a slot frees), the skill-gate replay, and the scheduler's row in the internal execute-task route; - the public link, external A2A and brain-orb postprocess turns are untagged by design, allowlisted with a reason; - a request naming project_id on /chat, /task or /fan-out is checked via dependencies.check_requested_project before admission, any claim or row; with no attributor registered it is 422 project_attribution_unavailable; - GET /api/agents/{name}/executions/{id} carries project_id from annotate; record and annotate fail open; - MCP chat_with_agent and fan_out take an optional project_id, forwarded and keyed only when set; get_execution_result passes project_id through when present. Census guard tests/unit/test_1105_execution_attribution.py walks the platform backend (rglob) and fails on an unrecorded creation site or a stale allowlist entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(projects-ui): Runs tab and list_project_executions MCP tool (Abilityai/trinity-enterprise#1105) Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(executions): gate replay carries the frozen project; a failed explicit attribution says so (Abilityai/trinity-enterprise#1105) Review I1, (b) and (c) of the planned attribution paths (plan §2.2 rules 2-3). (b) Skill-gate replay. A hold on /chat (admit_chat_request), on /task (dispatch_parallel_task) and on a fan-out subtask (via gate_replay) now freezes the project resolved while the requesting turn runs into the gate record's `dispatch` (`skill_gate_service.frozen_project`: `project_id`, plus `project_requested` when the request named it). `_dispatch_approved` records the approved run with it: as the explicit claim when the request named it, otherwise as inherited. Inert in OSS, where resolve returns None and nothing is frozen. (c) Honest status. `record_row` now reports FAILED for a named project that passed `check` and was then not recorded (the write raised, or the record-time re-assert no longer held). /chat and /task record inline, so the outcome rides a per-request ContextVar (reset by `check`) to the router, which answers `project_attribution: "failed"` (`execution_attribution.report`). Fan-out answers it on `FanOutResponse` when the named project did not resolve at request time, or when a sync batch's subtask record failed. (a) Loop iterations are NOT built. The loop record (`agent_loops`) has no project column and no free-form field, so storing the project resolved at loop start needs an OSS schema migration, which has not been ruled. Iterations still record from their own row only. Mutation check: each wiring line was reverted on its own and a named test went red: - the chat/task router `report` → test_{chat,task}_route_answers_failed_…[False]; - the chat/task hold `frozen_project` → test_a_held_{chat,task}_freezes_…; - the fan-out gate_replay project → test_a_fan_out_subtask_hands_its_project_to_the_gate; - the child failure append → test_a_fan_out_subtask_whose_record_failed_marks_the_batch; - the router FAILED → test_fan_out_answers_failed_when_the_named_project_did_not_resolve; - the replay `requested` → test_the_approved_replay_records_the_frozen_project[frozen1]; - the seam's unrecorded → FAILED → test_an_explicit_request_that_was_not_recorded_is_failed. Known gap: an Idempotency-Key replay of /chat or /task returns the stored snapshot, which does not carry the field. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(mcp): list_project_executions task_id takes up to 64 chars, the backend's bound (Abilityai/trinity-enterprise#1105) Review I4. The tool had `max(16)` while the route has `Query(max_length=64)`. The new test (64 accepted, 65 refused) went red against max(16). Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(ent875): census the internal execute_task attribution read (ent#1105) Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(1105): pin enterprise to b01cee0c7 (#1247 head re-pin) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Trinity Agent (trinity) <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: trinity-ability <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What
OSS side of two-factor authentication (TOTP) — enterprise issue Abilityai/trinity-enterprise#5.
Per the open-core pattern (#847), all algorithmic IP (TOTP verify, AES secret store, recovery codes, per-role policy) lives in the private
trinity-enterprisesubmodule (separate PR). This PR adds only the edition-agnostic login seam + the entitlement-gated Vue surface.Backend seam
services/mfa_gate.py— the single hook the enterprise provider registers into. No provider (OSS-only build) →gate_login()returnsNone→ login is byte-for-byte unchanged. Fail-open on provider error.dependencies.py—create_mfa_challenge_token/decode_mfa_challenge; a challenge-scoped token is rejected as a session token inget_current_user+decode_token.routers/auth.py—/tokenand/api/auth/email/verifyconsultmfa_gateafter the first factor; if a second factor is required they return a short-lived challenge token instead of an access token (auditedmfa_challenge_issued).models.py—Tokengains optionalmfa_required/challenge_tokenfields.docker/backend/Dockerfile—pyotp(the enterprise module runs in this image).Frontend (gated by
2fainGET /api/settings/feature-flags)TwoFactorPanel.vue): self-service enroll / confirm / disable / recovery codes; admin-only org policy.QrCode.vuerenders theotpauthURI with a graceful manual-key fallback.Edition behavior
/api/enterprise/2fa/*Testing
Verified end-to-end on a live stack (enroll → confirm → gated re-login →
login/verify→ working token; replay rejected; recovery-code login; challenge-token-as-session rejected). Enterprise unit + real-DB pytest 20/20.Related to Abilityai/trinity-enterprise#5
🤖 Generated with Claude Code