Skip to content

feat: implement audit logging system #122#134

Merged
kryachkow merged 18 commits intodevelopmentfrom
122-audit-log
Feb 18, 2026
Merged

feat: implement audit logging system #122#134
kryachkow merged 18 commits intodevelopmentfrom
122-audit-log

Conversation

@kryachkow
Copy link
Contributor

@kryachkow kryachkow commented Feb 12, 2026

Applicable issues

This PR is the first part of the issue #122. The rest of the work is described in issue #145.

Description of changes

Implemented immutable admin audit logging in Postgres with decorator-based instrumentation and read-only API access.

What was added

  • New immutable audit_logs table (append-only; DB trigger blocks UPDATE/DELETE)
  • Audit model and schemas for list/details views
  • Reusable @audit_action decorator for service-layer write operations
  • Request-scoped audit context populated from JWT claims
  • Read-only endpoints:
    • GET /admin/api/v1/audit-logs (paginated list, no state payload)
    • GET /admin/api/v1/audit-logs/{id} (includes state_before reconstructed from previous log and state_after from current log)

Logging behavior updates

  • Store only state_after (JSON); no full before/after snapshots in DB
  • state_before is computed on demand in details endpoint
  • Delete actions persist state_after = null
  • Reindex operations are not yet included in audit logs.
  • Jobs are auditable and tracked as job-related entities.

Actor attribution

  • performed_by and performed_by_name are taken from configurable JWT claims:
    • AUDIT_PERFORMED_BY_CLAIM (default: oid)
    • AUDIT_PERFORMED_BY_NAME_CLAIM (default: unique_name)

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@kryachkow kryachkow requested a review from ypldan as a code owner February 12, 2026 07:03
@kryachkow kryachkow linked an issue Feb 12, 2026 that may be closed by this pull request
@Fedir-Yatsenko Fedir-Yatsenko self-requested a review February 12, 2026 13:57
@Fedir-Yatsenko Fedir-Yatsenko added enhancement New feature or request python Pull requests that update python code labels Feb 12, 2026
Danylo_Kriachkov and others added 6 commits February 16, 2026 09:37
1. Make audit log fields non-nullable.
2. Set `state_after=None` for DELETE actions.
3. Split user auth from audit context
  setup.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kryachkow
Copy link
Contributor Author

kryachkow commented Feb 17, 2026

/deploy-review

GitHub actions run: 22091284378

Fedir-Yatsenko
Fedir-Yatsenko previously approved these changes Feb 17, 2026
Copy link
Collaborator

@Fedir-Yatsenko Fedir-Yatsenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's test in the Review env and merge the changes

@kryachkow
Copy link
Contributor Author

kryachkow commented Feb 17, 2026

/deploy-review

GitHub actions run: 22091513551
Environment URL: review-environment | pipeline

@kryachkow
Copy link
Contributor Author

kryachkow commented Feb 17, 2026

/deploy-review

GitHub actions run: 22092798607
Environment URL: review-environment | pipeline

@kryachkow
Copy link
Contributor Author

kryachkow commented Feb 17, 2026

/deploy-review

GitHub actions run: 22093903162
Environment URL: review-environment | pipeline

@kryachkow
Copy link
Contributor Author

kryachkow commented Feb 17, 2026

/deploy-review

GitHub actions run: 22104893009
Environment URL: review-environment | pipeline

@kryachkow kryachkow merged commit 0dfba5a into development Feb 18, 2026
10 checks passed
@kryachkow kryachkow deleted the 122-audit-log branch February 18, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit log

2 participants