Add client ID to token fetch to GET endpoint

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2016-03-09 12:44:55 -08:00
parent 46b2c3fadf
commit a59448784b

View file

@ -19,6 +19,8 @@ import (
// basic auth due to lack of credentials. // basic auth due to lack of credentials.
var ErrNoBasicAuthCredentials = errors.New("no basic auth credentials") var ErrNoBasicAuthCredentials = errors.New("no basic auth credentials")
const defaultClientID = "registry-client"
// AuthenticationHandler is an interface for authorizing a request from // AuthenticationHandler is an interface for authorizing a request from
// params from a "WWW-Authenicate" header for a single scheme. // params from a "WWW-Authenicate" header for a single scheme.
type AuthenticationHandler interface { type AuthenticationHandler interface {
@ -272,7 +274,7 @@ func (th *tokenHandler) fetchTokenWithOAuth(realm *url.URL, refreshToken, servic
clientID := th.clientID clientID := th.clientID
if clientID == "" { if clientID == "" {
// Use default client, this is a required field // Use default client, this is a required field
clientID = "registry-client" clientID = defaultClientID
} }
form.Set("client_id", clientID) form.Set("client_id", clientID)
@ -355,6 +357,11 @@ func (th *tokenHandler) fetchTokenWithBasicAuth(realm *url.URL, service string,
if th.offlineAccess { if th.offlineAccess {
reqParams.Add("offline_token", "true") reqParams.Add("offline_token", "true")
clientID := th.clientID
if clientID == "" {
clientID = defaultClientID
}
reqParams.Add("client_id", clientID)
} }
if th.creds != nil { if th.creds != nil {