From 483467999c97f4cb78de71510ea2e8efe394bdee Mon Sep 17 00:00:00 2001 From: ShiChangkuo Date: Mon, 12 Apr 2021 15:06:57 +0800 Subject: [PATCH] Add SecurityToken field in AKSKAuthOptions --- auth_aksk_options.go | 18 +++++++++--------- provider_client.go | 3 +++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/auth_aksk_options.go b/auth_aksk_options.go index 108d635a2..cd357cd87 100644 --- a/auth_aksk_options.go +++ b/auth_aksk_options.go @@ -11,15 +11,14 @@ type AKSKAuthOptions struct { // "OS_AUTH_URL" in the information provided by the cloud operator. IdentityEndpoint string `json:"-"` - // user project id - ProjectId string - - ProjectName string - // region Region string - // cloud service domain, example: myhwclouds.com + // IAM user project id and name + ProjectId string + ProjectName string + + // IAM account name and id Domain string DomainID string @@ -27,8 +26,9 @@ type AKSKAuthOptions struct { BssDomain string BssDomainID string - AccessKey string //Access Key - SecretKey string //Secret key + AccessKey string //Access Key + SecretKey string //Secret key + SecurityToken string //Security Token for temporary Access Key // AgencyNmae is the name of agnecy AgencyName string @@ -40,7 +40,7 @@ type AKSKAuthOptions struct { DelegatedProject string } -// Implements the method of AuthOptionsProvider +// GetIdentityEndpoint implements the method of AuthOptionsProvider func (opts AKSKAuthOptions) GetIdentityEndpoint() string { return opts.IdentityEndpoint } diff --git a/provider_client.go b/provider_client.go index 6c60f118f..1e7d85f53 100644 --- a/provider_client.go +++ b/provider_client.go @@ -243,6 +243,9 @@ func (client *ProviderClient) Request(method, url string, options *RequestOpts) if client.AKSKAuthOptions.DomainID != "" { req.Header.Set("X-Domain-Id", client.AKSKAuthOptions.DomainID) } + if client.AKSKAuthOptions.SecurityToken != "" { + req.Header.Set("X-Security-Token", client.AKSKAuthOptions.SecurityToken) + } } // Issue the request.