From b1945d00942d651baf4b0da576c4aaa65eaf3d04 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 15 Feb 2018 19:18:11 +0000 Subject: [PATCH] swift: fix refresh of authentication token Before this fix we were doing the token refresh but ignoring the new tokens. This bug was introduced in v1.39 by 4c0e2f9b3b17cd403744b2f19f7853ee016d9ae3 Fixes #2018 Fixes #2031 --- backend/swift/swift.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/swift/swift.go b/backend/swift/swift.go index 5c229e4ea..c45ef4ee2 100644 --- a/backend/swift/swift.go +++ b/backend/swift/swift.go @@ -221,6 +221,7 @@ func swiftConnection(name string) (*swift.Connection, error) { return nil, errors.Wrap(err, "failed to read environment variables") } } + StorageUrl, AuthToken := c.StorageUrl, c.AuthToken if !c.Authenticated() { if c.UserName == "" && c.UserId == "" { return nil, errors.New("user name or user id not found for authentication (and no storage_url+auth_token is provided)") @@ -231,15 +232,16 @@ func swiftConnection(name string) (*swift.Connection, error) { if c.AuthUrl == "" { return nil, errors.New("auth not found") } - err := c.Authenticate() + err := c.Authenticate() // fills in c.StorageUrl and c.AuthToken if err != nil { return nil, err } } // Make sure we re-auth with the AuthToken and StorageUrl - // provided by wrapping the existing auth - if c.StorageUrl != "" || c.AuthToken != "" { - c.Auth = newAuth(c.Auth, c.StorageUrl, c.AuthToken) + // provided by wrapping the existing auth, so we can just + // override one or the other or both. + if StorageUrl != "" || AuthToken != "" { + c.Auth = newAuth(c.Auth, StorageUrl, AuthToken) } return c, nil }