Skip to content

feat(gcs): propagate request metadata to gcs audit logs

What does this MR do?

Related to #1187

This MR propagates new query params in the gcs signed redirect url sent from the registry when a blob is requested (but served via gcs), the highlights of this MR are:

  • Updating the google signing schema from V2 to V4 -> !1577 (comment 1771671096)
  • Retrieving values for namespace, project_path and auth_type stored in the request context then validating and passing the values to be included in the signed gcp url query params -> !1577 (comment 1771681125)

Passing the query params to the signed redirect url allows for the query param key value pairs to be present in the request auditlogs as explained in https://gitlab.com/groups/gitlab-org/-/epics/8732#gcs

Sample resulting signed url
https://storage.googleapis.com/sahmed-registry-buckett/docker/registry/v2/blobs/sha256/c3/c345c9e441f5f49235768af74b8ab37743652d38958afaa000edd56d7b2f0540/data?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=sahmed-registry%40dev-package-container-96a3ff34.iam.gserviceaccount.com%2F20240214%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20240214T174928Z&X-Goog-Expires=1199&X-Goog-Signature=8193fca70ca7c479569e6b94263ff854420ce03c77d548242faacb7b41963f98de20aef26afcc82c44418445eae61357639a2ec6e269ed5968b2b2794e6042d9b27a0c8a194378df4a9dd2082bd6bb92614e7ed4165d6f3cc989eb81c7838c7c16103792540ef3951038c374ed44e565644266ed999556064ba251e85d9da707cd38e6868e7567898e1baf3a38b578f2f9aab922493cde5cf3a2f609a8ea72cb3579118f45925ac5e36472a188731530d53da40418cc9ea7c5968b5f02db9ce9ab3460acde65b1accb228036bafaf394ef134c338ee3ba50dab2ebcfb9e570020b3677e912bf80395cb261c9c32e98a749183bf829a1d8cfc25fb3941475cda4&X-Goog-SignedHeaders=host&x-goog-custom-audit-gitlab-auth-type=silly-type&x-goog-custom-audit-gitlab-namespace=suleimiahmed&x-goog-custom-audit-gitlab-project=suleimiahmed%2Fgolang

Author checklist

  • Feature flags
    • Added feature flag:
    • This feature does not require a feature flag
  • I added unit tests or they are not required
  • I added documentation (or it's not required)
  • I followed code review guidelines
  • I followed Go Style guidelines
  • For database changes including schema migrations:
    • Manually run up and down migrations in a postgres.ai production database clone and post a screenshot of the result here.
    • If adding new queries, extract a query plan from postgres.ai and post the link here. If changing existing queries, also extract a query plan for the current version for comparison.
    • Do not include code that depends on the schema migrations in the same commit. Split the MR into two or more.
  • Ensured this change is safe to deploy to individual stages in the same environment (cny -> prod). State-related changes can be troublesome due to having parts of the fleet processing (possibly related) requests in different ways.

Reviewer checklist

  • Ensure the commit and MR tittle are still accurate.
  • If the change contains a breaking change, apply the breaking change label.
  • If the change is considered high risk, apply the label high-risk-change
  • Identify if the change can be rolled back safely. (note: all other reasons for not being able to rollback will be sufficiently captured by major version changes).

If the MR introduces database schema migrations:

  • Ensure the commit and MR tittle start with fix:, feat:, or perf: so that the change appears on the Changelog
If the changes cannot be rolled back follow these steps:
  • If not, apply the label cannot-rollback.
  • Add a section to the MR description that includes the following details:
    • The reasoning behind why a release containing the presented MR can not be rolled back (e.g. schema migrations or changes to the FS structure)
    • Detailed steps to revert/disable a feature introduced by the same change where a migration cannot be rolled back. (note: ideally MRs containing schema migrations should not contain feature changes.)
    • Ensure this MR does not add code that depends on these changes that cannot be rolled back.

Related to #1187

Edited by Suleimi Ahmed

Merge request reports