| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607 |
- // Copyright 2019 Yunion
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- package identity
- import (
- "time"
- "yunion.io/x/jsonutils"
- "yunion.io/x/pkg/errors"
- "yunion.io/x/pkg/util/rbacscope"
- "yunion.io/x/onecloud/pkg/apis"
- "yunion.io/x/onecloud/pkg/util/tagutils"
- )
- type IdentityBaseResourceCreateInput struct {
- apis.StandaloneResourceCreateInput
- apis.DomainizedResourceCreateInput
- }
- type EnabledIdentityBaseResourceCreateInput struct {
- IdentityBaseResourceCreateInput
- Enabled *bool `json:"enabled"`
- }
- type IdentityBaseResourceListInput struct {
- apis.StandaloneResourceListInput
- apis.DomainizedResourceListInput
- }
- type EnabledIdentityBaseResourceListInput struct {
- IdentityBaseResourceListInput
- apis.EnabledResourceBaseListInput
- }
- type ProjectFilterListInput struct {
- // 项目归属域
- ProjectDomainId string `json:"project_domain_id"`
- // swagger:ignore
- // Deprecated
- ProjectDomain string `json:"project_domain" yunion-deprecated-by:"project_domain_id"`
- // 以项目(ID或Name)过滤列表结果
- ProjectId string `json:"project_id"`
- // swagger:ignore
- // Deprecated
- // filter by project_id
- Project string `json:"project" yunion-deprecated-by:"project_id"`
- // swagger:ignore
- // Deprecated
- // filter by tenant
- Tenant string `json:"tenant" yunion-deprecated-by:"project_id"`
- // swagger:ignore
- // Deprecated
- // filter by tenant_id
- TenantId string `json:"tenant_id" yunion-deprecated-by:"project_id"`
- }
- type UserFilterListInput struct {
- // 用户归属域
- UserDomainId string `json:"user_domain_id"`
- // swagger:ignore
- // Deprecated
- UserDomain string `json:"user_domain" yunion-deprecated-by:"user_domain_id"`
- // filter by user
- UserId string `json:"user_id"`
- // swagger:ignore
- // Deprecated
- // filter by user_id
- User string `json:"user" yunion-deprecated-by:"user_id"`
- }
- type GroupFilterListInput struct {
- // 组归属域
- GroupDomainId string `json:"group_domain_id"`
- // swagger:ignore
- // Deprecated
- GroupDomain string `json:"group_domain" yunion-deprecated-by:"group_domain_id"`
- // filter by group
- GroupId string `json:"group_id"`
- // swagger:ignore
- // Deprecated
- // filter by group_id
- Group string `json:"group" yunion-deprecated-by:"group_id"`
- }
- type RoleFilterListInput struct {
- // 角色归属域
- RoleDomainId string `json:"role_domain_id"`
- // swagger:ignore
- // Deprecated
- RoleDomain string `json:"role_domain" yunion-deprecated-by:"role_domain_id"`
- // filter by role
- RoleId string `json:"role_id"`
- // swagger:ignore
- // Deprecated
- // filter by role_id
- Role string `json:"role" yunion-deprecated-by:"role_id"`
- }
- type ServiceFilterListInput struct {
- // 服务类型过滤
- ServiceType string `json:"service_type"`
- // 服务名称或ID过滤
- ServiceId string `json:"service_id"`
- // swagger:ignore
- // Deprecated
- // filter by service_id
- Service string `json:"service" yunion-deprecated-by:"service_id"`
- // 以服务名称排序
- OrderByService string `json:"order_by_service"`
- }
- type RoleListInput struct {
- IdentityBaseResourceListInput
- apis.SharableResourceBaseListInput
- ProjectFilterListInput
- UserFilterListInput
- GroupFilterListInput
- }
- type GroupListInput struct {
- IdentityBaseResourceListInput
- UserFilterListInput
- ProjectFilterListInput
- // 名称过滤
- Displayname string `json:"displayname"`
- // 按IDP过滤
- IdpId string `json:"idp_id"`
- }
- type ProjectListInput struct {
- IdentityBaseResourceListInput
- UserFilterListInput
- GroupFilterListInput
- // filter projects by Identity Provider
- IdpId string `json:"idp_id"`
- // 过滤出指定用户或者组可以加入的项目
- Jointable *bool `json:"jointable"`
- // project tags filter imposed by policy
- PolicyProjectTags tagutils.TTagSetList `json:"policy_project_tags"`
- // 通过项目管理员id过滤
- AdminId []string `json:"admin_id"`
- }
- type DomainListInput struct {
- apis.StandaloneResourceListInput
- Enabled *bool `json:"enabled"`
- // 按IDP过滤
- IdpId string `json:"idp_id"`
- // 按IDP_ENTITY_ID过滤
- IdpEntityId string `json:"idp_entity_id"`
- // domain tags filter imposed by policy
- PolicyDomainTags tagutils.TTagSetList `json:"policy_domain_tags"`
- }
- type UserListInput struct {
- EnabledIdentityBaseResourceListInput
- GroupFilterListInput
- ProjectFilterListInput
- RoleFilterListInput
- // 角色生效所在的域
- RoleAssignmentDomainId string `json:"role_assignment_domain_id"`
- // 角色生效所在的项目
- RoleAssignmentProjectId string `json:"role_assignment_project_id"`
- // email
- Email []string `json:"email"`
- // mobile
- Mobile []string `json:"mobile"`
- // displayname
- Displayname []string `json:"displayname"`
- // 是否允许web控制台登录
- AllowWebConsole *bool `json:"allow_web_console"`
- // 是否开启MFA认证
- EnableMfa *bool `json:"enable_mfa"`
- // 关联IDP
- IdpId string `json:"idp_id"`
- // 按IDP_ENTITY_ID过滤
- IdpEntityId string `json:"idp_entity_id"`
- }
- type EndpointListInput struct {
- apis.StandaloneResourceListInput
- ServiceFilterListInput
- RegionFilterListInput
- // 以Endpoint接口类型过滤,可能值为: internal, internalURL, public, publicURL, admin, adminURL, console
- Interface string `json:"interface"`
- // 是否启用
- Enabled *bool `json:"enabled"`
- }
- type SJoinProjectsInput struct {
- Projects []string `json:"projects"`
- Roles []string `json:"roles"`
- // 启用用户, 仅用户禁用时生效
- Enabled bool `json:"enabled"`
- }
- func (input SJoinProjectsInput) Validate() error {
- if len(input.Projects) == 0 {
- return errors.Error("empty projects")
- }
- if len(input.Roles) == 0 {
- return errors.Error("empty roles")
- }
- return nil
- }
- type SProjectRole struct {
- Project string `json:"project"`
- Role string `json:"role"`
- }
- type SLeaveProjectsInput struct {
- ProjectRoles []SProjectRole `json:"project_roles"`
- }
- func (input SLeaveProjectsInput) Validate() error {
- if len(input.ProjectRoles) == 0 {
- return errors.Error("empty project_roles")
- }
- for i := range input.ProjectRoles {
- if len(input.ProjectRoles[i].Project) == 0 {
- return errors.Error("no project in project_roles")
- }
- if len(input.ProjectRoles[i].Role) == 0 {
- return errors.Error("no role in project_roles")
- }
- }
- return nil
- }
- type SProjectAddUserGroupInput struct {
- Users []string `json:"users"`
- Groups []string `json:"groups"`
- Roles []string `json:"roles"`
- EnableAllUsers bool `json:"enable_all_users"`
- }
- func (input SProjectAddUserGroupInput) Validate() error {
- if len(input.Users) == 0 && len(input.Groups) == 0 {
- return errors.Error("empty user and group")
- }
- if len(input.Roles) == 0 {
- return errors.Error("invalid roles")
- }
- return nil
- }
- type SUserRole struct {
- User string `json:"user"`
- Role string `json:"role"`
- }
- type SGroupRole struct {
- Group string `json:"group"`
- Role string `json:"role"`
- }
- type SProjectRemoveUserGroupInput struct {
- UserRoles []SUserRole `json:"user_roles"`
- GroupRoles []SGroupRole `json:"group_roles"`
- }
- func (input SProjectRemoveUserGroupInput) Validate() error {
- if len(input.UserRoles) == 0 && len(input.GroupRoles) == 0 {
- return errors.Error("empty input")
- }
- for i := range input.UserRoles {
- if len(input.UserRoles[i].User) == 0 {
- return errors.Error("empty user")
- }
- if len(input.UserRoles[i].Role) == 0 {
- return errors.Error("empty role")
- }
- }
- for i := range input.GroupRoles {
- if len(input.GroupRoles[i].Group) == 0 {
- return errors.Error("empty group")
- }
- if len(input.GroupRoles[i].Role) == 0 {
- return errors.Error("empty role")
- }
- }
- return nil
- }
- type IdentityProviderListInput struct {
- apis.EnabledStatusStandaloneResourceListInput
- apis.DomainizedResourceListInput
- // 以驱动类型过滤
- Driver []string `json:"driver"`
- // 以模板过滤
- Template []string `json:"template"`
- // 以同步状态过滤
- SyncStatus []string `json:"sync_status"`
- // 过滤支持SSO的认证源,如果值为all,则列出所有的全局认证源,否则可出sso为域ID的域认证源
- // example: all
- SsoDomain string `json:"sso_domain"`
- AutoCreateProject *bool `json:"auto_create_project"`
- AutoCreateUser *bool `json:"auto_create_user"`
- }
- type CredentialListInput struct {
- apis.StandaloneResourceListInput
- UserFilterListInput
- ProjectFilterListInput
- Type []string `json:"type"`
- Enabled *bool `json:"enabled"`
- }
- type PolicyListInput struct {
- EnabledIdentityBaseResourceListInput
- apis.SharableResourceBaseListInput
- // 以类型查询
- Type []string `json:"type"`
- // 是否显示系统权限
- IsSystem *bool `json:"is_system"`
- // filter policies by role id
- RoleId string `json:"role_id"`
- // swagger:ignore
- // Deprecated
- Role string `json:"role" yunion-deprecated-by:"role_id"`
- }
- type RegionFilterListInput struct {
- // 以区域名称或ID过滤
- RegionId string `json:"region_id"`
- // swagger:ignore
- // Deprecated
- Region string `json:"region" yunion-deprecated-by:"region_id"`
- }
- type RegionListInput struct {
- apis.StandaloneResourceListInput
- }
- type ServiceListInput struct {
- apis.StandaloneResourceListInput
- // 以Service Type过滤
- Type []string `json:"type"`
- // 是否启用/禁用
- Enabled *bool `json:"enabled"`
- }
- type IdentityBaseUpdateInput struct {
- apis.StandaloneResourceBaseUpdateInput
- }
- type EnabledIdentityBaseUpdateInput struct {
- IdentityBaseUpdateInput
- // 是否启用
- Enabled *bool `json:"enabled"`
- }
- type GroupUpdateInput struct {
- IdentityBaseUpdateInput
- // display name
- Displayname string `json:"displayname"`
- }
- type IdentityProviderUpdateInput struct {
- apis.EnabledStatusStandaloneResourceBaseUpdateInput
- // TargetDomainId string `json:"target_domain_id"`
- // 当认证后用户加入项目不存在时是否自动创建项目
- AutoCreateProject *bool `json:"auto_create_project"`
- // 当认证后用户不存在时是否自动创建用户
- AutoCreateUser *bool `json:"auto_create_user"`
- SyncIntervalSeconds *int `json:"sync_interval_seconds"`
- // 图标URL
- IconUri string `json:"icon_uri"`
- }
- type PolicyTagInput struct {
- // 匹配的资源标签
- ObjectTags tagutils.TTagSet `json:"object_tags,allowempty"`
- // 匹配的项目标签
- ProjectTags tagutils.TTagSet `json:"project_tags,allowempty"`
- // 匹配的域标签
- DomainTags tagutils.TTagSet `json:"domain_tags,allowempty"`
- // 组织架构节点ID
- OrgNodeId []string `json:"org_node_id,allowempty"`
- }
- type PolicyUpdateInput struct {
- EnabledIdentityBaseUpdateInput
- // Deprecated
- // swagger:ignore
- Type string `json:"type"`
- // Policy内容
- Blob jsonutils.JSONObject `json:"blob"`
- // 生效范围,project|domain|system
- Scope rbacscope.TRbacScope `json:"scope"`
- // 是否为系统权限
- IsSystem *bool `json:"is_system"`
- PolicyTagInput
- // Policy tag更新策略,可能的值为:add|remove|remove,默认为add
- TagUpdatePolicy string `json:"tag_update_policy"`
- }
- const (
- TAG_UPDATE_POLICY_ADD = "add"
- TAG_UPDATE_POLICY_REMOVE = "remove"
- TAG_UPDATE_POLICY_REPLACE = "replace"
- )
- type ProjectUpdateInput struct {
- IdentityBaseUpdateInput
- // 显示名称
- Displayname string `json:"displayname"`
- }
- type RoleUpdateInput struct {
- IdentityBaseUpdateInput
- }
- type UserUpdateInput struct {
- EnabledIdentityBaseUpdateInput
- Email string `json:"email"`
- Mobile string `json:"mobile"`
- Displayname string `json:"displayname"`
- IsSystemAccount *bool `json:"is_system_account"`
- AllowWebConsole *bool `json:"allow_web_console"`
- EnableMfa *bool `json:"enable_mfa"`
- Password string `json:"password"`
- SkipPasswordComplexityCheck *bool `json:"skip_password_complexity_check"`
- Lang string `json:"lang"`
- // 过期时间
- ExpiredAt *time.Time `json:"expired_at"`
- // 清除过期时间
- ClearExpire *bool `json:"clear_expire"`
- }
- type UserCreateInput struct {
- EnabledIdentityBaseResourceCreateInput
- Email string `json:"email"`
- Mobile string `json:"mobile"`
- Displayname string `json:"displayname"`
- IsSystemAccount *bool `json:"is_system_account"`
- AllowWebConsole *bool `json:"allow_web_console"`
- EnableMfa *bool `json:"enable_mfa"`
- Password string `json:"password"`
- SkipPasswordComplexityCheck *bool `json:"skip_password_complexity_check"`
- IdpId string `json:"idp_id"`
- IdpEntityId string `json:"idp_entity_id"`
- Lang string `json:"lang"`
- ExpiredAt *time.Time `json:"expired_at"`
- }
- type ProjectCreateInput struct {
- IdentityBaseResourceCreateInput
- // 显示名称
- Displayname string `json:"displayname"`
- }
- type GroupCreateInput struct {
- IdentityBaseResourceCreateInput
- // display name
- Displayname string `json:"displayname"`
- }
- type PolicyCreateInput struct {
- EnabledIdentityBaseResourceCreateInput
- apis.SharableResourceBaseCreateInput
- // Deprecated
- // swagger:ignore
- Type string `json:"type"`
- // policy
- Blob jsonutils.JSONObject `json:"blob"`
- // 生效范围,project|domain|system
- Scope rbacscope.TRbacScope `json:"scope"`
- // 是否为系统权限
- IsSystem *bool `json:"is_system"`
- PolicyTagInput
- }
- type RoleCreateInput struct {
- IdentityBaseResourceCreateInput
- apis.SharableResourceBaseCreateInput
- }
- type PerformGroupAddUsersInput struct {
- // 待添加用户列表(ID或名称)
- UserIds []string `json:"user_ids"`
- // Deprecated
- // swagger:ignore
- User []string `json:"user" yunion-deprecated-by:"user_ids"`
- }
- type PerformGroupRemoveUsersInput struct {
- // 待删除用户列表(ID或名称)
- UserIds []string `json:"user_ids"`
- // Deprecated
- // swagger:ignore
- User []string `json:"user" yunion-deprecated-by:"user_ids"`
- }
- type UserLinkIdpInput struct {
- IdpId string `json:"idp_id"`
- IdpEntityId string `json:"idp_entity_id"`
- }
- type UserUnlinkIdpInput UserLinkIdpInput
- type SProjectSetAdminInput struct {
- UserId string `json:"user_id"`
- }
|