config.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package identity
  15. import "yunion.io/x/jsonutils"
  16. const (
  17. QueryScopeOne = "one"
  18. QUeryScopeSub = "sub"
  19. )
  20. type TConfigs map[string]map[string]jsonutils.JSONObject
  21. type SLDAPIdpConfigBaseOptions struct {
  22. Url string `json:"url,omitempty" help:"LDAP server URL" required:"true"`
  23. Suffix string `json:"suffix,omitempty" required:"true"`
  24. User string `json:"user,omitempty" required:"true"`
  25. Password string `json:"password,omitempty" required:"true"`
  26. DisableUserOnImport bool `json:"disable_user_on_import"`
  27. }
  28. type SLDAPIdpConfigSingleDomainOptions struct {
  29. SLDAPIdpConfigBaseOptions
  30. UserTreeDN string `json:"user_tree_dn,omitempty" help:"Base user tree distinguished name" required:"true"`
  31. GroupTreeDN string `json:"group_tree_dn,omitempty" help:"Base group tree distinguished name" required:"true"`
  32. }
  33. type SLDAPIdpConfigMultiDomainOptions struct {
  34. SLDAPIdpConfigBaseOptions
  35. DomainTreeDN string `json:"domain_tree_dn,omitempty" help:"Base domain tree distinguished name" required:"true"`
  36. }
  37. type SLDAPIdpConfigOptions struct {
  38. Url string `json:"url,omitempty" help:"LDAP server URL" required:"true"`
  39. Suffix string `json:"suffix,omitempty" required:"true"`
  40. QueryScope string `json:"query_scope,omitempty" help:"Query scope" choices:"one|sub"`
  41. User string `json:"user,omitempty"`
  42. Password string `json:"password,omitempty"`
  43. DisableUserOnImport bool `json:"disable_user_on_import"`
  44. DomainTreeDN string `json:"domain_tree_dn,omitempty" help:"Domain tree root node dn(distinguished name)"`
  45. DomainFilter string `json:"domain_filter,omitempty"`
  46. DomainObjectclass string `json:"domain_objectclass,omitempty"`
  47. DomainIdAttribute string `json:"domain_id_attribute,omitempty"`
  48. DomainNameAttribute string `json:"domain_name_attribute,omitempty"`
  49. DomainQueryScope string `json:"domain_query_scope,omitempty" help:"Query scope" choices:"one|sub"`
  50. UserTreeDN string `json:"user_tree_dn,omitempty" help:"User tree distinguished name"`
  51. UserFilter string `json:"user_filter,omitempty"`
  52. UserObjectclass string `json:"user_objectclass,omitempty"`
  53. UserIdAttribute string `json:"user_id_attribute,omitempty"`
  54. UserNameAttribute string `json:"user_name_attribute,omitempty"`
  55. UserEnabledAttribute string `json:"user_enabled_attribute,omitempty"`
  56. UserEnabledMask int64 `json:"user_enabled_mask,allowzero" default:"-1"`
  57. UserEnabledDefault string `json:"user_enabled_default,omitempty"`
  58. UserEnabledInvert bool `json:"user_enabled_invert,allowfalse"`
  59. UserAdditionalAttribute []string `json:"user_additional_attribute_mapping,omitempty" token:"user_additional_attribute"`
  60. UserQueryScope string `json:"user_query_scope,omitempty" help:"Query scope" choices:"one|sub"`
  61. GroupTreeDN string `json:"group_tree_dn,omitempty" help:"Group tree distinguished name"`
  62. GroupFilter string `json:"group_filter,omitempty"`
  63. GroupObjectclass string `json:"group_objectclass,omitempty"`
  64. GroupIdAttribute string `json:"group_id_attribute,omitempty"`
  65. GroupNameAttribute string `json:"group_name_attribute,omitempty"`
  66. GroupMemberAttribute string `json:"group_member_attribute,omitempty"`
  67. GroupMembersAreIds bool `json:"group_members_are_ids,allowfalse"`
  68. GroupQueryScope string `json:"group_query_scope,omitempty" help:"Query scope" choices:"one|sub"`
  69. }
  70. const (
  71. IdpTemplateMSSingleDomain = "msad_one_domain"
  72. IdpTemplateMSMultiDomain = "msad_multi_domain"
  73. IdpTemplateOpenLDAPSingleDomain = "openldap_one_domain"
  74. IdpTemplateSAMLTest = "samltest_saml"
  75. IdpTemplateAzureADSAML = "azure_ad_saml"
  76. IdpTemplateDex = "dex_oidc"
  77. IdpTemplateGithub = "github_oidc"
  78. IdpTemplateAzureOAuth2 = "azure_oidc"
  79. IdpTemplateGoogle = "google_oidc"
  80. IdpTemplateAlipay = "alipay_oauth2"
  81. IdpTemplateWechat = "wechat_oauth2"
  82. IdpTemplateDingtalk = "dingtalk_oauth2"
  83. IdpTemplateFeishu = "feishu_oauth2"
  84. IdpTemplateQywechat = "qywechat_oauth2"
  85. IdpTemplateBingoIAM = "bingoiam_oauth2"
  86. )
  87. var (
  88. IdpTemplateDriver = map[string]string{
  89. IdpTemplateMSSingleDomain: IdentityDriverLDAP,
  90. IdpTemplateMSMultiDomain: IdentityDriverLDAP,
  91. IdpTemplateOpenLDAPSingleDomain: IdentityDriverLDAP,
  92. IdpTemplateSAMLTest: IdentityDriverSAML,
  93. IdpTemplateAzureADSAML: IdentityDriverSAML,
  94. IdpTemplateDex: IdentityDriverOIDC,
  95. IdpTemplateGithub: IdentityDriverOIDC,
  96. IdpTemplateAzureOAuth2: IdentityDriverOIDC,
  97. IdpTemplateGoogle: IdentityDriverOIDC,
  98. IdpTemplateAlipay: IdentityDriverOAuth2,
  99. IdpTemplateFeishu: IdentityDriverOAuth2,
  100. IdpTemplateDingtalk: IdentityDriverOAuth2,
  101. IdpTemplateWechat: IdentityDriverOAuth2,
  102. IdpTemplateQywechat: IdentityDriverOAuth2,
  103. IdpTemplateBingoIAM: IdentityDriverOAuth2,
  104. }
  105. )
  106. type PerformConfigInput struct {
  107. // 更新配置的方式
  108. // example: update
  109. //
  110. // | action | 含义 |
  111. // |---------|-----------------------------------------------|
  112. // | update | 增量更新配置 |
  113. // | remove | 删除指定配置 |
  114. // | replace | 全量替换配置,如果action为空,则默认为replace |
  115. //
  116. Action string `json:"action"`
  117. // 配置信息
  118. Config TConfigs `json:"config"`
  119. }