修正:1. host request double token 2. cloud provider lost access url

This commit is contained in:
Qiu Jian
2018-11-26 01:42:16 +08:00
parent 9e5aee6e6e
commit 3b2b4d59e0
3 changed files with 19 additions and 3 deletions
+14 -1
View File
@@ -133,7 +133,19 @@ func (self *SCloudproviderManager) ValidateCreateData(ctx context.Context, userC
return nil, httperrors.NewUnsupportOperationError("Directly creating cloudprovider is not supported, create cloudaccount instead")
}
func (self *SCloudprovider) getAccessUrl() string {
if len(self.AccessUrl) > 0 {
return self.AccessUrl
}
account := self.GetCloudaccount()
return account.AccessUrl
}
func (self *SCloudprovider) getPassword() (string, error) {
if len(self.Secret) == 0 {
account := self.GetCloudaccount()
return account.getPassword()
}
return utils.DescryptAESBase64(self.Id, self.Secret)
}
@@ -378,11 +390,12 @@ func (self *SCloudprovider) GetDriver() (cloudprovider.ICloudProvider, error) {
return nil, fmt.Errorf("Cloud provider is not enabled")
}
accessUrl := self.getAccessUrl()
passwd, err := self.getPassword()
if err != nil {
return nil, err
}
return cloudprovider.GetProvider(self.Id, self.Name, self.AccessUrl, self.Account, passwd, self.Provider)
return cloudprovider.GetProvider(self.Id, self.Name, accessUrl, self.Account, passwd, self.Provider)
}
func (self *SCloudprovider) savePassword(secret string) error {
+3 -1
View File
@@ -76,7 +76,9 @@ func getDefaultHeader(header http.Header, token string) http.Header {
if header == nil {
header = http.Header{}
}
header.Add("X-Auth-Token", token)
if len(header.Get(AUTH_TOKEN)) == 0 {
header.Add(AUTH_TOKEN, token)
}
}
return header
}
+2 -1
View File
@@ -42,7 +42,8 @@ type ClientSession struct {
func populateHeader(self *http.Header, update http.Header) {
for k, v := range update {
for _, vv := range v {
self.Add(k, vv)
// self.Add(k, vv)
self.Set(k, vv)
}
}
}