Conversation
Adds a new auth type cf-access which allows using this tool with Cloudflare Access. Defines the new auth type, create a new RoundTripper to handle the login / token fetch flow, and set it as the client transport if enabled. I originally planned to add this in prometheus/prometheus for `promtool`, but (1) The implementation is cleaner doing it here and (2) I want to do it for `amtool` as well, so implementing it in `common` means not doing it twice. Signed-off-by: Phil Dibowitz <phil@ipom.com>
ea2dd16 to
8b7f59d
Compare
When developing things (like prometheus#962), it's useful to be able to debug the http roundtrips. This adds a an --http.debug flag which logs the HTTP requests while redacting credentials. Signed-off-by: Phil Dibowitz <phil@ipom.com>
When developing things (like prometheus#962), it's useful to be able to debug the http roundtrips. This adds `debugRoundTripper` that other prom tools can use (behind a `--http.debug` flag) which automatically logs the HTTP requests while redacting credentials. Signed-off-by: Phil Dibowitz <phil@ipom.com>
When developing things (like prometheus#962), it's useful to be able to debug the http roundtrips. This adds `debugRoundTripper` that other prom tools can use (behind a `--http.debug` flag) which automatically logs the HTTP requests while redacting credentials. Signed-off-by: Phil Dibowitz <phil@ipom.com>
|
Thank you. This seems to drag a lot of dependencies to this project, which is broadly used. Do you think it could fit in its own repo/module? We have a precedent: https://github.com/prometheus/sigv4/ . Happy to have that under |
|
Thanks for the reply! Yes, since this is implemented as a RoundTripper, extracting it into a separate module should be straightforward. I originally put it in common to avoid requiring each consumer to interpret authorization.type: cf-access and install an additional RoundTripper. However, a standalone module could keep that integration small while preventing common from inheriting I envision the module providing a helper such as: cfg, cfAccessEnabled, err := cfaccess.PrepareHTTPClientConfig(cfg)
if err != nil {
return err
}This would detect and validate the cf-access configuration and return a copy with the authorization entry removed, preventing common from treating cf-access as a literal HTTP authorization scheme. The consumer would then construct its normal transport and conditionally wrap it: rt, err := commonconfig.NewRoundTripperFromConfig(cfg, "promtool")
if err != nil {
return err
}
if cfAccessEnabled {
rt = cfaccess.NewRoundTripper(rt)
}
Before doing the extraction, I'd like to confirm that this is the intended architecture and that follow-up integrations for If so, wanna create that repo and I'll make modify this a bit and PR over there? |
Adds a new auth type cf-access which allows using this tool with
Cloudflare Access. Defines the new auth type, create a new RoundTripper
to handle the login / token fetch flow, and set it as the client
transport if enabled.
I originally planned to add this in prometheus/prometheus for
promtool, but (1) The implementation is cleaner doing it here and (2)I want to do it for
amtoolas well, so implementing it incommonmeans not doing it twice.
If you were curious what it looks like to put directly in prometheus/prometheus,
there's a commit here for comparison: jaymzh/prometheus@6ea12c1
Signed-off-by: Phil Dibowitz phil@ipom.com