mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-04 03:42:49 +02:00
zero: add user-agent to requests (#5078)
This commit is contained in:
parent
86c82c0374
commit
2da4801d3a
3 changed files with 9 additions and 3 deletions
|
@ -11,6 +11,8 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/version"
|
||||
)
|
||||
|
||||
// config is the configuration for the gRPC client
|
||||
|
@ -29,6 +31,7 @@ func getConfig(
|
|||
endpoint string,
|
||||
opts ...grpc.DialOption,
|
||||
) (*config, error) {
|
||||
opts = append(opts, grpc.WithUserAgent(version.UserAgent()))
|
||||
c := &config{opts: opts}
|
||||
err := c.parseEndpoint(endpoint)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package reconciler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pomerium/pomerium/pkg/health"
|
||||
)
|
||||
|
||||
|
@ -12,7 +10,7 @@ func (c *service) ReportBundleAppliedSuccess(
|
|||
) {
|
||||
var attr []health.Attr
|
||||
for k, v := range metadata {
|
||||
attr = append(attr, health.StrAttr(fmt.Sprintf("download-metadata-%s", k), v))
|
||||
attr = append(attr, health.StrAttr(k, v))
|
||||
}
|
||||
health.ReportOK(health.ZeroResourceBundle(bundleID), attr...)
|
||||
}
|
||||
|
|
|
@ -6,12 +6,16 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/version"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultMinTokenTTL = time.Minute * 5
|
||||
)
|
||||
|
||||
var userAgent = version.UserAgent()
|
||||
|
||||
type client struct {
|
||||
tokenProvider TokenProviderFn
|
||||
httpClient *http.Client
|
||||
|
@ -44,6 +48,7 @@ func (c *client) Do(req *http.Request) (*http.Response, error) {
|
|||
return nil, fmt.Errorf("error getting token: %w", err)
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
req.Header.Set("User-Agent", userAgent)
|
||||
|
||||
return c.httpClient.Do(req)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue