Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SigV4: Allow specifying Host header as config #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

musabshak
Copy link

Instead of determining the Host header value from url.getHost(), allow specifying the Host to use for the SigV4 signature calculation via config.

Rationale:

  • Assume you're using the Gerrit LFS plugin and pointing it to AWS S3 or GCS (S3 REST API)
  • Your Gerrit (and git clients pulling/cloning) are hosted on an on-prem k8s cluster
  • You download say 40TB/month of LFS content (because your CI system needs it maybe)
  • The network egress costs from AWS S3 / GCS for pulling all this content will easily be $2-5k+/ month
  • So you will want to maintain an on-prem caching proxy e.g. NGINX, Varnish etc
  • That is, you will set hostname in your lfs.config on Gerrit to my-varnish-proxy.internaldomain.io
  • my-varnish-proxy will proxy the requests to storage.googleapis.com
  • In order to avoid adding SigV4 logic in your proxy, it is necessary that the Gerrit LFS layer uses the S3 endpoint to calculate the SigV4 signature
  • This is because when GCP is verifying the signature in the presigned URL, it seems to be verifying against the Host: storage.googleapis.com and not the Host header passed in/overridden via the proxy

MinIO used to support this exact use case. It provided its own S3 API (with SigV4 auth), and then it proxied the requests to GCS. However, as of 2022 MinIO deprecated support for proxying to GCS [1]

[1] https://blog.min.io/deprecation-of-the-minio-gateway/

Change-Id: Id2df956c50d43b83ffec3c7955dc34504cde616b

Instead of determining the Host header value from url.getHost(), allow
specifying the Host to use for the SigV4 signature calculation via
config.

Rationale:
- Assume you're using the Gerrit LFS plugin and pointing it to AWS S3
  or GCS (S3 REST API)
- Your Gerrit (and git clients pulling/cloning) are hosted on an on-prem
  k8s cluster
- You download say 40TB/month of LFS content (because your CI system
  needs it maybe)
- The network egress costs from AWS S3 / GCS for pulling all this
  content will easily be $2-5k+/ month
- So you will want to maintain an on-prem caching proxy e.g. NGINX,
  Varnish etc
- That is, you will set hostname in your lfs.config on Gerrit to
  my-varnish-proxy.internaldomain.io
- my-varnish-proxy will proxy the requests to storage.googleapis.com
- In order to avoid adding SigV4 logic in your proxy, it is necessary
  that the Gerrit LFS layer uses the S3 endpoint to calculate the
  SigV4 signature
- This is because when GCP is verifying the signature in the presigned
  URL, it seems to be verifying against the Host: storage.googleapis.com
  and not the Host header passed in/overridden via the proxy

MinIO used to support this exact use case. It provided its own S3 API
(with SigV4 auth), and then it proxied the requests to GCS. However,
as of 2022 MinIO deprecated support for proxying to GCS [1]

[1] https://blog.min.io/deprecation-of-the-minio-gateway/

Change-Id: Id2df956c50d43b83ffec3c7955dc34504cde616b
@musabshak
Copy link
Author

I know JGit does code reviews in the eclipse GerritHub. I was not quickly able to set up an account on that Gerrit. This diff is a test diff to get some preliminary feedback on the community's willingness to accept this patch.

@msohn
Copy link
Member

msohn commented Jan 28, 2025

Follow the contributor guide for instructions how to push changes for review to GerritHub
https://github.com/eclipse-egit/egit/wiki/Contributor-Guide#contributing-patches
You need an Eclipse account
https://accounts.eclipse.org/user/register
and agree to the Eclipse contributor agreement

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.

2 participants