Skip to content

Add audit logs - #647

Draft
varmar05 wants to merge 26 commits into
masterfrom
audit_logs
Draft

Add audit logs#647
varmar05 wants to merge 26 commits into
masterfrom
audit_logs

Conversation

@varmar05

@varmar05 varmar05 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Introduce a pluggable audit module with NullSink default and emit() API.

Wire SQLAlchemy listeners for user and project lifecycle events, explicit emits for auth and sync endpoints (login, password, access grants/revocations, version push, soft/hard delete, restore).

Add actor_context()/request_context() helpers, device_id capture, scope_id for workspace-scoped filtering, and target_type auto-derivation.

varmar05 and others added 8 commits June 17, 2026 15:07
 - `load_user` now returns None for inactive users, so their session cookies are rejected by Flask-Login
 - @auth_required adds `is_active` check
 - anonymize() now explicitly sets active=False for defence-in-depth
Existing passwords will be rehashed organically if needed.
Introduce a pluggable audit module with NullSink default and emit() API.

Wire SQLAlchemy listeners for user and project lifecycle events,
explicit emits for auth and sync endpoints (login, password, access
grants/revocations, version push, soft/hard delete, restore).

Add actor_context()/request_context() helpers, device_id capture, scope_id
for workspace-scoped filtering, and target_type auto-derivation.

This is groundwork for adding more events and to be extended in EE with custom sinks, query API, and retention policy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coveralls

coveralls commented Jul 1, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 30453492514

Coverage increased (+0.4%) to 92.504%

Details

  • Coverage increased (+0.4%) from the base build.
  • Patch coverage: 22 uncovered changes across 7 files (773 of 795 lines covered, 97.23%).
  • 3 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
server/mergin/audit/listeners.py 46 41 89.13%
server/mergin/auth/controller.py 45 41 91.11%
server/mergin/utils.py 12 8 66.67%
server/mergin/app.py 5 2 40.0%
server/mergin/auth/models.py 40 37 92.5%
server/mergin/tests/test_audit_events.py 266 264 99.25%
server/mergin/auth/app.py 63 62 98.41%
Total (31 files) 795 773 97.23%

Coverage Regressions

3 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
server/mergin/sync/utils.py 2 85.4%
server/mergin/auth/app.py 1 97.01%

Coverage Stats

Coverage Status
Relevant Lines: 10793
Covered Lines: 9984
Line Coverage: 92.5%
Coverage Strength: 0.93 hits per line

💛 - Coveralls

varmar05 and others added 18 commits July 1, 2026 15:29
… mimetype check -> mime_type config var is not needed
…ypes

Support for whitelisting extensions/mimetype
Implements structured audit event emission for all relevant user and project actions.
Update AuditEvent dataclass with new target columns: project_id, workspace_id and user_id.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…events

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also simplify test_get_projects_by_uuids to avoid the fake-workspace-id hack.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Send email notification with self-service unlock link on account lockout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants