zero: add user-agent to requests (#5078)

This commit is contained in:
Denis Mishin 2024-04-19 11:33:43 -04:00 committed by GitHub
parent 86c82c0374
commit 2da4801d3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View file

@ -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)
}