options.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 options
  15. import (
  16. common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
  17. )
  18. type GatewayOptions struct {
  19. DefaultRegion string `help:"Use default region while region not specific in api request"`
  20. CookieDomain string `help:"specific yunionauth cookie domain" default:""`
  21. Timeout int `help:"Timeout in seconds, default is 300" default:"300"`
  22. DisableModuleApiVersion bool `help:"Disable each modules default api version" default:"false"`
  23. EnableTotp bool `help:"Enable two-factor authentication" default:"false"`
  24. TotpIssuer string `help:"TOTP issuer" default:"Cloudpods"`
  25. SsoRedirectUrl string `help:"SSO idp redirect URL"`
  26. SsoAuthCallbackUrl string `help:"SSO idp auth callback URL"`
  27. SsoLinkCallbackUrl string `help:"SSO idp link user callback URL"`
  28. LoginCallbackParam string `help:"Redirect callback parameter name after successful login"`
  29. SsoUserNotFoundCallbackUrl string `help:"failure callback URL when SSO idp link user not found"`
  30. ReturnFullDomainList bool `default:"true" help:"return domain list for get_regions API"`
  31. SessionLevelAuthCookie bool `default:"false" help:"YunionAuth cookie is valid during a browser session"`
  32. // 上报非敏感基础信息,帮助软件更加完善
  33. DisableReporting bool `default:"false" help:"Reporting data every 24 hours, report data incloud version, os, platform and usages"`
  34. // 启用后端服务反向代理网关
  35. EnableBackendServiceProxy bool `default:"true" help:"Proxy API request to backend services"`
  36. BackendProxyReadWorkerCount int `default:"8" help:"Request worker thread count, default is 8"`
  37. BackendProxyWriteWorkerCount int `default:"4" help:"Request worker thread count, default is 4"`
  38. common_options.CommonOptions `"request_worker_count->default":"32"`
  39. EnableSyslogWebservice bool `help:"enable syslog webservice"`
  40. SyslogWebserviceUsername string `help:"syslog web service user name"`
  41. SyslogWebservicePassword string `help:"syslog web service password"`
  42. }
  43. var (
  44. Options *GatewayOptions
  45. )
  46. func OnOptionsChange(oldO, newO interface{}) bool {
  47. oldOpts := oldO.(*GatewayOptions)
  48. newOpts := newO.(*GatewayOptions)
  49. changed := false
  50. if common_options.OnCommonOptionsChange(&oldOpts.CommonOptions, &newOpts.CommonOptions) {
  51. changed = true
  52. }
  53. if oldOpts.EnableBackendServiceProxy != newOpts.EnableBackendServiceProxy {
  54. changed = true
  55. }
  56. return changed
  57. }