@@ -70,17 +70,17 @@ func (a *authHandlerNS) get(ctx context.Context, host string, sm *session.Manage
7070 }
7171 if parts [0 ] == host {
7272 if h .authority != nil {
73- session , ok , err := sessionauth .VerifyTokenAuthority (ctx , host , h .authority , sm , g )
73+ sessionID , ok , err := sessionauth .VerifyTokenAuthority (ctx , host , h .authority , sm , g )
7474 if err == nil && ok {
75- a .handlers [host + "/" + session ] = h
75+ a .handlers [host + "/" + sessionID ] = h
7676 h .lastUsed = time .Now ()
7777 return h
7878 }
7979 } else {
80- session , username , password , err := sessionauth .CredentialsFunc (sm , g )(host )
80+ sessionID , username , password , err := sessionauth .CredentialsFunc (sm , g )(host )
8181 if err == nil {
8282 if username == h .common .Username && password == h .common .Secret {
83- a .handlers [host + "/" + session ] = h
83+ a .handlers [host + "/" + sessionID ] = h
8484 h .lastUsed = time .Now ()
8585 return h
8686 }
@@ -130,12 +130,12 @@ func (a *dockerAuthorizer) Authorize(ctx context.Context, req *http.Request) err
130130 return nil
131131 }
132132
133- auth , err := ah .authorize (ctx , a .sm , a .session )
133+ authHeader , err := ah .authorize (ctx , a .sm , a .session )
134134 if err != nil {
135135 return err
136136 }
137137
138- req .Header .Set ("Authorization" , auth )
138+ req .Header .Set ("Authorization" , authHeader )
139139 return nil
140140}
141141
@@ -163,7 +163,7 @@ func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.R
163163 }
164164 handler = nil
165165
166- // this hacky way seems to be best method to detect that error is fatal and should not be retried with a new token
166+ // this hacky way seems to be the best method to detect that error is fatal and should not be retried with a new token
167167 if c .Parameters ["error" ] == "insufficient_scope" && parseScopes (oldScopes ).contains (parseScopes (strings .Split (c .Parameters ["scope" ], " " ))) {
168168 return err
169169 }
@@ -180,12 +180,12 @@ func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.R
180180 }
181181
182182 var username , secret string
183- session , pubKey , err := sessionauth .GetTokenAuthority (ctx , host , a .sm , a .session )
183+ sessionID , pubKey , err := sessionauth .GetTokenAuthority (ctx , host , a .sm , a .session )
184184 if err != nil {
185185 return err
186186 }
187187 if pubKey == nil {
188- session , username , secret , err = a .getCredentials (host )
188+ sessionID , username , secret , err = a .getCredentials (host )
189189 if err != nil {
190190 return err
191191 }
@@ -197,23 +197,20 @@ func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.R
197197 }
198198 common .Scopes = parseScopes (append (common .Scopes , oldScopes ... )).normalize ()
199199
200- a .handlers .set (host , session , newAuthHandler (host , a .client , c .Scheme , pubKey , common ))
200+ a .handlers .set (host , sessionID , newAuthHandler (host , a .client , c .Scheme , pubKey , common ))
201201
202202 return nil
203203 } else if c .Scheme == auth .BasicAuth {
204- session , username , secret , err := a .getCredentials (host )
204+ sessionID , username , secret , err := a .getCredentials (host )
205205 if err != nil {
206206 return err
207207 }
208208
209209 if username != "" && secret != "" {
210- common := auth.TokenOptions {
210+ a . handlers . set ( host , sessionID , newAuthHandler ( host , a . client , c . Scheme , nil , auth.TokenOptions {
211211 Username : username ,
212212 Secret : secret ,
213- }
214-
215- a .handlers .set (host , session , newAuthHandler (host , a .client , c .Scheme , nil , common ))
216-
213+ }))
217214 return nil
218215 }
219216 }
@@ -281,8 +278,8 @@ func (ah *authHandler) doBasicAuth() (string, error) {
281278 return "" , errors .New ("failed to handle basic auth because missing username or secret" )
282279 }
283280
284- auth := base64 .StdEncoding .EncodeToString ([]byte (username + ":" + secret ))
285- return fmt .Sprintf ("Basic %s" , auth ), nil
281+ authHeader := base64 .StdEncoding .EncodeToString ([]byte (username + ":" + secret ))
282+ return fmt .Sprintf ("Basic %s" , authHeader ), nil
286283}
287284
288285func (ah * authHandler ) doBearerAuth (ctx context.Context , sm * session.Manager , g session.Group ) (token string , err error ) {
0 commit comments