|
|
@@ -957,9 +957,7 @@ func getPluginsFromEnv(idx int) {
|
|
|
}
|
|
|
|
|
|
func getSFTPDBindindFromEnv(idx int) {
|
|
|
- binding := sftpd.Binding{
|
|
|
- ApplyProxyConfig: true,
|
|
|
- }
|
|
|
+ binding := defaultSFTPDBinding
|
|
|
if len(globalConf.SFTPD.Bindings) > idx {
|
|
|
binding = globalConf.SFTPD.Bindings[idx]
|
|
|
}
|
|
|
@@ -995,9 +993,17 @@ func getSFTPDBindindFromEnv(idx int) {
|
|
|
|
|
|
func getFTPDPassiveIPOverridesFromEnv(idx int) []ftpd.PassiveIPOverride {
|
|
|
var overrides []ftpd.PassiveIPOverride
|
|
|
+ if len(globalConf.FTPD.Bindings) > idx {
|
|
|
+ overrides = globalConf.FTPD.Bindings[idx].PassiveIPOverrides
|
|
|
+ }
|
|
|
|
|
|
for subIdx := 0; subIdx < 10; subIdx++ {
|
|
|
var override ftpd.PassiveIPOverride
|
|
|
+ var replace bool
|
|
|
+ if len(globalConf.FTPD.Bindings) > idx && len(globalConf.FTPD.Bindings[idx].PassiveIPOverrides) > subIdx {
|
|
|
+ override = globalConf.FTPD.Bindings[idx].PassiveIPOverrides[subIdx]
|
|
|
+ replace = true
|
|
|
+ }
|
|
|
|
|
|
ip, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_FTPD__BINDINGS__%v__PASSIVE_IP_OVERRIDES__%v__IP", idx, subIdx))
|
|
|
if ok {
|
|
|
@@ -1011,7 +1017,11 @@ func getFTPDPassiveIPOverridesFromEnv(idx int) []ftpd.PassiveIPOverride {
|
|
|
}
|
|
|
|
|
|
if len(override.Networks) > 0 {
|
|
|
- overrides = append(overrides, override)
|
|
|
+ if replace {
|
|
|
+ overrides[subIdx] = override
|
|
|
+ } else {
|
|
|
+ overrides = append(overrides, override)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1019,10 +1029,7 @@ func getFTPDPassiveIPOverridesFromEnv(idx int) []ftpd.PassiveIPOverride {
|
|
|
}
|
|
|
|
|
|
func getDefaultFTPDBinding(idx int) ftpd.Binding {
|
|
|
- binding := ftpd.Binding{
|
|
|
- ApplyProxyConfig: true,
|
|
|
- MinTLSVersion: 12,
|
|
|
- }
|
|
|
+ binding := defaultFTPDBinding
|
|
|
if len(globalConf.FTPD.Bindings) > idx {
|
|
|
binding = globalConf.FTPD.Bindings[idx]
|
|
|
}
|
|
|
@@ -1155,9 +1162,7 @@ func getWebDAVDBindingProxyConfigsFromEnv(idx int, binding *webdavd.Binding) boo
|
|
|
}
|
|
|
|
|
|
func getWebDAVDBindingFromEnv(idx int) {
|
|
|
- binding := webdavd.Binding{
|
|
|
- MinTLSVersion: 12,
|
|
|
- }
|
|
|
+ binding := defaultWebDAVDBinding
|
|
|
if len(globalConf.WebDAVD.Bindings) > idx {
|
|
|
binding = globalConf.WebDAVD.Bindings[idx]
|
|
|
}
|
|
|
@@ -1233,22 +1238,44 @@ func getWebDAVDBindingFromEnv(idx int) {
|
|
|
|
|
|
func getHTTPDSecurityProxyHeadersFromEnv(idx int) []httpd.HTTPSProxyHeader {
|
|
|
var httpsProxyHeaders []httpd.HTTPSProxyHeader
|
|
|
+ if len(globalConf.HTTPDConfig.Bindings) > idx {
|
|
|
+ httpsProxyHeaders = globalConf.HTTPDConfig.Bindings[idx].Security.HTTPSProxyHeaders
|
|
|
+ }
|
|
|
|
|
|
for subIdx := 0; subIdx < 10; subIdx++ {
|
|
|
- proxyKey, _ := os.LookupEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__SECURITY__HTTPS_PROXY_HEADERS__%v__KEY", idx, subIdx))
|
|
|
- proxyVal, _ := os.LookupEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__SECURITY__HTTPS_PROXY_HEADERS__%v__VALUE", idx, subIdx))
|
|
|
- if proxyKey != "" && proxyVal != "" {
|
|
|
- httpsProxyHeaders = append(httpsProxyHeaders, httpd.HTTPSProxyHeader{
|
|
|
- Key: proxyKey,
|
|
|
- Value: proxyVal,
|
|
|
- })
|
|
|
+ var httpsProxyHeader httpd.HTTPSProxyHeader
|
|
|
+ var replace bool
|
|
|
+ if len(globalConf.HTTPDConfig.Bindings) > idx &&
|
|
|
+ len(globalConf.HTTPDConfig.Bindings[idx].Security.HTTPSProxyHeaders) > subIdx {
|
|
|
+ httpsProxyHeader = httpsProxyHeaders[subIdx]
|
|
|
+ replace = true
|
|
|
+ }
|
|
|
+ proxyKey, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__SECURITY__HTTPS_PROXY_HEADERS__%v__KEY",
|
|
|
+ idx, subIdx))
|
|
|
+ if ok {
|
|
|
+ httpsProxyHeader.Key = proxyKey
|
|
|
+ }
|
|
|
+ proxyVal, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__SECURITY__HTTPS_PROXY_HEADERS__%v__VALUE",
|
|
|
+ idx, subIdx))
|
|
|
+ if ok {
|
|
|
+ httpsProxyHeader.Value = proxyVal
|
|
|
+ }
|
|
|
+ if httpsProxyHeader.Key != "" && httpsProxyHeader.Value != "" {
|
|
|
+ if replace {
|
|
|
+ httpsProxyHeaders[subIdx] = httpsProxyHeader
|
|
|
+ } else {
|
|
|
+ httpsProxyHeaders = append(httpsProxyHeaders, httpsProxyHeader)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return httpsProxyHeaders
|
|
|
}
|
|
|
|
|
|
func getHTTPDSecurityConfFromEnv(idx int) (httpd.SecurityConf, bool) { //nolint:gocyclo
|
|
|
- var result httpd.SecurityConf
|
|
|
+ result := defaultHTTPDBinding.Security
|
|
|
+ if len(globalConf.HTTPDConfig.Bindings) > idx {
|
|
|
+ result = globalConf.HTTPDConfig.Bindings[idx].Security
|
|
|
+ }
|
|
|
isSet := false
|
|
|
|
|
|
enabled, ok := lookupBoolFromEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__SECURITY__ENABLED", idx))
|
|
|
@@ -1296,6 +1323,7 @@ func getHTTPDSecurityConfFromEnv(idx int) (httpd.SecurityConf, bool) { //nolint:
|
|
|
stsSeconds, ok := lookupIntFromEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__SECURITY__STS_SECONDS", idx))
|
|
|
if ok {
|
|
|
result.STSSeconds = stsSeconds
|
|
|
+ isSet = true
|
|
|
}
|
|
|
|
|
|
stsIncludeSubDomains, ok := lookupBoolFromEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__SECURITY__STS_INCLUDE_SUBDOMAINS", idx))
|
|
|
@@ -1344,7 +1372,10 @@ func getHTTPDSecurityConfFromEnv(idx int) (httpd.SecurityConf, bool) { //nolint:
|
|
|
}
|
|
|
|
|
|
func getHTTPDOIDCFromEnv(idx int) (httpd.OIDC, bool) {
|
|
|
- var result httpd.OIDC
|
|
|
+ result := defaultHTTPDBinding.OIDC
|
|
|
+ if len(globalConf.HTTPDConfig.Bindings) > idx {
|
|
|
+ result = globalConf.HTTPDConfig.Bindings[idx].OIDC
|
|
|
+ }
|
|
|
isSet := false
|
|
|
|
|
|
clientID, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__OIDC__CLIENT_ID", idx))
|
|
|
@@ -1398,78 +1429,81 @@ func getHTTPDOIDCFromEnv(idx int) (httpd.OIDC, bool) {
|
|
|
return result, isSet
|
|
|
}
|
|
|
|
|
|
-func getHTTPDUIBrandingFromEnv(prefix string) (httpd.UIBranding, bool) {
|
|
|
- var result httpd.UIBranding
|
|
|
+func getHTTPDUIBrandingFromEnv(prefix string, branding httpd.UIBranding) (httpd.UIBranding, bool) {
|
|
|
isSet := false
|
|
|
|
|
|
name, ok := os.LookupEnv(fmt.Sprintf("%s__NAME", prefix))
|
|
|
if ok {
|
|
|
- result.Name = name
|
|
|
+ branding.Name = name
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
shortName, ok := os.LookupEnv(fmt.Sprintf("%s__SHORT_NAME", prefix))
|
|
|
if ok {
|
|
|
- result.ShortName = shortName
|
|
|
+ branding.ShortName = shortName
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
faviconPath, ok := os.LookupEnv(fmt.Sprintf("%s__FAVICON_PATH", prefix))
|
|
|
if ok {
|
|
|
- result.FaviconPath = faviconPath
|
|
|
+ branding.FaviconPath = faviconPath
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
logoPath, ok := os.LookupEnv(fmt.Sprintf("%s__LOGO_PATH", prefix))
|
|
|
if ok {
|
|
|
- result.LogoPath = logoPath
|
|
|
+ branding.LogoPath = logoPath
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
loginImagePath, ok := os.LookupEnv(fmt.Sprintf("%s__LOGIN_IMAGE_PATH", prefix))
|
|
|
if ok {
|
|
|
- result.LoginImagePath = loginImagePath
|
|
|
+ branding.LoginImagePath = loginImagePath
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
disclaimerName, ok := os.LookupEnv(fmt.Sprintf("%s__DISCLAIMER_NAME", prefix))
|
|
|
if ok {
|
|
|
- result.DisclaimerName = disclaimerName
|
|
|
+ branding.DisclaimerName = disclaimerName
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
disclaimerPath, ok := os.LookupEnv(fmt.Sprintf("%s__DISCLAIMER_PATH", prefix))
|
|
|
if ok {
|
|
|
- result.DisclaimerPath = disclaimerPath
|
|
|
+ branding.DisclaimerPath = disclaimerPath
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
defaultCSSPath, ok := os.LookupEnv(fmt.Sprintf("%s__DEFAULT_CSS", prefix))
|
|
|
if ok {
|
|
|
- result.DefaultCSS = defaultCSSPath
|
|
|
+ branding.DefaultCSS = defaultCSSPath
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
extraCSS, ok := lookupStringListFromEnv(fmt.Sprintf("%s__EXTRA_CSS", prefix))
|
|
|
if ok {
|
|
|
- result.ExtraCSS = extraCSS
|
|
|
+ branding.ExtraCSS = extraCSS
|
|
|
isSet = true
|
|
|
}
|
|
|
-
|
|
|
- return result, isSet
|
|
|
+ return branding, isSet
|
|
|
}
|
|
|
|
|
|
func getHTTPDBrandingFromEnv(idx int) (httpd.Branding, bool) {
|
|
|
- var result httpd.Branding
|
|
|
+ result := defaultHTTPDBinding.Branding
|
|
|
+ if len(globalConf.HTTPDConfig.Bindings) > idx {
|
|
|
+ result = globalConf.HTTPDConfig.Bindings[idx].Branding
|
|
|
+ }
|
|
|
isSet := false
|
|
|
|
|
|
- webAdmin, ok := getHTTPDUIBrandingFromEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__BRANDING__WEB_ADMIN", idx))
|
|
|
+ webAdmin, ok := getHTTPDUIBrandingFromEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__BRANDING__WEB_ADMIN", idx),
|
|
|
+ result.WebAdmin)
|
|
|
if ok {
|
|
|
result.WebAdmin = webAdmin
|
|
|
isSet = true
|
|
|
}
|
|
|
|
|
|
- webClient, ok := getHTTPDUIBrandingFromEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__BRANDING__WEB_CLIENT", idx))
|
|
|
+ webClient, ok := getHTTPDUIBrandingFromEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__BRANDING__WEB_CLIENT", idx),
|
|
|
+ result.WebClient)
|
|
|
if ok {
|
|
|
result.WebClient = webClient
|
|
|
isSet = true
|
|
|
@@ -1480,9 +1514,18 @@ func getHTTPDBrandingFromEnv(idx int) (httpd.Branding, bool) {
|
|
|
|
|
|
func getHTTPDWebClientIntegrationsFromEnv(idx int) []httpd.WebClientIntegration {
|
|
|
var integrations []httpd.WebClientIntegration
|
|
|
+ if len(globalConf.HTTPDConfig.Bindings) > idx {
|
|
|
+ integrations = globalConf.HTTPDConfig.Bindings[idx].WebClientIntegrations
|
|
|
+ }
|
|
|
|
|
|
for subIdx := 0; subIdx < 10; subIdx++ {
|
|
|
var integration httpd.WebClientIntegration
|
|
|
+ var replace bool
|
|
|
+ if len(globalConf.HTTPDConfig.Bindings) > idx &&
|
|
|
+ len(globalConf.HTTPDConfig.Bindings[idx].WebClientIntegrations) > subIdx {
|
|
|
+ integration = integrations[subIdx]
|
|
|
+ replace = true
|
|
|
+ }
|
|
|
|
|
|
url, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_HTTPD__BINDINGS__%v__WEB_CLIENT_INTEGRATIONS__%v__URL", idx, subIdx))
|
|
|
if ok {
|
|
|
@@ -1495,8 +1538,12 @@ func getHTTPDWebClientIntegrationsFromEnv(idx int) []httpd.WebClientIntegration
|
|
|
integration.FileExtensions = extensions
|
|
|
}
|
|
|
|
|
|
- if url != "" && len(extensions) > 0 {
|
|
|
- integrations = append(integrations, integration)
|
|
|
+ if integration.URL != "" && len(integration.FileExtensions) > 0 {
|
|
|
+ if replace {
|
|
|
+ integrations[subIdx] = integration
|
|
|
+ } else {
|
|
|
+ integrations = append(integrations, integration)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1504,12 +1551,7 @@ func getHTTPDWebClientIntegrationsFromEnv(idx int) []httpd.WebClientIntegration
|
|
|
}
|
|
|
|
|
|
func getDefaultHTTPBinding(idx int) httpd.Binding {
|
|
|
- binding := httpd.Binding{
|
|
|
- EnableWebAdmin: true,
|
|
|
- EnableWebClient: true,
|
|
|
- RenderOpenAPI: true,
|
|
|
- MinTLSVersion: 12,
|
|
|
- }
|
|
|
+ binding := defaultHTTPDBinding
|
|
|
if len(globalConf.HTTPDConfig.Bindings) > idx {
|
|
|
binding = globalConf.HTTPDConfig.Bindings[idx]
|
|
|
}
|
|
|
@@ -1669,6 +1711,9 @@ func setHTTPDBinding(isSet bool, binding httpd.Binding, idx int) {
|
|
|
|
|
|
func getHTTPClientCertificatesFromEnv(idx int) {
|
|
|
tlsCert := httpclient.TLSKeyPair{}
|
|
|
+ if len(globalConf.HTTPConfig.Certificates) > idx {
|
|
|
+ tlsCert = globalConf.HTTPConfig.Certificates[idx]
|
|
|
+ }
|
|
|
|
|
|
cert, ok := os.LookupEnv(fmt.Sprintf("SFTPGO_HTTP__CERTIFICATES__%v__CERT", idx))
|
|
|
if ok {
|