consts.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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/onecloud/pkg/apis"
  16. const (
  17. SERVICE_TYPE = apis.SERVICE_TYPE_KEYSTONE
  18. DEFAULT_DOMAIN_ID = "default"
  19. DEFAULT_DOMAIN_NAME = "Default"
  20. DefaultRemoteDomainId = "default_domain"
  21. DEFAULT_IDP_ID = DEFAULT_DOMAIN_ID
  22. SystemAdminUser = "sysadmin"
  23. SystemAdminProject = "system"
  24. SystemAdminRole = "admin"
  25. AUTH_METHOD_PASSWORD = "password"
  26. AUTH_METHOD_TOKEN = "token"
  27. AUTH_METHOD_AKSK = "aksk"
  28. AUTH_METHOD_CAS = "cas"
  29. AUTH_METHOD_SAML = "saml"
  30. AUTH_METHOD_OIDC = "oidc"
  31. AUTH_METHOD_OAuth2 = "oauth2"
  32. AUTH_METHOD_VERIFY = "verify"
  33. AUTH_METHOD_ASSUME = "assume"
  34. // AUTH_METHOD_ID_PASSWORD = 1
  35. // AUTH_METHOD_ID_TOKEN = 2
  36. AUTH_TOKEN_HEADER = "X-Auth-Token"
  37. AUTH_SUBJECT_TOKEN_HEADER = "X-Subject-Token"
  38. AssignmentUserProject = "UserProject"
  39. AssignmentGroupProject = "GroupProject"
  40. AssignmentUserDomain = "UserDomain"
  41. AssignmentGroupDomain = "GroupDomain"
  42. EndpointInterfacePublic = "public"
  43. EndpointInterfaceInternal = "internal"
  44. EndpointInterfaceAdmin = "admin"
  45. EndpointInterfaceConsole = "console"
  46. EndpointInterfaceApigateway = "apigateway"
  47. EndpointInterfaceSlave = "slave"
  48. KeystoneDomainRoot = "<<keystone.domain.root>>"
  49. IdMappingEntityUser = "user"
  50. IdMappingEntityGroup = "group"
  51. IdMappingEntityDomain = "domain"
  52. IdentityDriverSQL = "sql"
  53. IdentityDriverLDAP = "ldap"
  54. IdentityDriverCAS = "cas"
  55. IdentityDriverSAML = "saml"
  56. IdentityDriverOIDC = "oidc" // OpenID Connect
  57. IdentityDriverOAuth2 = "oauth2" // OAuth2.0
  58. IdentityDriverStatusConnected = "connected"
  59. IdentityDriverStatusDisconnected = "disconnected"
  60. IdentityDriverStatusDeleting = "deleting"
  61. IdentityDriverStatusDeleteFailed = "delete_fail"
  62. IdentityProviderSyncLocal = "local"
  63. IdentityProviderSyncFull = "full"
  64. IdentityProviderSyncOnAuth = "auth"
  65. IdentitySyncStatusQueued = "queued"
  66. IdentitySyncStatusSyncing = "syncing"
  67. IdentitySyncStatusIdle = "idle"
  68. MinimalSyncIntervalSeconds = 5 * 60 // 5 minutes
  69. AUTH_TOKEN_LENGTH = 64
  70. )
  71. var (
  72. AUTH_METHODS = []string{AUTH_METHOD_PASSWORD, AUTH_METHOD_TOKEN, AUTH_METHOD_AKSK, AUTH_METHOD_CAS}
  73. PASSWORD_PROTECTED_IDPS = []string{
  74. IdentityDriverSQL,
  75. IdentityDriverLDAP,
  76. }
  77. SensitiveDomainConfigMap = map[string][]string{
  78. "ldap": {
  79. "password",
  80. },
  81. }
  82. CommonWhitelistOptionMap = map[string][]string{
  83. "default": {
  84. "enable_quota_check",
  85. "default_quota_value",
  86. "non_default_domain_projects",
  87. "time_zone",
  88. "domainized_namespace",
  89. "api_server",
  90. "customized_private_prefixes",
  91. "global_http_proxy",
  92. "global_https_proxy",
  93. "ignore_nonrunning_guests",
  94. "platform_name",
  95. "enable_cloud_shell",
  96. "platform_names",
  97. "enable_change_owner_auto_rename",
  98. "default_handlers_whitelist_user_agents",
  99. "metadata_server_ip4s",
  100. "metadata_server_ip6s",
  101. },
  102. }
  103. ServiceBlacklistOptionMap = map[string][]string{
  104. "default": {
  105. // ############################
  106. // common blacklist options
  107. // ############################
  108. "help",
  109. "version",
  110. "config",
  111. "pid_file",
  112. "region",
  113. "application_id",
  114. "log_level",
  115. "log_verbose_level",
  116. "temp_path",
  117. "address",
  118. "port",
  119. "port_v2",
  120. "admin_port",
  121. "notify_admin_users",
  122. "session_endpoint_type",
  123. "admin_password",
  124. "admin_project",
  125. "admin_project_domain",
  126. "admin_user",
  127. "admin_domain",
  128. "auth_url",
  129. "enable_ssl",
  130. "ssl_certfile",
  131. "ssl_keyfile",
  132. "ssl_ca_certs",
  133. "is_slave_node",
  134. "config_sync_period_seconds",
  135. "enable_app_profiling",
  136. // ############################
  137. // db blacklist options
  138. // ############################
  139. "sql_connection",
  140. "clickhouse",
  141. "ops_log_with_clickhouse",
  142. "db_checksum_skip_init",
  143. "db_checksum_tables",
  144. "enable_db_checksum_tables",
  145. "db_checksum_hash_algorithm",
  146. "auto_sync_table",
  147. "exit_after_db_init",
  148. "global_virtual_resource_namespace",
  149. "debug_sqlchemy",
  150. "lockman_method",
  151. "etcd_lock_prefix",
  152. "etcd_lock_ttl",
  153. "etcd_endpoints",
  154. "etcd_username",
  155. "etcd_password",
  156. "etcd_use_tls",
  157. "etcd_skip_tls_verify",
  158. "etcd_cacert",
  159. "etcd_cert",
  160. "etcd_key",
  161. "splitable_max_duration_hours",
  162. "splitable_max_keep_segments",
  163. "ops_log_max_keep_months",
  164. "disable_local_vpc",
  165. // ############################
  166. // keystone blacklist options
  167. // ############################
  168. "bootstrap_admin_user_password",
  169. "reset_admin_user_password",
  170. "fernet_key_repository",
  171. // ############################
  172. // baremetal blacklist options
  173. // ############################
  174. "listen_interface",
  175. "access_address",
  176. "listen_address",
  177. "tftp_root",
  178. // "AutoRegisterBaremetal",
  179. "baremetals_path",
  180. // "LinuxDefaultRootUser",
  181. "ipmi_lan_port_shared",
  182. "zone",
  183. "dhcp_lease_time",
  184. "dhcp_renewal_time",
  185. "enable_general_guest_dhcp",
  186. "force_dhcp_probe_ipmi",
  187. "tftp_block_size_in_bytes",
  188. "tftp_max_timeout_retries",
  189. "enable_grub_tftp_download",
  190. "lengthy_worker_count",
  191. "short_worker_count",
  192. // "default_ipmi_password",
  193. // "default_strong_ipmi_password",
  194. // "windows_default_admin_user",
  195. "cache_path",
  196. "enable_pxe_boot",
  197. "boot_iso_path",
  198. // "status_probe_interval_seconds",
  199. // "log_fetch_interval_seconds",
  200. // "send_metrics_interval_seconds",
  201. // ############################
  202. // glance blacklist options
  203. // ############################
  204. "deploy_server_socket_path",
  205. "enable_remote_executor",
  206. "executor_socket_path",
  207. // ############################
  208. // kubeserver blacklist options
  209. // ############################
  210. "running_mode",
  211. "enable_default_policy",
  212. },
  213. }
  214. )
  215. func mergeConfigOptionsFrom(opt1, opt2 map[string][]string) map[string][]string {
  216. for opt, values := range opt2 {
  217. ovalues, _ := opt1[opt]
  218. opt1[opt] = append(ovalues, values...)
  219. }
  220. return opt1
  221. }
  222. func MergeServiceConfigOptions(opts ...map[string][]string) map[string][]string {
  223. ret := make(map[string][]string)
  224. for i := range opts {
  225. ret = mergeConfigOptionsFrom(ret, opts[i])
  226. }
  227. return ret
  228. }