Repository navigation
feat(security): fleet-wide default for require-verified-email — secure-by-default (#1129) - #1132
Conversation
…-by-default (#1129) Promote the per-agent `require_email` access-policy flag (#311) to an admin-controlled fleet-wide default that defaults ON, so new agents are secure-by-default instead of opt-in per agent. Mirrors the RES-001 agent-defaults/resources pattern. - settings_service: AGENT_DEFAULT_REQUIRE_EMAIL_KEY + get_agent_default_require_email() (default ON; resolved from system_settings, code fallback so fresh installs are secure without a data migration). - routers/settings: GET/PUT /api/settings/agent-defaults/access-policy (admin-only) + AgentDefaultAccessPolicyUpdate model. - register_agent_owner (db/agents + database facade): new require_email param, written explicitly in the INSERT (same SQLite-baked-default reasoning as #665's execution_timeout_seconds). Defaults False so the system agent is unaffected. - crud: seed require_email from the platform default at user-agent creation. - Settings UI: admin toggle in the Platform section, consistent with Default Model. - No schema change (column + system_settings already exist); existing agents are never rewritten — the default is read only at creation time. Verified live: default GET = ON; new agent seeds require_email ON; flip default OFF → next new agent OFF; existing agent unaffected by the flip; per-agent override still works; UI toggle renders + reflects the default. Throwaway agents deleted, default restored ON. Related to #1129 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
|
||
| updated = [] | ||
| if body.require_email is not None: | ||
| db.set_setting(AGENT_DEFAULT_REQUIRE_EMAIL_KEY, "1" if body.require_email else "0") |
There was a problem hiding this comment.
Missing audit log on a security-relevant setting change. This endpoint writes the fleet-wide email-verification default via db.set_setting(...) directly, with no platform_audit_service.log(...). Everywhere else in this router that mutates a setting audit-logs it — API-key change (L222), GitHub PAT (L380), and the generic PUT /{key} (L1454) all emit AuditEventType.CONFIGURATION. An admin flipping the fleet-wide require_email default OFF (weakening the platform security posture for every future agent) currently leaves no trace.
It mirrors the agent-defaults/resources PUT, which also doesn't audit — but resources isn't security-sensitive and this is (theme-security, P1). Suggest adding an audit call after the write, e.g.:
await platform_audit_service.log(
event_type=AuditEventType.CONFIGURATION,
event_action="update_agent_default_access_policy",
actor_id=str(current_user.id), actor_email=current_user.email,
details={"require_email": body.require_email}, source="api",
request=request,
)(make the handler async-friendly — it already is). Non-blocking, but worth closing the gap given the security theme.
There was a problem hiding this comment.
Fixed in 11a5abc — added the platform_audit_service.log(AuditEventType.CONFIGURATION, ...) call (same shape as the API-key/generic-setting writes) after the set_setting. Verified live: flipping the default writes a settings_change audit row with {setting: agent_default_require_email, require_email: <new>}.
🔎 Code review (high-effort, recall-biased) — 1 non-blocking findingClean, well-scoped diff that faithfully mirrors the RES-001 agent-defaults pattern; live-verified end-to-end. No correctness bugs. One security-theme gap worth closing. Finding (low/medium, non-blocking)
Checked & cleared
✅ Ready to merge; the audit-log addition is a nice defense-in-depth follow-up. Reviewed with the |
…review)
PUT /api/settings/agent-defaults/access-policy wrote the fleet-wide
require_email default via db.set_setting() with no audit trail, while every
other settings write in the router (API-key, GitHub PAT, generic /{key})
emits AuditEventType.CONFIGURATION. Flipping a security default must leave a
trace — add the same platform_audit_service.log() call.
Verified live: flipping the default writes a `settings_change` audit row with
{setting: agent_default_require_email, require_email: <new>}.
Related to #1129
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Resolve by running |
Resolved docs/memory/architecture.md: dev's restructure made the Platform Settings catalog terse (GET/PUT collapsed rows); re-added the #1129 agent-defaults/access-policy endpoint as one combined row in that style. Co-Authored-By: Claude Fable 5 <[email protected]>
vybe
left a comment
There was a problem hiding this comment.
Validated via /validate-pr: verified require_admin local-helper pattern, get_setting_value facade method, and that the single user-agent creation path is covered (system-agent sites intentionally excluded). Explicit-INSERT seed reasoning sound (#665 pattern), zero DDL, default flip audit-logged. Resolved the architecture.md conflict against the dev restructure. CI green. Approving.
Summary
Promotes the per-agent
require_emailaccess-policy flag (#311) to an admin-controlled fleet-wide default that defaults ON, so new agents are secure-by-default instead of opt-in per agent. Mirrors the RES-001agent-defaults/resourcespattern.Changes
settings_service.py—AGENT_DEFAULT_REQUIRE_EMAIL_KEY+get_agent_default_require_email()(default ON; resolved fromsystem_settings, with a code fallback so fresh installs are secure without a data migration).routers/settings.py—GET/PUT /api/settings/agent-defaults/access-policy(admin-only) +AgentDefaultAccessPolicyUpdatemodel. Registered before the/{key}catch-all (Invariant fix: add missing logging_config.py to backend Dockerfile #4).register_agent_owner(db/agents.py+database.pyfacade) — newrequire_emailparam, written explicitly in the INSERT (same SQLite-baked-default reasoning as feat: increase default chat execution timeout from 15m to 60m #665'sexecution_timeout_seconds). DefaultsFalse, so the system agent is unaffected.crud.py— seedsrequire_emailfrom the platform default at user-agent creation.No schema change
The
agent_ownership.require_emailcolumn (#311) andsystem_settingsboth already exist — zero DDL, no migration. The default is read only at creation time; existing agents are never rewritten.Acceptance criteria
require_emaildefault, stored insystem_settings, defaulting ON.agent_ownership.require_emailfrom the default (not hard-coded0).PUT /api/agents/{name}/access-policyunchanged).require_emailonly (per the grooming note);open_accessleft out.Verification (live)
GET /agent-defaults/access-policyrequire_email: true(default ON, key unset)require_email: truerequire_email: falsePUT /access-policyThrowaway agents deleted; default restored ON. Backend
py_compile+ frontendvue/compiler-sfcclean.Related to #1129
🤖 Generated with Claude Code