fix(region): validate cloudaccount saml auth params

This commit is contained in:
Qu Xuan
2020-11-25 11:33:50 +08:00
parent 4a8eafbc0a
commit c05b75385f
7 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ func init() {
cmd.CreateWithKeyworkd("create-aws", &options.SAWSCloudAccountCreateOptions{})
cmd.CreateWithKeyworkd("create-openstack", &options.SOpenStackCloudAccountCreateOptions{})
cmd.CreateWithKeyworkd("create-huawei", &options.SHuaweiCloudAccountCreateOptions{})
cmd.CreateWithKeyworkd("create-ucloud", &options.SHuaweiCloudAccountCreateOptions{})
cmd.CreateWithKeyworkd("create-ucloud", &options.SUcloudCloudAccountCreateOptions{})
cmd.CreateWithKeyworkd("create-zstack", &options.SZStackCloudAccountCreateOptions{})
cmd.CreateWithKeyworkd("create-s3", &options.SS3CloudAccountCreateOptions{})
cmd.CreateWithKeyworkd("create-ceph", &options.SCephCloudAccountCreateOptions{})
+2
View File
@@ -319,6 +319,8 @@ type CloudaccountUpdateInput struct {
// 带删除的options key
RemoveOptions []string `json:"remove_options"`
SAMLAuth *bool `json:"saml_auth"`
proxyapi.ProxySettingResourceInput
}
+8
View File
@@ -304,6 +304,14 @@ func (self *SCloudaccount) ValidateUpdateData(
input.Options = optionsJson
}
factory, err := self.GetProviderFactory()
if err != nil {
return input, httperrors.NewGeneralError(errors.Wrapf(err, "GetProviderFactory"))
}
if input.SAMLAuth != nil && *input.SAMLAuth && !factory.IsSupportSAMLAuth() {
return input, httperrors.NewNotSupportedError("%s not support saml auth", self.Provider)
}
if len(input.ProxySettingId) > 0 {
var proxySetting *proxy.SProxySetting
proxySetting, input.ProxySettingResourceInput, err = proxy.ValidateProxySettingResourceInput(userCred, input.ProxySettingResourceInput)
+2
View File
@@ -108,6 +108,8 @@ type SCloudAccountCreateBaseOptions struct {
Disabled *bool `help:"create cloud account with disabled status"`
SamlAuth string `help:"Enable or disable saml auth" choices:"true|false"`
ProxySetting string `help:"proxy setting id or name" json:"proxy_setting"`
}
+4
View File
@@ -55,6 +55,10 @@ func (factory *SAwsProviderFactory) IsSystemCloudpolicyUnified() bool {
return false
}
func (factory *SAwsProviderFactory) IsSupportSAMLAuth() bool {
return true
}
func (self *SAwsProviderFactory) GetSupportedDnsZoneTypes() []cloudprovider.TDnsZoneType {
return []cloudprovider.TDnsZoneType{
cloudprovider.PublicZone,
@@ -80,6 +80,10 @@ func (factory *SHuaweiProviderFactory) IsSupportModifyRouteTable() bool {
return true
}
func (factory *SHuaweiProviderFactory) IsSupportSAMLAuth() bool {
return true
}
func (self *SHuaweiProviderFactory) ValidateCreateCloudaccountData(ctx context.Context, userCred mcclient.TokenCredential, input cloudprovider.SCloudaccountCredential) (cloudprovider.SCloudaccount, error) {
output := cloudprovider.SCloudaccount{}
if len(input.AccessKeyId) == 0 {
@@ -62,6 +62,10 @@ func (self *SQcloudProviderFactory) IsSupportCreateCloudgroup() bool {
return true
}
func (self *SQcloudProviderFactory) IsSupportSAMLAuth() bool {
return true
}
func (self *SQcloudProviderFactory) IsSupportCrossCloudEnvVpcPeering() bool {
return false
}