config.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. // Package config manages the configuration
  2. package config
  3. import (
  4. "fmt"
  5. "strings"
  6. "github.com/spf13/viper"
  7. "github.com/drakkan/sftpgo/common"
  8. "github.com/drakkan/sftpgo/dataprovider"
  9. "github.com/drakkan/sftpgo/ftpd"
  10. "github.com/drakkan/sftpgo/httpclient"
  11. "github.com/drakkan/sftpgo/httpd"
  12. "github.com/drakkan/sftpgo/kms"
  13. "github.com/drakkan/sftpgo/logger"
  14. "github.com/drakkan/sftpgo/sftpd"
  15. "github.com/drakkan/sftpgo/utils"
  16. "github.com/drakkan/sftpgo/version"
  17. "github.com/drakkan/sftpgo/webdavd"
  18. )
  19. const (
  20. logSender = "config"
  21. // DefaultConfigName defines the name for the default config file.
  22. // This is the file name without extension, we use viper and so we
  23. // support all the config files format supported by viper
  24. DefaultConfigName = "sftpgo"
  25. // ConfigEnvPrefix defines a prefix that ENVIRONMENT variables will use
  26. configEnvPrefix = "sftpgo"
  27. )
  28. var (
  29. globalConf globalConfig
  30. defaultSFTPDBanner = fmt.Sprintf("SFTPGo_%v", version.Get().Version)
  31. defaultFTPDBanner = fmt.Sprintf("SFTPGo %v ready", version.Get().Version)
  32. )
  33. type globalConfig struct {
  34. Common common.Configuration `json:"common" mapstructure:"common"`
  35. SFTPD sftpd.Configuration `json:"sftpd" mapstructure:"sftpd"`
  36. FTPD ftpd.Configuration `json:"ftpd" mapstructure:"ftpd"`
  37. WebDAVD webdavd.Configuration `json:"webdavd" mapstructure:"webdavd"`
  38. ProviderConf dataprovider.Config `json:"data_provider" mapstructure:"data_provider"`
  39. HTTPDConfig httpd.Conf `json:"httpd" mapstructure:"httpd"`
  40. HTTPConfig httpclient.Config `json:"http" mapstructure:"http"`
  41. KMSConfig kms.Configuration `json:"kms" mapstructure:"kms"`
  42. }
  43. func init() {
  44. // create a default configuration to use if no config file is provided
  45. globalConf = globalConfig{
  46. Common: common.Configuration{
  47. IdleTimeout: 15,
  48. UploadMode: 0,
  49. Actions: common.ProtocolActions{
  50. ExecuteOn: []string{},
  51. Hook: "",
  52. },
  53. SetstatMode: 0,
  54. ProxyProtocol: 0,
  55. ProxyAllowed: []string{},
  56. },
  57. SFTPD: sftpd.Configuration{
  58. Banner: defaultSFTPDBanner,
  59. BindPort: 2022,
  60. BindAddress: "",
  61. MaxAuthTries: 0,
  62. HostKeys: []string{},
  63. KexAlgorithms: []string{},
  64. Ciphers: []string{},
  65. MACs: []string{},
  66. TrustedUserCAKeys: []string{},
  67. LoginBannerFile: "",
  68. EnabledSSHCommands: sftpd.GetDefaultSSHCommands(),
  69. KeyboardInteractiveHook: "",
  70. PasswordAuthentication: true,
  71. },
  72. FTPD: ftpd.Configuration{
  73. BindPort: 0,
  74. BindAddress: "",
  75. Banner: defaultFTPDBanner,
  76. BannerFile: "",
  77. ActiveTransfersPortNon20: false,
  78. ForcePassiveIP: "",
  79. PassivePortRange: ftpd.PortRange{
  80. Start: 50000,
  81. End: 50100,
  82. },
  83. CertificateFile: "",
  84. CertificateKeyFile: "",
  85. },
  86. WebDAVD: webdavd.Configuration{
  87. BindPort: 0,
  88. BindAddress: "",
  89. CertificateFile: "",
  90. CertificateKeyFile: "",
  91. Cors: webdavd.Cors{
  92. Enabled: false,
  93. AllowedOrigins: []string{},
  94. AllowedMethods: []string{},
  95. AllowedHeaders: []string{},
  96. ExposedHeaders: []string{},
  97. AllowCredentials: false,
  98. MaxAge: 0,
  99. },
  100. Cache: webdavd.Cache{
  101. Users: webdavd.UsersCacheConfig{
  102. ExpirationTime: 0,
  103. MaxSize: 50,
  104. },
  105. MimeTypes: webdavd.MimeCacheConfig{
  106. Enabled: true,
  107. MaxSize: 1000,
  108. },
  109. },
  110. },
  111. ProviderConf: dataprovider.Config{
  112. Driver: "sqlite",
  113. Name: "sftpgo.db",
  114. Host: "",
  115. Port: 5432,
  116. Username: "",
  117. Password: "",
  118. ConnectionString: "",
  119. SQLTablesPrefix: "",
  120. ManageUsers: 1,
  121. SSLMode: 0,
  122. TrackQuota: 1,
  123. PoolSize: 0,
  124. UsersBaseDir: "",
  125. Actions: dataprovider.UserActions{
  126. ExecuteOn: []string{},
  127. Hook: "",
  128. },
  129. ExternalAuthHook: "",
  130. ExternalAuthScope: 0,
  131. CredentialsPath: "credentials",
  132. PreLoginHook: "",
  133. PostLoginHook: "",
  134. PostLoginScope: 0,
  135. CheckPasswordHook: "",
  136. CheckPasswordScope: 0,
  137. PasswordHashing: dataprovider.PasswordHashing{
  138. Argon2Options: dataprovider.Argon2Options{
  139. Memory: 65536,
  140. Iterations: 1,
  141. Parallelism: 2,
  142. },
  143. },
  144. UpdateMode: 0,
  145. PreferDatabaseCredentials: false,
  146. },
  147. HTTPDConfig: httpd.Conf{
  148. BindPort: 8080,
  149. BindAddress: "127.0.0.1",
  150. TemplatesPath: "templates",
  151. StaticFilesPath: "static",
  152. BackupsPath: "backups",
  153. AuthUserFile: "",
  154. CertificateFile: "",
  155. CertificateKeyFile: "",
  156. },
  157. HTTPConfig: httpclient.Config{
  158. Timeout: 20,
  159. CACertificates: nil,
  160. SkipTLSVerify: false,
  161. },
  162. KMSConfig: kms.Configuration{
  163. Secrets: kms.Secrets{
  164. URL: "",
  165. MasterKeyPath: "",
  166. },
  167. },
  168. }
  169. viper.SetEnvPrefix(configEnvPrefix)
  170. replacer := strings.NewReplacer(".", "__")
  171. viper.SetEnvKeyReplacer(replacer)
  172. viper.SetConfigName(DefaultConfigName)
  173. setViperDefaults()
  174. viper.AutomaticEnv()
  175. viper.AllowEmptyEnv(true)
  176. }
  177. // GetCommonConfig returns the common protocols configuration
  178. func GetCommonConfig() common.Configuration {
  179. return globalConf.Common
  180. }
  181. // SetCommonConfig sets the common protocols configuration
  182. func SetCommonConfig(config common.Configuration) {
  183. globalConf.Common = config
  184. }
  185. // GetSFTPDConfig returns the configuration for the SFTP server
  186. func GetSFTPDConfig() sftpd.Configuration {
  187. return globalConf.SFTPD
  188. }
  189. // SetSFTPDConfig sets the configuration for the SFTP server
  190. func SetSFTPDConfig(config sftpd.Configuration) {
  191. globalConf.SFTPD = config
  192. }
  193. // GetFTPDConfig returns the configuration for the FTP server
  194. func GetFTPDConfig() ftpd.Configuration {
  195. return globalConf.FTPD
  196. }
  197. // SetFTPDConfig sets the configuration for the FTP server
  198. func SetFTPDConfig(config ftpd.Configuration) {
  199. globalConf.FTPD = config
  200. }
  201. // GetWebDAVDConfig returns the configuration for the WebDAV server
  202. func GetWebDAVDConfig() webdavd.Configuration {
  203. return globalConf.WebDAVD
  204. }
  205. // SetWebDAVDConfig sets the configuration for the WebDAV server
  206. func SetWebDAVDConfig(config webdavd.Configuration) {
  207. globalConf.WebDAVD = config
  208. }
  209. // GetHTTPDConfig returns the configuration for the HTTP server
  210. func GetHTTPDConfig() httpd.Conf {
  211. return globalConf.HTTPDConfig
  212. }
  213. // SetHTTPDConfig sets the configuration for the HTTP server
  214. func SetHTTPDConfig(config httpd.Conf) {
  215. globalConf.HTTPDConfig = config
  216. }
  217. //GetProviderConf returns the configuration for the data provider
  218. func GetProviderConf() dataprovider.Config {
  219. return globalConf.ProviderConf
  220. }
  221. //SetProviderConf sets the configuration for the data provider
  222. func SetProviderConf(config dataprovider.Config) {
  223. globalConf.ProviderConf = config
  224. }
  225. // GetHTTPConfig returns the configuration for HTTP clients
  226. func GetHTTPConfig() httpclient.Config {
  227. return globalConf.HTTPConfig
  228. }
  229. // GetKMSConfig returns the KMS configuration
  230. func GetKMSConfig() kms.Configuration {
  231. return globalConf.KMSConfig
  232. }
  233. // SetKMSConfig sets the kms configuration
  234. func SetKMSConfig(config kms.Configuration) {
  235. globalConf.KMSConfig = config
  236. }
  237. // HasServicesToStart returns true if the config defines at least a service to start.
  238. // Supported services are SFTP, FTP and WebDAV
  239. func HasServicesToStart() bool {
  240. if globalConf.SFTPD.BindPort > 0 {
  241. return true
  242. }
  243. if globalConf.FTPD.BindPort > 0 {
  244. return true
  245. }
  246. if globalConf.WebDAVD.BindPort > 0 {
  247. return true
  248. }
  249. return false
  250. }
  251. func getRedactedGlobalConf() globalConfig {
  252. conf := globalConf
  253. conf.ProviderConf.Password = "[redacted]"
  254. return conf
  255. }
  256. // LoadConfig loads the configuration
  257. // configDir will be added to the configuration search paths.
  258. // The search path contains by default the current directory and on linux it contains
  259. // $HOME/.config/sftpgo and /etc/sftpgo too.
  260. // configName is the name of the configuration to search without extension
  261. func LoadConfig(configDir, configName string) error {
  262. var err error
  263. viper.AddConfigPath(configDir)
  264. setViperAdditionalConfigPaths()
  265. viper.AddConfigPath(".")
  266. viper.SetConfigName(configName)
  267. if err = viper.ReadInConfig(); err != nil {
  268. logger.Warn(logSender, "", "error loading configuration file: %v", err)
  269. logger.WarnToConsole("error loading configuration file: %v", err)
  270. }
  271. err = viper.Unmarshal(&globalConf)
  272. if err != nil {
  273. logger.Warn(logSender, "", "error parsing configuration file: %v. Default configuration will be used: %+v",
  274. err, getRedactedGlobalConf())
  275. logger.WarnToConsole("error parsing configuration file: %v. Default configuration will be used.", err)
  276. return err
  277. }
  278. checkCommonParamsCompatibility()
  279. if strings.TrimSpace(globalConf.SFTPD.Banner) == "" {
  280. globalConf.SFTPD.Banner = defaultSFTPDBanner
  281. }
  282. if strings.TrimSpace(globalConf.FTPD.Banner) == "" {
  283. globalConf.FTPD.Banner = defaultFTPDBanner
  284. }
  285. if len(globalConf.ProviderConf.UsersBaseDir) > 0 && !utils.IsFileInputValid(globalConf.ProviderConf.UsersBaseDir) {
  286. err = fmt.Errorf("invalid users base dir %#v will be ignored", globalConf.ProviderConf.UsersBaseDir)
  287. globalConf.ProviderConf.UsersBaseDir = ""
  288. logger.Warn(logSender, "", "Configuration error: %v", err)
  289. logger.WarnToConsole("Configuration error: %v", err)
  290. }
  291. if globalConf.Common.UploadMode < 0 || globalConf.Common.UploadMode > 2 {
  292. err = fmt.Errorf("invalid upload_mode 0, 1 and 2 are supported, configured: %v reset upload_mode to 0",
  293. globalConf.Common.UploadMode)
  294. globalConf.Common.UploadMode = 0
  295. logger.Warn(logSender, "", "Configuration error: %v", err)
  296. logger.WarnToConsole("Configuration error: %v", err)
  297. }
  298. if globalConf.Common.ProxyProtocol < 0 || globalConf.Common.ProxyProtocol > 2 {
  299. err = fmt.Errorf("invalid proxy_protocol 0, 1 and 2 are supported, configured: %v reset proxy_protocol to 0",
  300. globalConf.Common.ProxyProtocol)
  301. globalConf.Common.ProxyProtocol = 0
  302. logger.Warn(logSender, "", "Configuration error: %v", err)
  303. logger.WarnToConsole("Configuration error: %v", err)
  304. }
  305. if globalConf.ProviderConf.ExternalAuthScope < 0 || globalConf.ProviderConf.ExternalAuthScope > 7 {
  306. err = fmt.Errorf("invalid external_auth_scope: %v reset to 0", globalConf.ProviderConf.ExternalAuthScope)
  307. globalConf.ProviderConf.ExternalAuthScope = 0
  308. logger.Warn(logSender, "", "Configuration error: %v", err)
  309. logger.WarnToConsole("Configuration error: %v", err)
  310. }
  311. if len(globalConf.ProviderConf.CredentialsPath) == 0 {
  312. err = fmt.Errorf("invalid credentials path, reset to \"credentials\"")
  313. globalConf.ProviderConf.CredentialsPath = "credentials"
  314. logger.Warn(logSender, "", "Configuration error: %v", err)
  315. logger.WarnToConsole("Configuration error: %v", err)
  316. }
  317. checkHostKeyCompatibility()
  318. logger.Debug(logSender, "", "config file used: '%#v', config loaded: %+v", viper.ConfigFileUsed(), getRedactedGlobalConf())
  319. return err
  320. }
  321. func checkHostKeyCompatibility() {
  322. // we copy deprecated fields to new ones to keep backward compatibility so lint is disabled
  323. if len(globalConf.SFTPD.Keys) > 0 && len(globalConf.SFTPD.HostKeys) == 0 { //nolint:staticcheck
  324. logger.Warn(logSender, "", "keys is deprecated, please use host_keys")
  325. logger.WarnToConsole("keys is deprecated, please use host_keys")
  326. for _, k := range globalConf.SFTPD.Keys { //nolint:staticcheck
  327. globalConf.SFTPD.HostKeys = append(globalConf.SFTPD.HostKeys, k.PrivateKey)
  328. }
  329. }
  330. }
  331. func checkCommonParamsCompatibility() {
  332. // we copy deprecated fields to new ones to keep backward compatibility so lint is disabled
  333. if globalConf.SFTPD.IdleTimeout > 0 { //nolint:staticcheck
  334. logger.Warn(logSender, "", "sftpd.idle_timeout is deprecated, please use common.idle_timeout")
  335. logger.WarnToConsole("sftpd.idle_timeout is deprecated, please use common.idle_timeout")
  336. globalConf.Common.IdleTimeout = globalConf.SFTPD.IdleTimeout //nolint:staticcheck
  337. }
  338. if len(globalConf.SFTPD.Actions.Hook) > 0 && len(globalConf.Common.Actions.Hook) == 0 { //nolint:staticcheck
  339. logger.Warn(logSender, "", "sftpd.actions is deprecated, please use common.actions")
  340. logger.WarnToConsole("sftpd.actions is deprecated, please use common.actions")
  341. globalConf.Common.Actions.ExecuteOn = globalConf.SFTPD.Actions.ExecuteOn //nolint:staticcheck
  342. globalConf.Common.Actions.Hook = globalConf.SFTPD.Actions.Hook //nolint:staticcheck
  343. }
  344. if globalConf.SFTPD.SetstatMode > 0 && globalConf.Common.SetstatMode == 0 { //nolint:staticcheck
  345. logger.Warn(logSender, "", "sftpd.setstat_mode is deprecated, please use common.setstat_mode")
  346. logger.WarnToConsole("sftpd.setstat_mode is deprecated, please use common.setstat_mode")
  347. globalConf.Common.SetstatMode = globalConf.SFTPD.SetstatMode //nolint:staticcheck
  348. }
  349. if globalConf.SFTPD.UploadMode > 0 && globalConf.Common.UploadMode == 0 { //nolint:staticcheck
  350. logger.Warn(logSender, "", "sftpd.upload_mode is deprecated, please use common.upload_mode")
  351. logger.WarnToConsole("sftpd.upload_mode is deprecated, please use common.upload_mode")
  352. globalConf.Common.UploadMode = globalConf.SFTPD.UploadMode //nolint:staticcheck
  353. }
  354. if globalConf.SFTPD.ProxyProtocol > 0 && globalConf.Common.ProxyProtocol == 0 { //nolint:staticcheck
  355. logger.Warn(logSender, "", "sftpd.proxy_protocol is deprecated, please use common.proxy_protocol")
  356. logger.WarnToConsole("sftpd.proxy_protocol is deprecated, please use common.proxy_protocol")
  357. globalConf.Common.ProxyProtocol = globalConf.SFTPD.ProxyProtocol //nolint:staticcheck
  358. globalConf.Common.ProxyAllowed = globalConf.SFTPD.ProxyAllowed //nolint:staticcheck
  359. }
  360. }
  361. func setViperDefaults() {
  362. viper.SetDefault("common.idle_timeout", globalConf.Common.IdleTimeout)
  363. viper.SetDefault("common.upload_mode", globalConf.Common.UploadMode)
  364. viper.SetDefault("common.actions.execute_on", globalConf.Common.Actions.ExecuteOn)
  365. viper.SetDefault("common.actions.hook", globalConf.Common.Actions.Hook)
  366. viper.SetDefault("common.setstat_mode", globalConf.Common.SetstatMode)
  367. viper.SetDefault("common.proxy_protocol", globalConf.Common.ProxyProtocol)
  368. viper.SetDefault("common.proxy_allowed", globalConf.Common.ProxyAllowed)
  369. viper.SetDefault("common.post_connect_hook", globalConf.Common.PostConnectHook)
  370. viper.SetDefault("sftpd.bind_port", globalConf.SFTPD.BindPort)
  371. viper.SetDefault("sftpd.bind_address", globalConf.SFTPD.BindAddress)
  372. viper.SetDefault("sftpd.max_auth_tries", globalConf.SFTPD.MaxAuthTries)
  373. viper.SetDefault("sftpd.banner", globalConf.SFTPD.Banner)
  374. viper.SetDefault("sftpd.host_keys", globalConf.SFTPD.HostKeys)
  375. viper.SetDefault("sftpd.kex_algorithms", globalConf.SFTPD.KexAlgorithms)
  376. viper.SetDefault("sftpd.ciphers", globalConf.SFTPD.Ciphers)
  377. viper.SetDefault("sftpd.macs", globalConf.SFTPD.MACs)
  378. viper.SetDefault("sftpd.trusted_user_ca_keys", globalConf.SFTPD.TrustedUserCAKeys)
  379. viper.SetDefault("sftpd.login_banner_file", globalConf.SFTPD.LoginBannerFile)
  380. viper.SetDefault("sftpd.enabled_ssh_commands", globalConf.SFTPD.EnabledSSHCommands)
  381. viper.SetDefault("sftpd.keyboard_interactive_auth_hook", globalConf.SFTPD.KeyboardInteractiveHook)
  382. viper.SetDefault("sftpd.password_authentication", globalConf.SFTPD.PasswordAuthentication)
  383. viper.SetDefault("ftpd.bind_port", globalConf.FTPD.BindPort)
  384. viper.SetDefault("ftpd.bind_address", globalConf.FTPD.BindAddress)
  385. viper.SetDefault("ftpd.banner", globalConf.FTPD.Banner)
  386. viper.SetDefault("ftpd.banner_file", globalConf.FTPD.BannerFile)
  387. viper.SetDefault("ftpd.active_transfers_port_non_20", globalConf.FTPD.ActiveTransfersPortNon20)
  388. viper.SetDefault("ftpd.force_passive_ip", globalConf.FTPD.ForcePassiveIP)
  389. viper.SetDefault("ftpd.passive_port_range.start", globalConf.FTPD.PassivePortRange.Start)
  390. viper.SetDefault("ftpd.passive_port_range.end", globalConf.FTPD.PassivePortRange.End)
  391. viper.SetDefault("ftpd.certificate_file", globalConf.FTPD.CertificateFile)
  392. viper.SetDefault("ftpd.certificate_key_file", globalConf.FTPD.CertificateKeyFile)
  393. viper.SetDefault("ftpd.tls_mode", globalConf.FTPD.TLSMode)
  394. viper.SetDefault("webdavd.bind_port", globalConf.WebDAVD.BindPort)
  395. viper.SetDefault("webdavd.bind_address", globalConf.WebDAVD.BindAddress)
  396. viper.SetDefault("webdavd.certificate_file", globalConf.WebDAVD.CertificateFile)
  397. viper.SetDefault("webdavd.certificate_key_file", globalConf.WebDAVD.CertificateKeyFile)
  398. viper.SetDefault("webdavd.cors.enabled", globalConf.WebDAVD.Cors.Enabled)
  399. viper.SetDefault("webdavd.cors.allowed_origins", globalConf.WebDAVD.Cors.AllowedOrigins)
  400. viper.SetDefault("webdavd.cors.allowed_methods", globalConf.WebDAVD.Cors.AllowedMethods)
  401. viper.SetDefault("webdavd.cors.allowed_headers", globalConf.WebDAVD.Cors.AllowedHeaders)
  402. viper.SetDefault("webdavd.cors.exposed_headers", globalConf.WebDAVD.Cors.ExposedHeaders)
  403. viper.SetDefault("webdavd.cors.allow_credentials", globalConf.WebDAVD.Cors.AllowCredentials)
  404. viper.SetDefault("webdavd.cors.max_age", globalConf.WebDAVD.Cors.MaxAge)
  405. viper.SetDefault("webdavd.cache.users.expiration_time", globalConf.WebDAVD.Cache.Users.ExpirationTime)
  406. viper.SetDefault("webdavd.cache.users.max_size", globalConf.WebDAVD.Cache.Users.MaxSize)
  407. viper.SetDefault("webdavd.cache.mime_types.enabled", globalConf.WebDAVD.Cache.MimeTypes.Enabled)
  408. viper.SetDefault("webdavd.cache.mime_types.max_size", globalConf.WebDAVD.Cache.MimeTypes.MaxSize)
  409. viper.SetDefault("data_provider.driver", globalConf.ProviderConf.Driver)
  410. viper.SetDefault("data_provider.name", globalConf.ProviderConf.Name)
  411. viper.SetDefault("data_provider.host", globalConf.ProviderConf.Host)
  412. viper.SetDefault("data_provider.port", globalConf.ProviderConf.Port)
  413. viper.SetDefault("data_provider.username", globalConf.ProviderConf.Username)
  414. viper.SetDefault("data_provider.password", globalConf.ProviderConf.Password)
  415. viper.SetDefault("data_provider.sslmode", globalConf.ProviderConf.SSLMode)
  416. viper.SetDefault("data_provider.connection_string", globalConf.ProviderConf.ConnectionString)
  417. viper.SetDefault("data_provider.sql_tables_prefix", globalConf.ProviderConf.SQLTablesPrefix)
  418. viper.SetDefault("data_provider.manage_users", globalConf.ProviderConf.ManageUsers)
  419. viper.SetDefault("data_provider.track_quota", globalConf.ProviderConf.TrackQuota)
  420. viper.SetDefault("data_provider.pool_size", globalConf.ProviderConf.PoolSize)
  421. viper.SetDefault("data_provider.users_base_dir", globalConf.ProviderConf.UsersBaseDir)
  422. viper.SetDefault("data_provider.actions.execute_on", globalConf.ProviderConf.Actions.ExecuteOn)
  423. viper.SetDefault("data_provider.actions.hook", globalConf.ProviderConf.Actions.Hook)
  424. viper.SetDefault("data_provider.external_auth_hook", globalConf.ProviderConf.ExternalAuthHook)
  425. viper.SetDefault("data_provider.external_auth_scope", globalConf.ProviderConf.ExternalAuthScope)
  426. viper.SetDefault("data_provider.credentials_path", globalConf.ProviderConf.CredentialsPath)
  427. viper.SetDefault("data_provider.prefer_database_credentials", globalConf.ProviderConf.PreferDatabaseCredentials)
  428. viper.SetDefault("data_provider.pre_login_hook", globalConf.ProviderConf.PreLoginHook)
  429. viper.SetDefault("data_provider.post_login_hook", globalConf.ProviderConf.PostLoginHook)
  430. viper.SetDefault("data_provider.post_login_scope", globalConf.ProviderConf.PostLoginScope)
  431. viper.SetDefault("data_provider.check_password_hook", globalConf.ProviderConf.CheckPasswordHook)
  432. viper.SetDefault("data_provider.check_password_scope", globalConf.ProviderConf.CheckPasswordScope)
  433. viper.SetDefault("data_provider.password_hashing.argon2_options.memory", globalConf.ProviderConf.PasswordHashing.Argon2Options.Memory)
  434. viper.SetDefault("data_provider.password_hashing.argon2_options.iterations", globalConf.ProviderConf.PasswordHashing.Argon2Options.Iterations)
  435. viper.SetDefault("data_provider.password_hashing.argon2_options.parallelism", globalConf.ProviderConf.PasswordHashing.Argon2Options.Parallelism)
  436. viper.SetDefault("data_provider.update_mode", globalConf.ProviderConf.UpdateMode)
  437. viper.SetDefault("httpd.bind_port", globalConf.HTTPDConfig.BindPort)
  438. viper.SetDefault("httpd.bind_address", globalConf.HTTPDConfig.BindAddress)
  439. viper.SetDefault("httpd.templates_path", globalConf.HTTPDConfig.TemplatesPath)
  440. viper.SetDefault("httpd.static_files_path", globalConf.HTTPDConfig.StaticFilesPath)
  441. viper.SetDefault("httpd.backups_path", globalConf.HTTPDConfig.BackupsPath)
  442. viper.SetDefault("httpd.auth_user_file", globalConf.HTTPDConfig.AuthUserFile)
  443. viper.SetDefault("httpd.certificate_file", globalConf.HTTPDConfig.CertificateFile)
  444. viper.SetDefault("httpd.certificate_key_file", globalConf.HTTPDConfig.CertificateKeyFile)
  445. viper.SetDefault("http.timeout", globalConf.HTTPConfig.Timeout)
  446. viper.SetDefault("http.ca_certificates", globalConf.HTTPConfig.CACertificates)
  447. viper.SetDefault("http.skip_tls_verify", globalConf.HTTPConfig.SkipTLSVerify)
  448. viper.SetDefault("kms.secrets.url", globalConf.KMSConfig.Secrets.URL)
  449. viper.SetDefault("kms.secrets.master_key_path", globalConf.KMSConfig.Secrets.MasterKeyPath)
  450. }