options.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. "yunion.io/x/onecloud/pkg/cloudcommon/options"
  17. )
  18. type SKeystoneOptions struct {
  19. options.BaseOptions
  20. options.DBOptions
  21. AdminPort int `default:"35357" help:"listening port for admin API(deprecated)"`
  22. TokenExpirationSeconds int `default:"86400" help:"token expiration seconds" token:"expiration"`
  23. FernetKeyRepository string `help:"fernet key repo directory" token:"key_repository" default:"/etc/yunion/keystone/fernet-keys"`
  24. SetupCredentialKeys bool `help:"setup standalone fernet keys for credentials" token:"setup_credential_key" default:"false" json:",allowfalse"`
  25. BootstrapAdminUserPassword string `help:"bootstreap sysadmin user password" default:"sysadmin"`
  26. ResetAdminUserPassword bool `help:"reset sysadmin password if exists and this option is true" json:",allowfalse"`
  27. AutoSyncIntervalSeconds int `help:"frequency to check auto sync tasks" default:"30"`
  28. DefaultSyncIntervalSeconds int `help:"frequency to do auto sync tasks" default:"900"`
  29. FetchScopeResourceCountIntervalSeconds int `help:"frequency tp fetch project resource counts" default:"900"`
  30. PasswordExpirationSeconds int `help:"password expires after the duration in seconds"`
  31. PasswordMinimalLength int `help:"password minimal length" default:"6"`
  32. PasswordUniqueHistoryCheck int `help:"password must be unique in last N passwords, default is 0 means no check" default:"0"`
  33. PasswordCharComplexity int `help:"password complexity policy" default:"0"`
  34. PasswordErrorLockCount int `help:"lock user account if given number of failed auth"`
  35. DefaultUserQuota int `default:"500" help:"default quota for user per domain, default is 500"`
  36. DefaultGroupQuota int `default:"500" help:"default quota for group per domain, default is 500"`
  37. DefaultProjectQuota int `default:"500" help:"default quota for project per domain, default is 500"`
  38. DefaultRoleQuota int `default:"500" help:"default quota for role per domain, default is 500"`
  39. DefaultPolicyQuota int `default:"500" help:"default quota for policy per domain, default is 500"`
  40. SessionEndpointType string `help:"Client session end point type"`
  41. // AllowJoinProjectsAcrossDomains bool `help:"allow users/groups to join projects across domains" default:"false"`
  42. DefaultUserLanguage string `help:"default user language, default to zh-CN" default:"zh-CN"`
  43. DomainAdminRoleToNotify string `help:"domain admin role to notify" default:"domainadmin"`
  44. AdminRoleToNotify string `help:"admin role to notify" default:"admin"`
  45. EnableDefaultDashboardPolicy bool `default:"true" help:"enable default dashboard policy"`
  46. SystemDashboardPolicy string `help:"dashboard policy name for system view" default:""`
  47. DomainDashboardPolicy string `help:"dashboard policy name for domain view" default:""`
  48. ProjectDashboardPolicy string `help:"dashboard policy name for project view" default:""`
  49. NoPolicyViolationCheck bool `help:"do not check policy violation when modify or assign policy" default:"false"`
  50. ThreeAdminRoleSystem bool `help:"do not check policy violation when modify or assign policy" default:"false"`
  51. SystemThreeAdminRoleNames []string `help:"Name of system three-admin roles" default:"sys_secadmin,sys_opsadmin,sys_adtadmin"`
  52. DomainThreeAdminRoleNames []string `help:"Name of system three-admin roles" default:"domain_secadmin,domain_opsadmin,domain_adtadmin"`
  53. LdapSearchPageSize uint32 `help:"pagination size for LDAP search" default:"100"`
  54. LdapSyncDisabledUsers bool `help:"auto sync ldap disabled users"`
  55. ProjectAdminRole string `help:"name of role to be saved as admin user of project" default:"project_owner"`
  56. PwdExpiredNotifyDays []int `help:"The notify for password will expire " default:"1,7"`
  57. MaxUserRolesInProject int `help:"maximal allowed roles of a user in a project" default:"5"`
  58. MaxGroupRolesInProject int `help:"maximal allowed roles of a group in a project" default:"3"`
  59. ForceEnableMfa string `help:"force enable mfa" default:"disable" choices:"all|after|disable"`
  60. }
  61. var (
  62. Options SKeystoneOptions
  63. )
  64. func (o SKeystoneOptions) PasswordHistoryCount() int {
  65. if o.PasswordUniqueHistoryCheck > 0 {
  66. return o.PasswordUniqueHistoryCheck
  67. }
  68. return 10
  69. }
  70. func OnOptionsChange(oldOptions, newOptions interface{}) bool {
  71. oldOpts := oldOptions.(*SKeystoneOptions)
  72. newOpts := newOptions.(*SKeystoneOptions)
  73. changed := false
  74. if options.OnBaseOptionsChange(&oldOpts.BaseOptions, &newOpts.BaseOptions) {
  75. changed = true
  76. }
  77. if options.OnDBOptionsChange(&oldOpts.DBOptions, &newOpts.DBOptions) {
  78. changed = true
  79. }
  80. if oldOpts.DefaultUserLanguage != newOpts.DefaultUserLanguage {
  81. changed = true
  82. }
  83. if oldOpts.ForceEnableMfa != newOpts.ForceEnableMfa {
  84. changed = true
  85. }
  86. return changed
  87. }