mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
修正:1. host request double token 2. cloud provider lost access url
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user