Files
e1a9e6aa83 feat: migrate audit log format to v2 with enhanced actor metadata (#74)
* feat: migrate audit log format to v2 with enhanced actor metadata

BREAKING CHANGE: Audit log format has been upgraded from v1 to v2

Changes:
- Add Actor object with identity, organization_id, stack_id, and ip_address
- Extract organization_id and stack_id from STACK env var (format: "ORG-STACK")
- Extract IP address with fallback chain: X-Forwarded-For > X-Real-IP > RemoteAddr
- Extract trace_id from OpenTelemetry context
- Restructure payload: move request/response into HTTP object
- Add utility functions: parseStackEnv(), extractIPAddress(), extractTraceID()

The new format provides better traceability and context for audit events:
- Actor information centralized in dedicated object
- OpenTelemetry integration for distributed tracing
- Client IP tracking for security analysis
- Organization and stack identification from environment

Modified files:
- internal/audit/messages/audit.go: New types, utility functions, updated payload structure
- pkg/plugins/audit.go: Pass context and request to NewAuditMessagePayload()

* fix: pre-commit

* feat: Upgrade to go-libs/v3

* feat: Enhance audit plugin with authentication metadata and JWT verification

* fix: update go-jose dependency to v4.0.5 and adjust indirect requirement to v3.0.4

* fix: set HTTP client timeout to 30 seconds in initKeySet function

* chore: make auth optional and add all claims instead of just the subject

---------

Co-authored-by: Geoffrey Ragot <[email protected]>
2025-11-13 15:07:05 +01:00

48 lines
1.2 KiB
Plaintext

VERSION 0.8
ARG core=github.com/formancehq/earthly:main
IMPORT $core AS core
FROM core+base-image
sources:
WORKDIR /src
COPY go.* .
COPY --dir pkg .
COPY main.go Caddyfile .
SAVE ARTIFACT /src
compile:
FROM core+builder-image
COPY (+sources/*) /src
WORKDIR /src
ARG VERSION=latest
DO --pass-args core+GO_COMPILE --VERSION=$VERSION
build-image:
FROM core+final-image
ENTRYPOINT ["/usr/bin/caddy"]
CMD ["run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
COPY Caddyfile /etc/caddy/Caddyfile
COPY (+compile/main) /usr/bin/caddy
ARG REPOSITORY=ghcr.io
ARG tag=latest
DO core+SAVE_IMAGE --COMPONENT=gateway --REPOSITORY=${REPOSITORY} --TAG=$tag
deploy:
COPY (+sources/*) /src
LET tag=$(tar cf - /src | sha1sum | awk '{print $1}')
WAIT
BUILD --pass-args +build-image --tag=$tag
END
FROM --pass-args core+vcluster-deployer-image
RUN kubectl patch Versions.formance.com default -p "{\"spec\":{\"gateway\": \"${tag}\"}}" --type=merge
deploy-staging:
BUILD --pass-args core+deploy-staging
openapi:
COPY ./openapi.yaml .
SAVE ARTIFACT ./openapi.yaml