Skip to content

Commit 2b1a567

Browse files
committed
add support for trusts in clientconfig
1 parent 2eeed4c commit 2b1a567

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

openstack/clientconfig/requests.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,12 @@ func v3auth(cloud *Cloud, opts *ClientOpts) (*gophercloud.AuthOptions, error) {
655655
}
656656
}
657657

658+
if cloud.AuthInfo.TrustID == "" {
659+
if v := env.Getenv(envPrefix + "TRUST_ID"); v != "" {
660+
cloud.AuthInfo.TrustID = v
661+
}
662+
}
663+
658664
// Build a scope and try to do it correctly.
659665
// https://github.com/openstack/os-client-config/blob/master/os_client_config/config.py#L595
660666
scope := new(gophercloud.AuthScope)
@@ -664,6 +670,8 @@ func v3auth(cloud *Cloud, opts *ClientOpts) (*gophercloud.AuthOptions, error) {
664670
// If Domain* is set, but UserDomain* or ProjectDomain* aren't,
665671
// then use Domain* as the default setting.
666672
cloud = setDomainIfNeeded(cloud)
673+
} else if isTrust(cloud.AuthInfo) {
674+
scope.TrustID = cloud.AuthInfo.TrustID
667675
} else {
668676
if !isProjectScoped(cloud.AuthInfo) {
669677
if cloud.AuthInfo.DomainID != "" {
@@ -1038,3 +1046,8 @@ func isApplicationCredential(authInfo *AuthInfo) bool {
10381046
}
10391047
return true
10401048
}
1049+
1050+
// isTrust determines if a trust ID is used to auth.
1051+
func isTrust(authInfo *AuthInfo) bool {
1052+
return authInfo.TrustID != ""
1053+
}

openstack/clientconfig/results.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ type AuthInfo struct {
136136
// false, it will not cache these settings, but re-authentication will not be
137137
// possible. This setting defaults to false.
138138
AllowReauth bool `yaml:"allow_reauth,omitempty" json:"allow_reauth,omitempty"`
139+
140+
// TrustID is used the authenticate using Keystone trusts.
141+
// Must also provide trustee Username or UserID with Password and Domain.
142+
TrustID string `yaml:"trust_id,omitempty" json:"trust_id,omitempty"`
139143
}
140144

141145
// Region represents a region included as part of cloud in clouds.yaml

0 commit comments

Comments
 (0)