feat(audit): implement audit logging functionality with middleware an…#83
Closed
romariohornburg wants to merge 1 commit intogrid-labs-tech:mainfrom
Closed
feat(audit): implement audit logging functionality with middleware an…#83romariohornburg wants to merge 1 commit intogrid-labs-tech:mainfrom
romariohornburg wants to merge 1 commit intogrid-labs-tech:mainfrom
Conversation
…d configuration options - Added audit logging middleware to the FastAPI application, activated based on configuration. - Enhanced user and token handling in authentication to include audit actor information. - Updated webapp and worker command execution endpoints to capture and log execution details. - Introduced environment variables for audit logging configuration in Docker setup.
There was a problem hiding this comment.
👋 Welcome to Tron! Thanks for your first pull request.
A maintainer will review it soon. Here's what to expect:
- ✅ Automated tests will run on your changes
- 👀 A maintainer will review your code
- 💬 You may receive feedback or requests for changes
- 🎉 Once approved, your PR will be merged!
While you wait:
- Make sure all tests pass
- Check that your PR follows the contribution guidelines
- Feel free to ask questions if you need help
Thank you for contributing to Tron! 🚀
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
Contributor
|
Please close and reopen the pull request to re-read the labeler job permission. |
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.
Audit Logs Implementation (Closes #82)
Summary
This PR implements headless, asynchronous audit logging across the Tron platform. It captures structured events for every significant request and exports them directly to external SIEMs (Elasticsearch, Splunk, Datadog) via HTTP. The design is fail-open and configured exclusively via environment variables (no UI).
Audit Event Structure
Each log entry contains:
anonymousinstances/abc-123,organizations/xyz/members)X-Forwarded-Forbehind proxies)For EXEC events (pod command execution), the following are also included:
Architecture
asyncio.create_task()(non-blocking)request.state.audit_actoron successful authenticationFile Structure
Configuration
Environment variables (add to
.env):AUDIT_LOG_ENABLED(default:false) – enables/disables audit loggingAUDIT_SIEM_URL– SIEM endpoint URL (e.g.,https://logs.example.com/ingest)AUDIT_SIEM_TOKEN(optional) – Bearer token for authenticationAUDIT_SIEM_TIMEOUT(default:5) – HTTP timeout in secondsThe middleware is only registered when
AUDIT_LOG_ENABLED=trueandAUDIT_SIEM_URLis set.Changes
AuditMiddlewareto capture request/response metadataaudit_exec_payloadwith command and outputdocker-compose.yamlto pass audit env vars to the API containerdocker/.env.examplewith audit variablesTests
audit_config,audit_event, andaudit_sender(including fail-open behavior)Compliance