mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-24 03:05:39 +01:00
Fix replication bugs: fix #11974, fix #11939 Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
parent
69fe9e9bf7
commit
a31315aa36
@ -54,9 +54,9 @@ type authorizer struct {
|
||||
}
|
||||
|
||||
func (a *authorizer) Modify(req *http.Request) error {
|
||||
// Nil URL means this is the first time the authorizer is called
|
||||
// Nil underlying authorizer means this is the first time the authorizer is called
|
||||
// Try to connect to the registry and determine the auth scheme
|
||||
if a.url == nil {
|
||||
if a.authorizer == nil {
|
||||
// to avoid concurrent issue
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
@ -74,7 +74,7 @@ func (a *authorizer) Modify(req *http.Request) error {
|
||||
}
|
||||
|
||||
func (a *authorizer) initialize(u *url.URL) error {
|
||||
if a.url != nil {
|
||||
if a.authorizer != nil {
|
||||
return nil
|
||||
}
|
||||
url, err := url.Parse(u.Scheme + "://" + u.Host + "/v2/")
|
||||
|
@ -142,5 +142,8 @@ func (a *authorizer) fetchToken(scopes []*scope) (*token, error) {
|
||||
if err = json.Unmarshal(body, token); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(token.Token) == 0 && len(token.AccessToken) > 0 {
|
||||
token.Token = token.AccessToken
|
||||
}
|
||||
return token, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user