mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #10030 from ioito/hotfix/qx-optimized-azure-saml
fix(cloudid): fix azure saml provider delete error
This commit is contained in:
@@ -28,6 +28,8 @@ type SamluserCreateInput struct {
|
||||
|
||||
// 权限组和账号必须是同一平台
|
||||
CloudaccountId string `json:"cloudaccount_id"`
|
||||
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
type SamluserListInput struct {
|
||||
|
||||
@@ -16,12 +16,15 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/cloudid"
|
||||
compute_api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
|
||||
"yunion.io/x/onecloud/pkg/cloudid/options"
|
||||
@@ -146,7 +149,12 @@ func (manager *SSamluserManager) ValidateCreateData(ctx context.Context, userCre
|
||||
if account.Provider != group.Provider {
|
||||
return input, httperrors.NewConflictError("account %s and group %s not with same provider", account.Name, group.Name)
|
||||
}
|
||||
|
||||
if account.Provider == compute_api.CLOUD_PROVIDER_AZURE {
|
||||
if info := strings.Split(options.Options.ApiServer, ":"); len(info) > 1 {
|
||||
domain := strings.TrimPrefix(info[1], "//")
|
||||
input.Email = fmt.Sprintf("%s@%s", input.Name, domain)
|
||||
}
|
||||
}
|
||||
sq := CloudgroupManager.Query("id").Equals("provider", group.Provider).SubQuery()
|
||||
q := manager.Query().Equals("owner_id", input.OwnerId).Equals("cloudaccount_id", account.Id).In("cloudgroup_id", sq)
|
||||
groups := []SCloudgroup{}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudid/models"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/logclient"
|
||||
)
|
||||
|
||||
@@ -66,7 +67,7 @@ func (self *SAMLProviderDeleteTask) OnInit(ctx context.Context, obj db.IStandalo
|
||||
return
|
||||
}
|
||||
samls, err := provider.GetICloudSAMLProviders()
|
||||
if err != nil {
|
||||
if err != nil && errors.Cause(err) != cloudprovider.ErrNotImplemented {
|
||||
self.taskFailed(ctx, saml, errors.Wrapf(err, "GetICloudSAMLProviders"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func (self *SAzureClient) ListSAMLProviders() ([]SAMLProvider, error) {
|
||||
func (self *SAzureClient) InviteUser(email string) (*SClouduser, error) {
|
||||
body := jsonutils.Marshal(map[string]string{
|
||||
"invitedUserEmailAddress": email,
|
||||
"inviteRedirectUrl": fmt.Sprintf("https://portal.azure.com/%s", self.tenantId),
|
||||
"inviteRedirectUrl": fmt.Sprintf("https://portal.azure.com/%s?login_hint=%s", self.tenantId, email),
|
||||
})
|
||||
resp, err := self.msGraphRequest("POST", "invitations", body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user