Skip to content

Commit

Permalink
Use merged enhancemnt for AllowReauth and revert auth implementation (#…
Browse files Browse the repository at this point in the history
…28)

Signed-off-by: Ondrej Vasko <ondrej.vaskoo@gmail.com>
  • Loading branch information
Lirt authored Sep 10, 2021
1 parent 8263e1f commit 91845c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/gophercloud/gophercloud v0.20.0
github.com/gophercloud/utils v0.0.0-20210823151123-bfd010397530
github.com/gophercloud/utils v0.0.0-20210909165623-d7085207ff6d
github.com/kr/pretty v0.2.1 // indirect
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ github.com/gophercloud/gophercloud v0.20.0 h1:1+4jrsjVhdX5omlAo4jkmFc6ftLbuXLzgF
github.com/gophercloud/gophercloud v0.20.0/go.mod h1:wRtmUelyIIv3CSSDI47aUwbs075O6i+LY+pXsKCBsb4=
github.com/gophercloud/utils v0.0.0-20210823151123-bfd010397530 h1:4jscVWuPPP5sejJfvv3McomZlBQofDdLwX3w7iYvrVc=
github.com/gophercloud/utils v0.0.0-20210823151123-bfd010397530/go.mod h1:qOGlfG6OIJ193/c3Xt/XjOfHataNZdQcVgiu93LxBUM=
github.com/gophercloud/utils v0.0.0-20210909165623-d7085207ff6d h1:0Wsi5dvUuPF6dVn/CNfEA4xLxmaEtOt7tV2HD16xIf8=
github.com/gophercloud/utils v0.0.0-20210909165623-d7085207ff6d/go.mod h1:qOGlfG6OIJ193/c3Xt/XjOfHataNZdQcVgiu93LxBUM=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
Expand Down
13 changes: 5 additions & 8 deletions src/utils/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strconv"

"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/utils/openstack/clientconfig"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -45,9 +44,13 @@ func Authenticate(pc **gophercloud.ProviderClient, service string, log logrus.Fi
UserDomainID: os.Getenv("OS_SWIFT_USER_DOMAIN_ID"),
ProjectDomainName: os.Getenv("OS_SWIFT_PROJECT_DOMAIN_NAME"),
ProjectDomainID: os.Getenv("OS_SWIFT_PROJECT_DOMAIN_ID"),
AllowReauth: true,
}
} else {
log.Infof("Trying to authenticate against Openstack using environment variables (including application credentials) or using files ~/.config/openstack/clouds.yaml, /etc/openstack/clouds.yaml and ./clouds.yaml")
clientOpts.AuthInfo = &clientconfig.AuthInfo{
AllowReauth: true,
}
}

tlsVerify, err := strconv.ParseBool(GetEnv("TLS_SKIP_VERIFY", "false"))
Expand All @@ -60,13 +63,7 @@ func Authenticate(pc **gophercloud.ProviderClient, service string, log logrus.Fi
transport.TLSClientConfig = tlsConfig
clientOpts.HTTPClient = &http.Client{Transport: transport}

ao, err := clientconfig.AuthOptions(&clientOpts)
ao.AllowReauth = true
if err != nil {
return fmt.Errorf("failed to parse authentication options from environment variables or files: %v", err)
}

*pc, err = openstack.AuthenticatedClient(*ao)
*pc, err = clientconfig.AuthenticatedClient(&clientOpts)
if err != nil {
return err
}
Expand Down

0 comments on commit 91845c1

Please sign in to comment.