Skip to content

Add identity audit logging#72

Open
darshana-v wants to merge 3 commits intomainfrom
identity-audit-log
Open

Add identity audit logging#72
darshana-v wants to merge 3 commits intomainfrom
identity-audit-log

Conversation

@darshana-v
Copy link
Copy Markdown
Contributor

Summary

Identity mutations (create/update/delete) previously had no audit trail. Operators had no way to answer "who registered this agent?" or "who changed its trust level and when?". owner_user_id is a static ownership field on the identity, not a record of who performed a given operation.

This PR adds an identity_audit_logs table that records every mutation with the acting user's ID (from the X-User-ID header, set by TenantContextMiddleware), a timestamp, and before/after JSONB snapshots of the identity row.


Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • This change requires a documentation update

Testing

  • Manually tested
  • Unit tests added/updated
  • No tests required

Impact / Risks


📸 Screenshots / Logs (if applicable)


Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements an audit logging system for identity lifecycle operations, including the creation of a new database table, repository, and service-level integration. The feedback focuses on ensuring the acting user's ID is consistently captured across all service methods (specifically within the agent service), standardizing audit timestamps to UTC, and expanding the logging logic to include failed operation attempts for a more comprehensive security trail.

Comment thread internal/service/agent.go Outdated
Comment thread internal/service/agent.go Outdated
Comment thread internal/service/identity.go
Comment thread internal/store/postgres/audit.go Outdated
@darshana-v darshana-v changed the title Add identity audit logging to service layer Add identity audit logging Apr 14, 2026
@darshana-v
Copy link
Copy Markdown
Contributor Author

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.

1 participant