2017-04-12 08:27:57 -04:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
2019-11-29 12:59:40 +01:00
|
|
|
// See LICENSE.txt for license information.
|
2015-09-17 21:00:59 -07:00
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
2018-10-16 16:51:46 +02:00
|
|
|
"crypto/tls"
|
2015-09-17 21:00:59 -07:00
|
|
|
"encoding/json"
|
|
|
|
|
"io"
|
2018-07-30 14:59:08 -04:00
|
|
|
"math"
|
|
|
|
|
"net"
|
2017-05-29 15:46:35 -04:00
|
|
|
"net/http"
|
2016-08-02 16:37:09 -04:00
|
|
|
"net/url"
|
2018-10-16 16:51:46 +02:00
|
|
|
"os"
|
2020-09-30 21:09:56 +02:00
|
|
|
"reflect"
|
2018-05-30 10:48:04 -04:00
|
|
|
"regexp"
|
2018-07-30 14:59:08 -04:00
|
|
|
"strconv"
|
2017-10-03 10:42:19 -04:00
|
|
|
"strings"
|
2017-08-17 15:05:17 +01:00
|
|
|
"time"
|
2019-02-12 14:19:01 -04:00
|
|
|
|
2019-09-12 21:11:05 +02:00
|
|
|
"github.com/mattermost/ldap"
|
2021-04-13 10:40:12 -04:00
|
|
|
|
2021-07-22 12:21:47 +05:30
|
|
|
"github.com/mattermost/mattermost-server/v6/shared/filestore"
|
|
|
|
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
2015-09-17 21:00:59 -07:00
|
|
|
)
|
|
|
|
|
|
2015-09-21 17:34:13 -07:00
|
|
|
const (
|
2021-07-12 20:05:36 +02:00
|
|
|
ConnSecurityNone = ""
|
|
|
|
|
ConnSecurityPlain = "PLAIN"
|
2021-08-12 11:49:16 +02:00
|
|
|
ConnSecurityTLS = "TLS"
|
2021-07-12 20:05:36 +02:00
|
|
|
ConnSecurityStarttls = "STARTTLS"
|
2015-09-21 17:34:13 -07:00
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
ImageDriverLocal = "local"
|
|
|
|
|
ImageDriverS3 = "amazons3"
|
2015-09-21 20:38:31 -07:00
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
DatabaseDriverMysql = "mysql"
|
|
|
|
|
DatabaseDriverPostgres = "postgres"
|
2015-09-29 14:17:16 -07:00
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
SearchengineElasticsearch = "elasticsearch"
|
2021-02-23 13:38:50 +03:00
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
MinioAccessKey = "minioaccesskey"
|
|
|
|
|
MinioSecretKey = "miniosecretkey"
|
|
|
|
|
MinioBucket = "mattermost-test"
|
|
|
|
|
|
|
|
|
|
PasswordMaximumLength = 64
|
|
|
|
|
PasswordMinimumLength = 5
|
|
|
|
|
|
|
|
|
|
ServiceGitlab = "gitlab"
|
|
|
|
|
ServiceGoogle = "google"
|
|
|
|
|
ServiceOffice365 = "office365"
|
|
|
|
|
ServiceOpenid = "openid"
|
|
|
|
|
|
|
|
|
|
GenericNoChannelNotification = "generic_no_channel"
|
|
|
|
|
GenericNotification = "generic"
|
|
|
|
|
GenericNotificationServer = "https://push-test.mattermost.com"
|
|
|
|
|
MmSupportAdvisorAddress = "support-advisor@mattermost.com"
|
|
|
|
|
FullNotification = "full"
|
|
|
|
|
IdLoadedNotification = "id_loaded"
|
|
|
|
|
|
|
|
|
|
DirectMessageAny = "any"
|
|
|
|
|
DirectMessageTeam = "team"
|
|
|
|
|
|
|
|
|
|
ShowUsername = "username"
|
|
|
|
|
ShowNicknameFullName = "nickname_full_name"
|
|
|
|
|
ShowFullName = "full_name"
|
|
|
|
|
|
|
|
|
|
PermissionsAll = "all"
|
|
|
|
|
PermissionsChannelAdmin = "channel_admin"
|
|
|
|
|
PermissionsTeamAdmin = "team_admin"
|
|
|
|
|
PermissionsSystemAdmin = "system_admin"
|
|
|
|
|
|
|
|
|
|
FakeSetting = "********************************"
|
|
|
|
|
|
|
|
|
|
RestrictEmojiCreationAll = "all"
|
|
|
|
|
RestrictEmojiCreationAdmin = "admin"
|
|
|
|
|
RestrictEmojiCreationSystemAdmin = "system_admin"
|
|
|
|
|
|
|
|
|
|
PermissionsDeletePostAll = "all"
|
|
|
|
|
PermissionsDeletePostTeamAdmin = "team_admin"
|
|
|
|
|
PermissionsDeletePostSystemAdmin = "system_admin"
|
|
|
|
|
|
|
|
|
|
GroupUnreadChannelsDisabled = "disabled"
|
|
|
|
|
GroupUnreadChannelsDefaultOn = "default_on"
|
|
|
|
|
GroupUnreadChannelsDefaultOff = "default_off"
|
|
|
|
|
|
|
|
|
|
CollapsedThreadsDisabled = "disabled"
|
|
|
|
|
CollapsedThreadsDefaultOn = "default_on"
|
|
|
|
|
CollapsedThreadsDefaultOff = "default_off"
|
|
|
|
|
|
|
|
|
|
EmailBatchingBufferSize = 256
|
|
|
|
|
EmailBatchingInterval = 30
|
|
|
|
|
|
|
|
|
|
EmailNotificationContentsFull = "full"
|
|
|
|
|
EmailNotificationContentsGeneric = "generic"
|
|
|
|
|
|
2022-03-02 14:26:57 -07:00
|
|
|
EmailSMTPDefaultServer = "localhost"
|
|
|
|
|
EmailSMTPDefaultPort = "10025"
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
SitenameMaxLength = 30
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
ServiceSettingsDefaultSiteURL = "http://localhost:8065"
|
2021-08-12 11:49:16 +02:00
|
|
|
ServiceSettingsDefaultTLSCertFile = ""
|
|
|
|
|
ServiceSettingsDefaultTLSKeyFile = ""
|
2021-07-12 20:05:36 +02:00
|
|
|
ServiceSettingsDefaultReadTimeout = 300
|
|
|
|
|
ServiceSettingsDefaultWriteTimeout = 300
|
|
|
|
|
ServiceSettingsDefaultIdleTimeout = 60
|
|
|
|
|
ServiceSettingsDefaultMaxLoginAttempts = 10
|
|
|
|
|
ServiceSettingsDefaultAllowCorsFrom = ""
|
|
|
|
|
ServiceSettingsDefaultListenAndAddress = ":8065"
|
2021-08-16 19:46:44 +02:00
|
|
|
ServiceSettingsDefaultGfycatAPIKey = "2_KtH_W5"
|
|
|
|
|
ServiceSettingsDefaultGfycatAPISecret = "3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof"
|
2021-11-12 03:11:11 +05:30
|
|
|
ServiceSettingsDefaultDeveloperFlags = ""
|
2021-07-12 20:05:36 +02:00
|
|
|
|
|
|
|
|
TeamSettingsDefaultSiteName = "Mattermost"
|
|
|
|
|
TeamSettingsDefaultMaxUsersPerTeam = 50
|
|
|
|
|
TeamSettingsDefaultCustomBrandText = ""
|
|
|
|
|
TeamSettingsDefaultCustomDescriptionText = ""
|
|
|
|
|
TeamSettingsDefaultUserStatusAwayTimeout = 300
|
|
|
|
|
|
2022-02-18 19:51:57 +05:30
|
|
|
SqlSettingsDefaultDataSource = "postgres://mmuser:mostest@localhost/mattermost_test?sslmode=disable&connect_timeout=10&binary_parameters=yes"
|
2021-07-12 20:05:36 +02:00
|
|
|
|
|
|
|
|
FileSettingsDefaultDirectory = "./data/"
|
|
|
|
|
|
|
|
|
|
ImportSettingsDefaultDirectory = "./import"
|
|
|
|
|
ImportSettingsDefaultRetentionDays = 30
|
|
|
|
|
|
|
|
|
|
ExportSettingsDefaultDirectory = "./export"
|
|
|
|
|
ExportSettingsDefaultRetentionDays = 30
|
|
|
|
|
|
|
|
|
|
EmailSettingsDefaultFeedbackOrganization = ""
|
|
|
|
|
|
2021-11-24 08:48:01 -05:00
|
|
|
SupportSettingsDefaultTermsOfServiceLink = "https://mattermost.com/terms-of-use/"
|
2021-07-12 20:05:36 +02:00
|
|
|
SupportSettingsDefaultPrivacyPolicyLink = "https://mattermost.com/privacy-policy/"
|
2022-03-16 07:47:57 -04:00
|
|
|
SupportSettingsDefaultAboutLink = "https://docs.mattermost.com/about/product.html/"
|
|
|
|
|
SupportSettingsDefaultHelpLink = "https://mattermost.com/default-help/"
|
|
|
|
|
SupportSettingsDefaultReportAProblemLink = "https://mattermost.com/default-report-a-problem/"
|
2021-07-12 20:05:36 +02:00
|
|
|
SupportSettingsDefaultSupportEmail = ""
|
|
|
|
|
SupportSettingsDefaultReAcceptancePeriod = 365
|
|
|
|
|
|
|
|
|
|
LdapSettingsDefaultFirstNameAttribute = ""
|
|
|
|
|
LdapSettingsDefaultLastNameAttribute = ""
|
|
|
|
|
LdapSettingsDefaultEmailAttribute = ""
|
|
|
|
|
LdapSettingsDefaultUsernameAttribute = ""
|
|
|
|
|
LdapSettingsDefaultNicknameAttribute = ""
|
|
|
|
|
LdapSettingsDefaultIdAttribute = ""
|
|
|
|
|
LdapSettingsDefaultPositionAttribute = ""
|
|
|
|
|
LdapSettingsDefaultLoginFieldName = ""
|
|
|
|
|
LdapSettingsDefaultGroupDisplayNameAttribute = ""
|
|
|
|
|
LdapSettingsDefaultGroupIdAttribute = ""
|
|
|
|
|
LdapSettingsDefaultPictureAttribute = ""
|
|
|
|
|
|
|
|
|
|
SamlSettingsDefaultIdAttribute = ""
|
|
|
|
|
SamlSettingsDefaultGuestAttribute = ""
|
|
|
|
|
SamlSettingsDefaultAdminAttribute = ""
|
|
|
|
|
SamlSettingsDefaultFirstNameAttribute = ""
|
|
|
|
|
SamlSettingsDefaultLastNameAttribute = ""
|
|
|
|
|
SamlSettingsDefaultEmailAttribute = ""
|
|
|
|
|
SamlSettingsDefaultUsernameAttribute = ""
|
|
|
|
|
SamlSettingsDefaultNicknameAttribute = ""
|
|
|
|
|
SamlSettingsDefaultLocaleAttribute = ""
|
|
|
|
|
SamlSettingsDefaultPositionAttribute = ""
|
|
|
|
|
|
|
|
|
|
SamlSettingsSignatureAlgorithmSha1 = "RSAwithSHA1"
|
|
|
|
|
SamlSettingsSignatureAlgorithmSha256 = "RSAwithSHA256"
|
|
|
|
|
SamlSettingsSignatureAlgorithmSha512 = "RSAwithSHA512"
|
|
|
|
|
SamlSettingsDefaultSignatureAlgorithm = SamlSettingsSignatureAlgorithmSha1
|
|
|
|
|
|
|
|
|
|
SamlSettingsCanonicalAlgorithmC14n = "Canonical1.0"
|
|
|
|
|
SamlSettingsCanonicalAlgorithmC14n11 = "Canonical1.1"
|
|
|
|
|
SamlSettingsDefaultCanonicalAlgorithm = SamlSettingsCanonicalAlgorithmC14n
|
|
|
|
|
|
|
|
|
|
NativeappSettingsDefaultAppDownloadLink = "https://mattermost.com/download/#mattermostApps"
|
2022-03-16 07:47:57 -04:00
|
|
|
NativeappSettingsDefaultAndroidAppDownloadLink = "https://mattermost.com/mattermost-android-app/"
|
|
|
|
|
NativeappSettingsDefaultIosAppDownloadLink = "https://mattermost.com/mattermost-ios-app/"
|
2021-07-12 20:05:36 +02:00
|
|
|
|
|
|
|
|
ExperimentalSettingsDefaultLinkMetadataTimeoutMilliseconds = 5000
|
|
|
|
|
|
|
|
|
|
AnalyticsSettingsDefaultMaxUsersForStatistics = 2500
|
|
|
|
|
|
|
|
|
|
AnnouncementSettingsDefaultBannerColor = "#f2a93b"
|
|
|
|
|
AnnouncementSettingsDefaultBannerTextColor = "#333333"
|
2021-08-16 19:46:44 +02:00
|
|
|
AnnouncementSettingsDefaultNoticesJsonURL = "https://notices.mattermost.com/"
|
2021-07-12 20:05:36 +02:00
|
|
|
AnnouncementSettingsDefaultNoticesFetchFrequencySeconds = 3600
|
|
|
|
|
|
|
|
|
|
TeamSettingsDefaultTeamText = "default"
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
ElasticsearchSettingsDefaultConnectionURL = "http://localhost:9200"
|
2021-07-12 20:05:36 +02:00
|
|
|
ElasticsearchSettingsDefaultUsername = "elastic"
|
|
|
|
|
ElasticsearchSettingsDefaultPassword = "changeme"
|
|
|
|
|
ElasticsearchSettingsDefaultPostIndexReplicas = 1
|
|
|
|
|
ElasticsearchSettingsDefaultPostIndexShards = 1
|
|
|
|
|
ElasticsearchSettingsDefaultChannelIndexReplicas = 1
|
|
|
|
|
ElasticsearchSettingsDefaultChannelIndexShards = 1
|
|
|
|
|
ElasticsearchSettingsDefaultUserIndexReplicas = 1
|
|
|
|
|
ElasticsearchSettingsDefaultUserIndexShards = 1
|
|
|
|
|
ElasticsearchSettingsDefaultAggregatePostsAfterDays = 365
|
|
|
|
|
ElasticsearchSettingsDefaultPostsAggregatorJobStartTime = "03:00"
|
|
|
|
|
ElasticsearchSettingsDefaultIndexPrefix = ""
|
|
|
|
|
ElasticsearchSettingsDefaultLiveIndexingBatchSize = 1
|
|
|
|
|
ElasticsearchSettingsDefaultBulkIndexingTimeWindowSeconds = 3600
|
|
|
|
|
ElasticsearchSettingsDefaultRequestTimeoutSeconds = 30
|
|
|
|
|
|
|
|
|
|
BleveSettingsDefaultIndexDir = ""
|
|
|
|
|
BleveSettingsDefaultBulkIndexingTimeWindowSeconds = 3600
|
|
|
|
|
|
|
|
|
|
DataRetentionSettingsDefaultMessageRetentionDays = 365
|
|
|
|
|
DataRetentionSettingsDefaultFileRetentionDays = 365
|
2022-01-20 17:46:03 -07:00
|
|
|
DataRetentionSettingsDefaultBoardsRetentionDays = 365
|
2021-07-12 20:05:36 +02:00
|
|
|
DataRetentionSettingsDefaultDeletionJobStartTime = "02:00"
|
|
|
|
|
DataRetentionSettingsDefaultBatchSize = 3000
|
|
|
|
|
|
|
|
|
|
PluginSettingsDefaultDirectory = "./plugins"
|
|
|
|
|
PluginSettingsDefaultClientDirectory = "./client/plugins"
|
|
|
|
|
PluginSettingsDefaultEnableMarketplace = true
|
2021-08-16 19:46:44 +02:00
|
|
|
PluginSettingsDefaultMarketplaceURL = "https://api.integrations.mattermost.com"
|
|
|
|
|
PluginSettingsOldMarketplaceURL = "https://marketplace.integrations.mattermost.com"
|
2021-07-12 20:05:36 +02:00
|
|
|
|
|
|
|
|
ComplianceExportTypeCsv = "csv"
|
|
|
|
|
ComplianceExportTypeActiance = "actiance"
|
|
|
|
|
ComplianceExportTypeGlobalrelay = "globalrelay"
|
|
|
|
|
ComplianceExportTypeGlobalrelayZip = "globalrelay-zip"
|
|
|
|
|
GlobalrelayCustomerTypeA9 = "A9"
|
|
|
|
|
GlobalrelayCustomerTypeA10 = "A10"
|
|
|
|
|
|
|
|
|
|
ClientSideCertCheckPrimaryAuth = "primary"
|
|
|
|
|
ClientSideCertCheckSecondaryAuth = "secondary"
|
|
|
|
|
|
|
|
|
|
ImageProxyTypeLocal = "local"
|
|
|
|
|
ImageProxyTypeAtmosCamo = "atmos/camo"
|
|
|
|
|
|
|
|
|
|
GoogleSettingsDefaultScope = "profile email"
|
|
|
|
|
GoogleSettingsDefaultAuthEndpoint = "https://accounts.google.com/o/oauth2/v2/auth"
|
|
|
|
|
GoogleSettingsDefaultTokenEndpoint = "https://www.googleapis.com/oauth2/v4/token"
|
2021-08-16 19:46:44 +02:00
|
|
|
GoogleSettingsDefaultUserAPIEndpoint = "https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses,nicknames,metadata"
|
2021-07-12 20:05:36 +02:00
|
|
|
|
|
|
|
|
Office365SettingsDefaultScope = "User.Read"
|
|
|
|
|
Office365SettingsDefaultAuthEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
|
|
|
|
|
Office365SettingsDefaultTokenEndpoint = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
|
2021-08-16 19:46:44 +02:00
|
|
|
Office365SettingsDefaultUserAPIEndpoint = "https://graph.microsoft.com/v1.0/me"
|
2021-07-12 20:05:36 +02:00
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
CloudSettingsDefaultCwsURL = "https://customers.mattermost.com"
|
|
|
|
|
CloudSettingsDefaultCwsAPIURL = "https://portal.internal.prod.cloud.mattermost.com"
|
2021-07-12 20:05:36 +02:00
|
|
|
OpenidSettingsDefaultScope = "profile openid email"
|
|
|
|
|
|
|
|
|
|
LocalModeSocketPath = "/var/tmp/mattermost_local.socket"
|
2015-09-21 17:34:13 -07:00
|
|
|
)
|
|
|
|
|
|
2021-01-19 21:16:22 +05:30
|
|
|
func GetDefaultAppCustomURLSchemes() []string {
|
|
|
|
|
return []string{"mmauth://", "mmauthbeta://"}
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-16 16:51:46 +02:00
|
|
|
var ServerTLSSupportedCiphers = map[string]uint16{
|
|
|
|
|
"TLS_RSA_WITH_RC4_128_SHA": tls.TLS_RSA_WITH_RC4_128_SHA,
|
|
|
|
|
"TLS_RSA_WITH_3DES_EDE_CBC_SHA": tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
|
|
|
|
|
"TLS_RSA_WITH_AES_128_CBC_SHA": tls.TLS_RSA_WITH_AES_128_CBC_SHA,
|
|
|
|
|
"TLS_RSA_WITH_AES_256_CBC_SHA": tls.TLS_RSA_WITH_AES_256_CBC_SHA,
|
|
|
|
|
"TLS_RSA_WITH_AES_128_CBC_SHA256": tls.TLS_RSA_WITH_AES_128_CBC_SHA256,
|
|
|
|
|
"TLS_RSA_WITH_AES_128_GCM_SHA256": tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
|
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384": tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
|
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA": tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA,
|
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA": tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
|
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA": tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
|
|
|
|
|
"TLS_ECDHE_RSA_WITH_RC4_128_SHA": tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA,
|
|
|
|
|
"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA": tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
|
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA": tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
|
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA": tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
|
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256": tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
|
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256": tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
|
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256": tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256": tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384": tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384": tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
|
|
|
|
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305": tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
|
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305": tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 21:00:59 -07:00
|
|
|
type ServiceSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
SiteURL *string `access:"environment_web_server,authentication_saml,write_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
WebsocketURL *string `access:"write_restrictable,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
LicenseFileLocation *string `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
ListenAddress *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
ConnectionSecurity *string `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
|
|
|
|
TLSCertFile *string `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
|
|
|
|
TLSKeyFile *string `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
2021-02-15 22:26:19 +03:00
|
|
|
TLSMinVer *string `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
2020-09-30 21:09:56 +02:00
|
|
|
TLSStrictTransport *bool `access:"write_restrictable,cloud_restrictable"`
|
2021-02-15 22:26:19 +03:00
|
|
|
TLSStrictTransportMaxAge *int64 `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
TLSOverwriteCiphers []string `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
UseLetsEncrypt *bool `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
|
|
|
|
LetsEncryptCertificateCacheFile *string `access:"environment_web_server,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
Forward80To443 *bool `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
2021-02-15 22:26:19 +03:00
|
|
|
TrustedProxyIPHeader []string `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
ReadTimeout *int `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
|
|
|
|
WriteTimeout *int `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
IdleTimeout *int `access:"write_restrictable,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
MaximumLoginAttempts *int `access:"authentication_password,write_restrictable,cloud_restrictable"`
|
2021-02-15 22:26:19 +03:00
|
|
|
GoroutineHealthThreshold *int `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableOAuthServiceProvider *bool `access:"integrations_integration_management"`
|
|
|
|
|
EnableIncomingWebhooks *bool `access:"integrations_integration_management"`
|
|
|
|
|
EnableOutgoingWebhooks *bool `access:"integrations_integration_management"`
|
|
|
|
|
EnableCommands *bool `access:"integrations_integration_management"`
|
|
|
|
|
EnablePostUsernameOverride *bool `access:"integrations_integration_management"`
|
|
|
|
|
EnablePostIconOverride *bool `access:"integrations_integration_management"`
|
|
|
|
|
GoogleDeveloperKey *string `access:"site_posts,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableLinkPreviews *bool `access:"site_posts"`
|
2021-08-09 11:33:21 -04:00
|
|
|
EnablePermalinkPreviews *bool `access:"site_posts"`
|
2021-04-06 10:39:48 -04:00
|
|
|
RestrictLinkPreviews *string `access:"site_posts"`
|
|
|
|
|
EnableTesting *bool `access:"environment_developer,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableDeveloper *bool `access:"environment_developer,write_restrictable,cloud_restrictable"`
|
2021-11-12 03:11:11 +05:30
|
|
|
DeveloperFlags *string `access:"environment_developer"`
|
2022-02-15 13:00:46 -05:00
|
|
|
EnableClientPerformanceDebugging *bool `access:"environment_developer,write_restrictable,cloud_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
EnableOpenTracing *bool `access:"write_restrictable,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableSecurityFixAlert *bool `access:"environment_smtp,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableInsecureOutgoingConnections *bool `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AllowedUntrustedInternalConnections *string `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableMultifactorAuthentication *bool `access:"authentication_mfa"`
|
|
|
|
|
EnforceMultifactorAuthentication *bool `access:"authentication_mfa"`
|
|
|
|
|
EnableUserAccessTokens *bool `access:"integrations_integration_management"`
|
|
|
|
|
AllowCorsFrom *string `access:"integrations_cors,write_restrictable,cloud_restrictable"`
|
|
|
|
|
CorsExposedHeaders *string `access:"integrations_cors,write_restrictable,cloud_restrictable"`
|
|
|
|
|
CorsAllowCredentials *bool `access:"integrations_cors,write_restrictable,cloud_restrictable"`
|
|
|
|
|
CorsDebug *bool `access:"integrations_cors,write_restrictable,cloud_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
AllowCookiesForSubdomains *bool `access:"write_restrictable,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
ExtendSessionLengthWithActivity *bool `access:"environment_session_lengths,write_restrictable,cloud_restrictable"`
|
|
|
|
|
SessionLengthWebInDays *int `access:"environment_session_lengths,write_restrictable,cloud_restrictable"`
|
|
|
|
|
SessionLengthMobileInDays *int `access:"environment_session_lengths,write_restrictable,cloud_restrictable"`
|
2022-02-15 12:50:56 -05:00
|
|
|
SessionLengthSSOInDays *int `access:"environment_session_lengths,write_restrictable,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
SessionCacheInMinutes *int `access:"environment_session_lengths,write_restrictable,cloud_restrictable"`
|
|
|
|
|
SessionIdleTimeoutInMinutes *int `access:"environment_session_lengths,write_restrictable,cloud_restrictable"`
|
2021-02-15 22:26:19 +03:00
|
|
|
WebsocketSecurePort *int `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
WebsocketPort *int `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
WebserverMode *string `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableGifPicker *bool `access:"integrations_gif"`
|
2021-08-16 19:46:44 +02:00
|
|
|
GfycatAPIKey *string `access:"integrations_gif"`
|
|
|
|
|
GfycatAPISecret *string `access:"integrations_gif"`
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableCustomEmoji *bool `access:"site_emoji"`
|
|
|
|
|
EnableEmojiPicker *bool `access:"site_emoji"`
|
2020-08-21 16:49:31 -04:00
|
|
|
PostEditTimeLimit *int `access:"user_management_permissions"`
|
2021-04-06 10:39:48 -04:00
|
|
|
TimeBetweenUserTypingUpdatesMilliseconds *int64 `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
EnablePostSearch *bool `access:"write_restrictable,cloud_restrictable"`
|
2021-02-26 07:41:05 +01:00
|
|
|
EnableFileSearch *bool `access:"write_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
MinimumHashtagLength *int `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableUserTypingMessages *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableChannelViewedMessages *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
EnableUserStatuses *bool `access:"write_restrictable,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
ExperimentalEnableAuthenticationTransfer *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
ClusterLogTimeoutMilliseconds *int `access:"write_restrictable,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
EnablePreviewFeatures *bool `access:"experimental_features"`
|
|
|
|
|
EnableTutorial *bool `access:"experimental_features"`
|
2021-08-09 08:56:10 +03:00
|
|
|
EnableOnboardingFlow *bool `access:"experimental_features"`
|
2021-04-06 10:39:48 -04:00
|
|
|
ExperimentalEnableDefaultChannelLeaveJoinMessages *bool `access:"experimental_features"`
|
|
|
|
|
ExperimentalGroupUnreadChannels *string `access:"experimental_features"`
|
2018-05-18 09:13:23 -04:00
|
|
|
EnableAPITeamDeletion *bool
|
2020-07-22 12:02:23 +00:00
|
|
|
EnableAPIUserDeletion *bool
|
2021-04-06 10:39:48 -04:00
|
|
|
ExperimentalEnableHardenedMode *bool `access:"experimental_features"`
|
|
|
|
|
ExperimentalStrictCSRFEnforcement *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableEmailInvitations *bool `access:"authentication_signup"`
|
|
|
|
|
DisableBotsWhenOwnerIsDeactivated *bool `access:"integrations_bot_accounts,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableBotAccountCreation *bool `access:"integrations_bot_accounts"`
|
|
|
|
|
EnableSVGs *bool `access:"site_posts"`
|
|
|
|
|
EnableLatex *bool `access:"site_posts"`
|
2021-08-30 17:52:33 +02:00
|
|
|
EnableInlineLatex *bool `access:"site_posts"`
|
2020-08-14 08:42:39 +00:00
|
|
|
EnableAPIChannelDeletion *bool
|
2020-05-19 18:20:41 +02:00
|
|
|
EnableLocalMode *bool
|
2021-02-15 22:26:19 +03:00
|
|
|
LocalModeSocketLocation *string // telemetry: none
|
|
|
|
|
EnableAWSMetering *bool // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
SplitKey *string `access:"experimental_feature_flags,write_restrictable"` // telemetry: none
|
|
|
|
|
FeatureFlagSyncIntervalSeconds *int `access:"experimental_feature_flags,write_restrictable"` // telemetry: none
|
|
|
|
|
DebugSplit *bool `access:"experimental_feature_flags,write_restrictable"` // telemetry: none
|
|
|
|
|
ThreadAutoFollow *bool `access:"experimental_features"`
|
|
|
|
|
CollapsedThreads *string `access:"experimental_features"`
|
|
|
|
|
ManagedResourcePaths *string `access:"environment_web_server,write_restrictable,cloud_restrictable"`
|
2022-02-17 12:34:39 -05:00
|
|
|
EnableCustomGroups *bool `access:"site_users_and_teams"`
|
2015-09-17 21:00:59 -07:00
|
|
|
}
|
|
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
func (s *ServiceSettings) SetDefaults(isUpdate bool) {
|
2018-07-10 01:54:25 -07:00
|
|
|
if s.EnableEmailInvitations == nil {
|
|
|
|
|
// If the site URL is also not present then assume this is a clean install
|
|
|
|
|
if s.SiteURL == nil {
|
|
|
|
|
s.EnableEmailInvitations = NewBool(false)
|
|
|
|
|
} else {
|
|
|
|
|
s.EnableEmailInvitations = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SiteURL == nil {
|
2019-06-06 20:57:01 +03:00
|
|
|
if s.EnableDeveloper != nil && *s.EnableDeveloper {
|
2021-08-16 19:46:44 +02:00
|
|
|
s.SiteURL = NewString(ServiceSettingsDefaultSiteURL)
|
2019-06-06 20:57:01 +03:00
|
|
|
} else {
|
|
|
|
|
s.SiteURL = NewString("")
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-06-03 09:33:59 -04:00
|
|
|
|
2018-02-20 12:49:45 -08:00
|
|
|
if s.WebsocketURL == nil {
|
|
|
|
|
s.WebsocketURL = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LicenseFileLocation == nil {
|
|
|
|
|
s.LicenseFileLocation = NewString("")
|
|
|
|
|
}
|
2016-04-13 19:31:01 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.ListenAddress == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ListenAddress = NewString(ServiceSettingsDefaultListenAndAddress)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2015-12-08 13:38:43 -05:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableLinkPreviews == nil {
|
2020-05-20 09:23:13 -04:00
|
|
|
s.EnableLinkPreviews = NewBool(true)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-06-02 16:47:26 -03:00
|
|
|
|
2021-08-09 11:33:21 -04:00
|
|
|
if s.EnablePermalinkPreviews == nil {
|
|
|
|
|
s.EnablePermalinkPreviews = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-09 20:54:54 +03:00
|
|
|
if s.RestrictLinkPreviews == nil {
|
|
|
|
|
s.RestrictLinkPreviews = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.EnableTesting == nil {
|
|
|
|
|
s.EnableTesting = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableDeveloper == nil {
|
|
|
|
|
s.EnableDeveloper = NewBool(false)
|
|
|
|
|
}
|
2017-10-31 08:37:34 -07:00
|
|
|
|
2021-11-12 03:11:11 +05:30
|
|
|
if s.DeveloperFlags == nil {
|
|
|
|
|
s.DeveloperFlags = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-15 13:00:46 -05:00
|
|
|
if s.EnableClientPerformanceDebugging == nil {
|
|
|
|
|
s.EnableClientPerformanceDebugging = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-05 14:46:08 +01:00
|
|
|
if s.EnableOpenTracing == nil {
|
|
|
|
|
s.EnableOpenTracing = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableSecurityFixAlert == nil {
|
|
|
|
|
s.EnableSecurityFixAlert = NewBool(true)
|
|
|
|
|
}
|
2016-07-05 15:49:00 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableInsecureOutgoingConnections == nil {
|
|
|
|
|
s.EnableInsecureOutgoingConnections = NewBool(false)
|
|
|
|
|
}
|
2016-07-05 15:49:00 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AllowedUntrustedInternalConnections == nil {
|
2018-01-22 15:32:50 -06:00
|
|
|
s.AllowedUntrustedInternalConnections = NewString("")
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-07-05 15:49:00 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableMultifactorAuthentication == nil {
|
|
|
|
|
s.EnableMultifactorAuthentication = NewBool(false)
|
|
|
|
|
}
|
2016-07-05 15:49:00 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnforceMultifactorAuthentication == nil {
|
|
|
|
|
s.EnforceMultifactorAuthentication = NewBool(false)
|
|
|
|
|
}
|
2016-07-05 15:49:00 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableUserAccessTokens == nil {
|
|
|
|
|
s.EnableUserAccessTokens = NewBool(false)
|
|
|
|
|
}
|
2016-07-22 10:53:57 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.GoroutineHealthThreshold == nil {
|
|
|
|
|
s.GoroutineHealthThreshold = NewInt(-1)
|
|
|
|
|
}
|
2016-09-15 09:35:44 -03:00
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.GoogleDeveloperKey == nil {
|
|
|
|
|
s.GoogleDeveloperKey = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableOAuthServiceProvider == nil {
|
|
|
|
|
s.EnableOAuthServiceProvider = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableIncomingWebhooks == nil {
|
|
|
|
|
s.EnableIncomingWebhooks = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableOutgoingWebhooks == nil {
|
|
|
|
|
s.EnableOutgoingWebhooks = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.ConnectionSecurity == nil {
|
|
|
|
|
s.ConnectionSecurity = NewString("")
|
|
|
|
|
}
|
2017-05-18 16:26:52 +01:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.TLSKeyFile == nil {
|
2021-08-12 11:49:16 +02:00
|
|
|
s.TLSKeyFile = NewString(ServiceSettingsDefaultTLSKeyFile)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-05-18 15:05:57 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.TLSCertFile == nil {
|
2021-08-12 11:49:16 +02:00
|
|
|
s.TLSCertFile = NewString(ServiceSettingsDefaultTLSCertFile)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-07-07 15:21:02 +01:00
|
|
|
|
2018-10-16 16:51:46 +02:00
|
|
|
if s.TLSMinVer == nil {
|
|
|
|
|
s.TLSMinVer = NewString("1.2")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.TLSStrictTransport == nil {
|
|
|
|
|
s.TLSStrictTransport = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.TLSStrictTransportMaxAge == nil {
|
|
|
|
|
s.TLSStrictTransportMaxAge = NewInt64(63072000)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.TLSOverwriteCiphers == nil {
|
|
|
|
|
s.TLSOverwriteCiphers = []string{}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.UseLetsEncrypt == nil {
|
|
|
|
|
s.UseLetsEncrypt = NewBool(false)
|
|
|
|
|
}
|
2017-10-25 08:17:17 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LetsEncryptCertificateCacheFile == nil {
|
|
|
|
|
s.LetsEncryptCertificateCacheFile = NewString("./config/letsencrypt.cache")
|
|
|
|
|
}
|
2017-08-02 01:36:54 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.ReadTimeout == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ReadTimeout = NewInt(ServiceSettingsDefaultReadTimeout)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-10-26 14:21:22 -05:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.WriteTimeout == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.WriteTimeout = NewInt(ServiceSettingsDefaultWriteTimeout)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2015-09-17 21:00:59 -07:00
|
|
|
|
2020-02-05 11:32:05 +05:30
|
|
|
if s.IdleTimeout == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.IdleTimeout = NewInt(ServiceSettingsDefaultIdleTimeout)
|
2020-02-05 11:32:05 +05:30
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.MaximumLoginAttempts == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.MaximumLoginAttempts = NewInt(ServiceSettingsDefaultMaxLoginAttempts)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Forward80To443 == nil {
|
|
|
|
|
s.Forward80To443 = NewBool(false)
|
2017-10-23 02:39:51 -07:00
|
|
|
}
|
|
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
if isUpdate {
|
|
|
|
|
// When updating an existing configuration, ensure that defaults are set.
|
|
|
|
|
if s.TrustedProxyIPHeader == nil {
|
2021-08-19 10:33:29 +02:00
|
|
|
s.TrustedProxyIPHeader = []string{HeaderForwarded, HeaderRealIP}
|
2019-06-06 20:57:01 +03:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// When generating a blank configuration, leave the list empty.
|
|
|
|
|
s.TrustedProxyIPHeader = []string{}
|
2019-05-24 20:22:13 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.TimeBetweenUserTypingUpdatesMilliseconds == nil {
|
|
|
|
|
s.TimeBetweenUserTypingUpdatesMilliseconds = NewInt64(5000)
|
2015-09-17 21:00:59 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnablePostSearch == nil {
|
|
|
|
|
s.EnablePostSearch = NewBool(true)
|
2015-09-21 20:38:31 -07:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 07:41:05 +01:00
|
|
|
if s.EnableFileSearch == nil {
|
|
|
|
|
s.EnableFileSearch = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 22:09:50 +09:00
|
|
|
if s.MinimumHashtagLength == nil {
|
|
|
|
|
s.MinimumHashtagLength = NewInt(3)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableUserTypingMessages == nil {
|
|
|
|
|
s.EnableUserTypingMessages = NewBool(true)
|
|
|
|
|
}
|
2015-09-21 20:38:31 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableChannelViewedMessages == nil {
|
|
|
|
|
s.EnableChannelViewedMessages = NewBool(true)
|
2015-09-17 21:00:59 -07:00
|
|
|
}
|
2015-09-29 14:17:16 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableUserStatuses == nil {
|
|
|
|
|
s.EnableUserStatuses = NewBool(true)
|
|
|
|
|
}
|
2015-12-09 15:42:48 -08:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.ClusterLogTimeoutMilliseconds == nil {
|
|
|
|
|
s.ClusterLogTimeoutMilliseconds = NewInt(2000)
|
2017-08-31 01:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
2017-12-08 11:15:48 -08:00
|
|
|
if s.EnableTutorial == nil {
|
|
|
|
|
s.EnableTutorial = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-09 08:56:10 +03:00
|
|
|
if s.EnableOnboardingFlow == nil {
|
|
|
|
|
s.EnableOnboardingFlow = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-06 15:41:10 -04:00
|
|
|
// Must be manually enabled for existing installations.
|
|
|
|
|
if s.ExtendSessionLengthWithActivity == nil {
|
|
|
|
|
s.ExtendSessionLengthWithActivity = NewBool(!isUpdate)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SessionLengthWebInDays == nil {
|
2020-05-06 15:41:10 -04:00
|
|
|
if isUpdate {
|
|
|
|
|
s.SessionLengthWebInDays = NewInt(180)
|
|
|
|
|
} else {
|
|
|
|
|
s.SessionLengthWebInDays = NewInt(30)
|
|
|
|
|
}
|
2015-12-09 15:42:48 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SessionLengthMobileInDays == nil {
|
2020-05-06 15:41:10 -04:00
|
|
|
if isUpdate {
|
|
|
|
|
s.SessionLengthMobileInDays = NewInt(180)
|
|
|
|
|
} else {
|
|
|
|
|
s.SessionLengthMobileInDays = NewInt(30)
|
|
|
|
|
}
|
2017-08-31 01:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SessionLengthSSOInDays == nil {
|
2022-02-15 12:50:56 -05:00
|
|
|
s.SessionLengthSSOInDays = NewInt(30)
|
2017-08-31 01:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SessionCacheInMinutes == nil {
|
|
|
|
|
s.SessionCacheInMinutes = NewInt(10)
|
2017-05-29 15:46:35 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SessionIdleTimeoutInMinutes == nil {
|
2019-03-15 10:44:27 -07:00
|
|
|
s.SessionIdleTimeoutInMinutes = NewInt(43200)
|
2017-08-31 01:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableCommands == nil {
|
2019-01-31 08:12:01 -05:00
|
|
|
s.EnableCommands = NewBool(true)
|
2016-10-26 05:21:07 -07:00
|
|
|
}
|
2016-12-22 20:59:04 +01:00
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.EnablePostUsernameOverride == nil {
|
|
|
|
|
s.EnablePostUsernameOverride = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnablePostIconOverride == nil {
|
|
|
|
|
s.EnablePostIconOverride = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.WebsocketPort == nil {
|
|
|
|
|
s.WebsocketPort = NewInt(80)
|
2017-05-30 16:12:24 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.WebsocketSecurePort == nil {
|
|
|
|
|
s.WebsocketSecurePort = NewInt(443)
|
2017-08-08 08:15:20 -06:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AllowCorsFrom == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.AllowCorsFrom = NewString(ServiceSettingsDefaultAllowCorsFrom)
|
2017-09-05 15:24:21 -04:00
|
|
|
}
|
|
|
|
|
|
2018-07-26 08:31:22 -07:00
|
|
|
if s.CorsExposedHeaders == nil {
|
|
|
|
|
s.CorsExposedHeaders = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.CorsAllowCredentials == nil {
|
|
|
|
|
s.CorsAllowCredentials = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.CorsDebug == nil {
|
|
|
|
|
s.CorsDebug = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-20 12:49:45 -08:00
|
|
|
if s.AllowCookiesForSubdomains == nil {
|
|
|
|
|
s.AllowCookiesForSubdomains = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.WebserverMode == nil {
|
|
|
|
|
s.WebserverMode = NewString("gzip")
|
|
|
|
|
} else if *s.WebserverMode == "regular" {
|
|
|
|
|
*s.WebserverMode = "gzip"
|
2017-05-04 15:45:19 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableCustomEmoji == nil {
|
2020-09-24 10:28:27 -04:00
|
|
|
s.EnableCustomEmoji = NewBool(true)
|
2017-07-28 13:52:31 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableEmojiPicker == nil {
|
|
|
|
|
s.EnableEmojiPicker = NewBool(true)
|
2017-07-28 13:52:31 -04:00
|
|
|
}
|
|
|
|
|
|
2018-06-27 13:35:15 -06:00
|
|
|
if s.EnableGifPicker == nil {
|
2020-09-25 11:01:09 -04:00
|
|
|
s.EnableGifPicker = NewBool(true)
|
2018-06-27 13:35:15 -06:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.GfycatAPIKey == nil || *s.GfycatAPIKey == "" {
|
|
|
|
|
s.GfycatAPIKey = NewString(ServiceSettingsDefaultGfycatAPIKey)
|
2018-06-27 13:35:15 -06:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.GfycatAPISecret == nil || *s.GfycatAPISecret == "" {
|
|
|
|
|
s.GfycatAPISecret = NewString(ServiceSettingsDefaultGfycatAPISecret)
|
2018-06-27 13:35:15 -06:00
|
|
|
}
|
|
|
|
|
|
2017-11-28 11:46:48 -08:00
|
|
|
if s.ExperimentalEnableAuthenticationTransfer == nil {
|
|
|
|
|
s.ExperimentalEnableAuthenticationTransfer = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PostEditTimeLimit == nil {
|
2018-02-09 16:31:01 +01:00
|
|
|
s.PostEditTimeLimit = NewInt(-1)
|
2017-04-25 18:37:57 +02:00
|
|
|
}
|
2017-11-21 14:30:08 -08:00
|
|
|
|
|
|
|
|
if s.EnablePreviewFeatures == nil {
|
|
|
|
|
s.EnablePreviewFeatures = NewBool(true)
|
|
|
|
|
}
|
2018-01-10 14:04:04 -08:00
|
|
|
|
|
|
|
|
if s.ExperimentalEnableDefaultChannelLeaveJoinMessages == nil {
|
|
|
|
|
s.ExperimentalEnableDefaultChannelLeaveJoinMessages = NewBool(true)
|
|
|
|
|
}
|
2018-01-22 15:32:50 -06:00
|
|
|
|
2018-01-23 17:59:41 -03:00
|
|
|
if s.ExperimentalGroupUnreadChannels == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ExperimentalGroupUnreadChannels = NewString(GroupUnreadChannelsDisabled)
|
2018-02-06 18:45:14 -05:00
|
|
|
} else if *s.ExperimentalGroupUnreadChannels == "0" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ExperimentalGroupUnreadChannels = NewString(GroupUnreadChannelsDisabled)
|
2018-02-06 18:45:14 -05:00
|
|
|
} else if *s.ExperimentalGroupUnreadChannels == "1" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ExperimentalGroupUnreadChannels = NewString(GroupUnreadChannelsDefaultOn)
|
2018-01-23 17:59:41 -03:00
|
|
|
}
|
|
|
|
|
|
2018-05-18 09:13:23 -04:00
|
|
|
if s.EnableAPITeamDeletion == nil {
|
|
|
|
|
s.EnableAPITeamDeletion = NewBool(false)
|
|
|
|
|
}
|
2018-06-04 09:48:26 -07:00
|
|
|
|
2020-07-22 12:02:23 +00:00
|
|
|
if s.EnableAPIUserDeletion == nil {
|
|
|
|
|
s.EnableAPIUserDeletion = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-14 08:42:39 +00:00
|
|
|
if s.EnableAPIChannelDeletion == nil {
|
|
|
|
|
s.EnableAPIChannelDeletion = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-04 09:48:26 -07:00
|
|
|
if s.ExperimentalEnableHardenedMode == nil {
|
|
|
|
|
s.ExperimentalEnableHardenedMode = NewBool(false)
|
|
|
|
|
}
|
2019-01-10 15:17:31 -05:00
|
|
|
|
2019-01-31 20:39:02 +01:00
|
|
|
if s.ExperimentalStrictCSRFEnforcement == nil {
|
|
|
|
|
s.ExperimentalStrictCSRFEnforcement = NewBool(false)
|
|
|
|
|
}
|
MM-12393 Server side of bot accounts. (#10378)
* bots model, store and api (#9903)
* bots model, store and api
Fixes: MM-13100, MM-13101, MM-13103, MM-13105, MMM-13119
* uncomment tests incorrectly commented, and fix merge issues
* add etags support
* add missing licenses
* remove unused sqlbuilder.go (for now...)
* rejig permissions
* split out READ_BOTS into READ_BOTS and READ_OTHERS_BOTS, the latter
implicitly allowing the former
* make MANAGE_OTHERS_BOTS imply MANAGE_BOTS
* conform to general rest api pattern
* eliminate redundant http.StatusOK
* Update api4/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* s/model.UserFromBotModel/model.UserFromBot/g
* Update model/bot.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* Update model/client4.go
Co-Authored-By: lieut-data <jesse.hallam@gmail.com>
* move sessionHasPermissionToManageBot to app/authorization.go
* use api.ApiSessionRequired for createBot
* introduce BOT_DESCRIPTION_MAX_RUNES constant
* MM-13512 Prevent getting a user by email based on privacy settings (#10021)
* MM-13512 Prevent getting a user by email based on privacy settings
* Add additional config settings to tests
* upgrade db to 5.7 (#10019)
* MM-13526 Add validation when setting a user's Locale field (#10022)
* Fix typos (#10024)
* Fixing first user being created with system admin privilages without being explicity specified. (#10014)
* Revert "Support for Embeded chat (#9129)" (#10017)
This reverts commit 3fcecd521a5c6ccfdb52fb4c3fb1f8c6ea528a4e.
* s/DisableBot/UpdateBotActive
* add permissions on upgrade
* Update NOTICE.txt (#10054)
- add new dependency (text)
- handle switch to forked dependency (go-gomail -> go-mail)
- misc copyright owner updates
* avoid leaking bot knowledge without permission
* [GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)
* 6798 added a new api to get the bulk reactions for posts
* 6798 added the permsission check before getting the reactions
* GH-6798 added a new app function for the new endpoint
* 6798 added a store method to get reactions for multiple posts
* 6798 connected the app function with the new store function
* 6798 fixed the review comments
* MM-13559 Update model.post.is_valid.file_ids.app_error text per report (#10055)
Ticket: https://mattermost.atlassian.net/browse/MM-13559
Report: https://github.com/mattermost/mattermost-server/issues/10023
* Trigger Login Hooks with OAuth (#10061)
* make BotStore.GetAll deterministic even on duplicate CreateAt
* fix spurious TestMuteCommandSpecificChannel test failure
See
https://community-daily.mattermost.com/core/pl/px9p8s3dzbg1pf3ddrm5cr36uw
* fix race in TestExportUserChannels
* TestExportUserChannels: remove SaveMember call, as it is redundant and used to be silently failing anyway
* MM-13117: bot tokens (#10111)
* eliminate redundant Client/AdminClient declarations
* harden TestUpdateChannelScheme to API failures
* eliminate unnecessary config restoration
* minor cleanup
* make TestGenerateMfaSecret config dependency explicit
* TestCreateUserAccessToken for bots
* TestGetUserAccessToken* for bots
* leverage SessionHasPermissionToUserOrBot for user token APIs
* Test(Revoke|Disable|Enable)UserAccessToken
* make EnableUserAccessTokens explicit, so as to not rely on local config.json
* uncomment TestResetPassword, but still skip
* mark assert(Invalid)Token as helper
* fix whitespace issues
* fix mangled comments
* MM-13116: bot plugin api (#10113)
* MM-13117: expose bot API to plugins
This also changes the `CreatorId` column definition to allow for plugin
ids, as the default unless the plugin overrides is to use the plugin id
here. This branch hasn't hit master yet, so no migration needed.
* gofmt issues
* expunge use of BotList in plugin/client API
* introduce model.BotGetOptions
* use botUserId term for clarity
* MM-13129 Adding functionality to deal with orphaned bots (#10238)
* Add way to list orphaned bots.
* Add /assign route to modify ownership of bot accounts.
* Apply suggestions from code review
Co-Authored-By: crspeller <crspeller@gmail.com>
* MM-13120: add IsBot field to returned user objects (#10103)
* MM-13104: forbid bot login (#10251)
* MM-13104: disallow bot login
* fix shadowing
* MM-13136 Disable user bots when user is disabled. (#10293)
* Disable user bots when user is disabled.
* Grammer.
Co-Authored-By: crspeller <crspeller@gmail.com>
* Fixing bot branch for test changes.
* Don't use external dependancies in bot plugin tests.
* Rename bot CreatorId to OwnerId
* Adding ability to re-enable bots
* Fixing IsBot to not attempt to be saved to DB.
* Adding diagnostics and licencing counting for bot accounts.
* Modifying gorp to allow reading of '-' fields.
* Removing unnessisary nil values from UserCountOptions.
* Changing comment to GoDoc format
* Improving user count SQL
* Some improvments from feedback.
* Omit empty on User.IsBot
2019-03-05 07:06:45 -08:00
|
|
|
|
|
|
|
|
if s.DisableBotsWhenOwnerIsDeactivated == nil {
|
|
|
|
|
s.DisableBotsWhenOwnerIsDeactivated = NewBool(true)
|
|
|
|
|
}
|
2019-05-13 10:48:32 -04:00
|
|
|
|
2019-05-23 16:03:22 -04:00
|
|
|
if s.EnableBotAccountCreation == nil {
|
|
|
|
|
s.EnableBotAccountCreation = NewBool(false)
|
2019-05-13 10:48:32 -04:00
|
|
|
}
|
2019-08-14 13:40:40 -04:00
|
|
|
|
|
|
|
|
if s.EnableSVGs == nil {
|
|
|
|
|
if isUpdate {
|
|
|
|
|
s.EnableSVGs = NewBool(true)
|
|
|
|
|
} else {
|
|
|
|
|
s.EnableSVGs = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-25 19:58:48 +02:00
|
|
|
|
|
|
|
|
if s.EnableLatex == nil {
|
|
|
|
|
if isUpdate {
|
|
|
|
|
s.EnableLatex = NewBool(true)
|
|
|
|
|
} else {
|
|
|
|
|
s.EnableLatex = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-19 18:20:41 +02:00
|
|
|
|
2021-08-30 17:52:33 +02:00
|
|
|
if s.EnableInlineLatex == nil {
|
|
|
|
|
s.EnableInlineLatex = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-19 18:20:41 +02:00
|
|
|
if s.EnableLocalMode == nil {
|
|
|
|
|
s.EnableLocalMode = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.LocalModeSocketLocation == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.LocalModeSocketLocation = NewString(LocalModeSocketPath)
|
2020-05-19 18:20:41 +02:00
|
|
|
}
|
2020-09-28 11:43:08 -07:00
|
|
|
|
|
|
|
|
if s.EnableAWSMetering == nil {
|
|
|
|
|
s.EnableAWSMetering = NewBool(false)
|
|
|
|
|
}
|
2020-10-15 18:01:16 +03:00
|
|
|
|
2020-10-29 15:54:39 -07:00
|
|
|
if s.SplitKey == nil {
|
|
|
|
|
s.SplitKey = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FeatureFlagSyncIntervalSeconds == nil {
|
|
|
|
|
s.FeatureFlagSyncIntervalSeconds = NewInt(30)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.DebugSplit == nil {
|
|
|
|
|
s.DebugSplit = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-15 18:01:16 +03:00
|
|
|
if s.ThreadAutoFollow == nil {
|
2022-02-01 16:21:04 +05:30
|
|
|
s.ThreadAutoFollow = NewBool(false)
|
2020-10-15 18:01:16 +03:00
|
|
|
}
|
2020-11-05 11:07:03 -05:00
|
|
|
|
2020-11-20 11:00:52 +02:00
|
|
|
if s.CollapsedThreads == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.CollapsedThreads = NewString(CollapsedThreadsDisabled)
|
2020-11-20 11:00:52 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-05 11:07:03 -05:00
|
|
|
if s.ManagedResourcePaths == nil {
|
|
|
|
|
s.ManagedResourcePaths = NewString("")
|
|
|
|
|
}
|
2022-02-17 12:34:39 -05:00
|
|
|
|
|
|
|
|
if s.EnableCustomGroups == nil {
|
|
|
|
|
s.EnableCustomGroups = NewBool(true)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ClusterSettings struct {
|
2021-09-14 13:22:59 -04:00
|
|
|
Enable *bool `access:"environment_high_availability,write_restrictable"`
|
|
|
|
|
ClusterName *string `access:"environment_high_availability,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
OverrideHostname *string `access:"environment_high_availability,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
NetworkInterface *string `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
|
|
|
|
BindAddress *string `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AdvertiseAddress *string `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
|
|
|
|
UseIPAddress *bool `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableGossipCompression *bool `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableExperimentalGossipEncryption *bool `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ReadOnlyConfig *bool `access:"environment_high_availability,write_restrictable,cloud_restrictable"`
|
|
|
|
|
GossipPort *int `access:"environment_high_availability,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
StreamingPort *int `access:"environment_high_availability,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
MaxIdleConns *int `access:"environment_high_availability,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
MaxIdleConnsPerHost *int `access:"environment_high_availability,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
IdleConnTimeoutMilliseconds *int `access:"environment_high_availability,write_restrictable,cloud_restrictable"` // telemetry: none
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-04-25 18:37:57 +02:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *ClusterSettings) SetDefaults() {
|
|
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
2015-12-09 15:42:48 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.ClusterName == nil {
|
|
|
|
|
s.ClusterName = NewString("")
|
2016-08-02 16:37:09 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.OverrideHostname == nil {
|
|
|
|
|
s.OverrideHostname = NewString("")
|
2017-08-31 01:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
2019-06-11 20:53:03 +02:00
|
|
|
if s.NetworkInterface == nil {
|
|
|
|
|
s.NetworkInterface = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-26 09:40:19 +02:00
|
|
|
if s.BindAddress == nil {
|
|
|
|
|
s.BindAddress = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AdvertiseAddress == nil {
|
|
|
|
|
s.AdvertiseAddress = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-19 10:33:29 +02:00
|
|
|
if s.UseIPAddress == nil {
|
|
|
|
|
s.UseIPAddress = NewBool(true)
|
2017-03-31 06:54:30 -07:00
|
|
|
}
|
|
|
|
|
|
2020-06-03 14:16:15 +05:30
|
|
|
if s.EnableExperimentalGossipEncryption == nil {
|
|
|
|
|
s.EnableExperimentalGossipEncryption = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-28 11:41:03 +05:30
|
|
|
if s.EnableGossipCompression == nil {
|
|
|
|
|
s.EnableGossipCompression = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.ReadOnlyConfig == nil {
|
|
|
|
|
s.ReadOnlyConfig = NewBool(true)
|
2017-03-06 21:13:12 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.GossipPort == nil {
|
|
|
|
|
s.GossipPort = NewInt(8074)
|
2015-12-14 11:34:16 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.StreamingPort == nil {
|
|
|
|
|
s.StreamingPort = NewInt(8075)
|
2015-10-09 12:24:39 -07:00
|
|
|
}
|
2018-05-23 13:17:08 -04:00
|
|
|
|
|
|
|
|
if s.MaxIdleConns == nil {
|
|
|
|
|
s.MaxIdleConns = NewInt(100)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.MaxIdleConnsPerHost == nil {
|
|
|
|
|
s.MaxIdleConnsPerHost = NewInt(128)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.IdleConnTimeoutMilliseconds == nil {
|
|
|
|
|
s.IdleConnTimeoutMilliseconds = NewInt(90000)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type MetricsSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"`
|
|
|
|
|
BlockProfileRate *int `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ListenAddress *string `access:"environment_performance_monitoring,write_restrictable,cloud_restrictable"` // telemetry: none
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2015-10-20 17:30:24 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *MetricsSettings) SetDefaults() {
|
|
|
|
|
if s.ListenAddress == nil {
|
|
|
|
|
s.ListenAddress = NewString(":8067")
|
2016-02-05 12:40:32 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
2017-08-09 15:49:07 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.BlockProfileRate == nil {
|
|
|
|
|
s.BlockProfileRate = NewInt(0)
|
2016-03-30 12:49:29 -04:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
2018-06-12 10:16:39 -07:00
|
|
|
type ExperimentalSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
ClientSideCertEnable *bool `access:"experimental_features,cloud_restrictable"`
|
|
|
|
|
ClientSideCertCheck *string `access:"experimental_features,cloud_restrictable"`
|
|
|
|
|
EnableClickToReply *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
LinkMetadataTimeoutMilliseconds *int64 `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
RestrictSystemAdmin *bool `access:"experimental_features,write_restrictable"`
|
|
|
|
|
UseNewSAMLLibrary *bool `access:"experimental_features,cloud_restrictable"`
|
|
|
|
|
CloudUserLimit *int64 `access:"experimental_features,write_restrictable"`
|
|
|
|
|
CloudBilling *bool `access:"experimental_features,write_restrictable"`
|
|
|
|
|
EnableSharedChannels *bool `access:"experimental_features"`
|
|
|
|
|
EnableRemoteClusterService *bool `access:"experimental_features"`
|
2018-06-12 10:16:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ExperimentalSettings) SetDefaults() {
|
|
|
|
|
if s.ClientSideCertEnable == nil {
|
|
|
|
|
s.ClientSideCertEnable = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ClientSideCertCheck == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ClientSideCertCheck = NewString(ClientSideCertCheckSecondaryAuth)
|
2018-06-12 10:16:39 -07:00
|
|
|
}
|
2018-11-23 11:59:34 -05:00
|
|
|
|
2019-03-13 17:45:48 -07:00
|
|
|
if s.EnableClickToReply == nil {
|
|
|
|
|
s.EnableClickToReply = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 09:40:23 -05:00
|
|
|
if s.LinkMetadataTimeoutMilliseconds == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.LinkMetadataTimeoutMilliseconds = NewInt64(ExperimentalSettingsDefaultLinkMetadataTimeoutMilliseconds)
|
2019-01-31 09:40:23 -05:00
|
|
|
}
|
2019-03-08 13:15:28 -05:00
|
|
|
|
|
|
|
|
if s.RestrictSystemAdmin == nil {
|
|
|
|
|
s.RestrictSystemAdmin = NewBool(false)
|
|
|
|
|
}
|
2020-08-19 16:01:07 -04:00
|
|
|
|
|
|
|
|
if s.CloudUserLimit == nil {
|
|
|
|
|
// User limit 0 is treated as no limit
|
|
|
|
|
s.CloudUserLimit = NewInt64(0)
|
|
|
|
|
}
|
2020-09-03 10:10:59 -04:00
|
|
|
|
|
|
|
|
if s.CloudBilling == nil {
|
|
|
|
|
s.CloudBilling = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-18 15:35:53 -07:00
|
|
|
if s.UseNewSAMLLibrary == nil {
|
|
|
|
|
s.UseNewSAMLLibrary = NewBool(false)
|
|
|
|
|
}
|
2020-10-01 10:37:15 +05:30
|
|
|
|
|
|
|
|
if s.EnableSharedChannels == nil {
|
|
|
|
|
s.EnableSharedChannels = NewBool(false)
|
|
|
|
|
}
|
2021-04-01 13:44:56 -04:00
|
|
|
|
|
|
|
|
if s.EnableRemoteClusterService == nil {
|
|
|
|
|
s.EnableRemoteClusterService = NewBool(false)
|
|
|
|
|
}
|
2018-06-12 10:16:39 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type AnalyticsSettings struct {
|
2020-09-30 21:09:56 +02:00
|
|
|
MaxUsersForStatistics *int `access:"write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-03-30 12:49:29 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *AnalyticsSettings) SetDefaults() {
|
|
|
|
|
if s.MaxUsersForStatistics == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.MaxUsersForStatistics = NewInt(AnalyticsSettingsDefaultMaxUsersForStatistics)
|
2016-12-12 08:16:10 -05:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type SSOSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"authentication_openid"`
|
|
|
|
|
Secret *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
Id *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
Scope *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
AuthEndpoint *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
TokenEndpoint *string `access:"authentication_openid"` // telemetry: none
|
2021-08-16 19:46:44 +02:00
|
|
|
UserAPIEndpoint *string `access:"authentication_openid"` // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
DiscoveryEndpoint *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
ButtonText *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
ButtonColor *string `access:"authentication_openid"` // telemetry: none
|
2020-12-08 19:58:37 -07:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
func (s *SSOSettings) setDefaults(scope, authEndpoint, tokenEndpoint, userAPIEndpoint, buttonColor string) {
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Secret == nil {
|
|
|
|
|
s.Secret = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Id == nil {
|
|
|
|
|
s.Id = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Scope == nil {
|
2019-06-06 20:57:01 +03:00
|
|
|
s.Scope = NewString(scope)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
2020-12-08 19:58:37 -07:00
|
|
|
if s.DiscoveryEndpoint == nil {
|
|
|
|
|
s.DiscoveryEndpoint = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.AuthEndpoint == nil {
|
2019-06-06 20:57:01 +03:00
|
|
|
s.AuthEndpoint = NewString(authEndpoint)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.TokenEndpoint == nil {
|
2019-06-06 20:57:01 +03:00
|
|
|
s.TokenEndpoint = NewString(tokenEndpoint)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.UserAPIEndpoint == nil {
|
|
|
|
|
s.UserAPIEndpoint = NewString(userAPIEndpoint)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
2020-12-08 19:58:37 -07:00
|
|
|
|
|
|
|
|
if s.ButtonText == nil {
|
|
|
|
|
s.ButtonText = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ButtonColor == nil {
|
|
|
|
|
s.ButtonColor = NewString(buttonColor)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
2020-02-14 09:55:40 -08:00
|
|
|
type Office365Settings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"authentication_openid"`
|
|
|
|
|
Secret *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
Id *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
Scope *string `access:"authentication_openid"`
|
|
|
|
|
AuthEndpoint *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
TokenEndpoint *string `access:"authentication_openid"` // telemetry: none
|
2021-08-16 19:46:44 +02:00
|
|
|
UserAPIEndpoint *string `access:"authentication_openid"` // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
DiscoveryEndpoint *string `access:"authentication_openid"` // telemetry: none
|
|
|
|
|
DirectoryId *string `access:"authentication_openid"` // telemetry: none
|
2020-02-14 09:55:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Office365Settings) setDefaults() {
|
|
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Id == nil {
|
|
|
|
|
s.Id = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Secret == nil {
|
|
|
|
|
s.Secret = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.Scope == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.Scope = NewString(Office365SettingsDefaultScope)
|
2020-02-14 09:55:40 -08:00
|
|
|
}
|
|
|
|
|
|
2020-12-08 19:58:37 -07:00
|
|
|
if s.DiscoveryEndpoint == nil {
|
|
|
|
|
s.DiscoveryEndpoint = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-14 09:55:40 -08:00
|
|
|
if s.AuthEndpoint == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.AuthEndpoint = NewString(Office365SettingsDefaultAuthEndpoint)
|
2020-02-14 09:55:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.TokenEndpoint == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.TokenEndpoint = NewString(Office365SettingsDefaultTokenEndpoint)
|
2020-02-14 09:55:40 -08:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.UserAPIEndpoint == nil {
|
|
|
|
|
s.UserAPIEndpoint = NewString(Office365SettingsDefaultUserAPIEndpoint)
|
2020-02-14 09:55:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.DirectoryId == nil {
|
|
|
|
|
s.DirectoryId = NewString("")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Office365Settings) SSOSettings() *SSOSettings {
|
|
|
|
|
ssoSettings := SSOSettings{}
|
|
|
|
|
ssoSettings.Enable = s.Enable
|
|
|
|
|
ssoSettings.Secret = s.Secret
|
|
|
|
|
ssoSettings.Id = s.Id
|
|
|
|
|
ssoSettings.Scope = s.Scope
|
2020-12-08 19:58:37 -07:00
|
|
|
ssoSettings.DiscoveryEndpoint = s.DiscoveryEndpoint
|
2020-02-14 09:55:40 -08:00
|
|
|
ssoSettings.AuthEndpoint = s.AuthEndpoint
|
|
|
|
|
ssoSettings.TokenEndpoint = s.TokenEndpoint
|
2021-08-16 19:46:44 +02:00
|
|
|
ssoSettings.UserAPIEndpoint = s.UserAPIEndpoint
|
2020-02-14 09:55:40 -08:00
|
|
|
return &ssoSettings
|
|
|
|
|
}
|
|
|
|
|
|
MM-33818: Add replica lag metric (#17148)
* MM-33818: Add replica lag metric
We add two new metrics for monitoring replica lag:
- Monitor absolute lag based on binlog distance/transaction queue length.
- Monitor time taken for the replica to catch up.
To achieve this, we add a config setting to run a user defined SQL query
on the database.
We need to specify a separate datasource field as part of the config because
in some databases, querying the replica lag value requires elevated credentials
which are not needed for usual running of the application, and can even be a security risk.
Arguably, a peculiar part of the design is the requirement of the query output to be in a (node, value)
format. But since from the application, the SQL query is a black box and the user can set any query
they want, we cannot, in any way templatize this.
And as an extra note, freno also does it in a similar way.
The last bit is because we need to have a separate datasources, now we consume one extra connection
rather than sharing it with the pool. This is an unfortunate result of the design, and while one extra
connection doesn't make much of a difference in a single-tenant scenario. It does make so, in a multi-tenant scenario.
But in a multi-tenant scenario, the expectation would already be to use a connection pool. So this
is not a big concern.
https://mattermost.atlassian.net/browse/MM-33818
```release-note
Two new gauge metrics were added:
mattermost_db_replica_lag_abs and mattermost_db_replica_lag_time, both
containing a label of "node", signifying which db host is the metric from.
These metrics signify the replica lag in absolute terms and in the time dimension
capturing the whole picture of replica lag.
To use these metrics, a separate config section ReplicaLagSettings was added
under SqlSettings. This is an array of maps which contain three keys: DataSource,
QueryAbsoluteLag, and QueryTimeLag. Each map entry is for a single replica instance.
DataSource contains the DB credentials to connect to the replica instance.
QueryAbsoluteLag is a plain SQL query that must return a single row of which the first column
must be the node value of the Prometheus metric, and the second column must be the value of the lag.
QueryTimeLag is the same as above, but used to measure the time lag.
As an example, for AWS Aurora instances, the QueryAbsoluteLag can be:
select server_id, highest_lsn_rcvd-durable_lsn as bindiff from aurora_global_db_instance_status() where server_id=<>
and QueryTimeLag can be:
select server_id, visibility_lag_in_msec from aurora_global_db_instance_status() where server_id=<>
For MySQL Group Replication, the absolute lag can be measured from the number of pending transactions
in the applier queue:
select member_id, count_transaction_remote_in_applier_queue FROM performance_schema.replication_group_member_stats where member_id=<>
Overall, what query to choose is left to the administrator, and depending on the database and need, an appropriate
query can be chosen.
```
* Trigger CI
* Fix tests
* address review comments
* Remove t.Parallel
It was spawning too many connections,
and overloading the docker container.
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-29 21:35:24 +05:30
|
|
|
type ReplicaLagSettings struct {
|
|
|
|
|
DataSource *string `access:"environment,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
QueryAbsoluteLag *string `access:"environment,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
QueryTimeLag *string `access:"environment,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type SqlSettings struct {
|
2022-01-08 11:16:07 +03:00
|
|
|
DriverName *string `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
DataSource *string `access:"environment_database,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
DataSourceReplicas []string `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
DataSourceSearchReplicas []string `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
MaxIdleConns *int `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ConnMaxLifetimeMilliseconds *int `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ConnMaxIdleTimeMilliseconds *int `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
MaxOpenConns *int `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
Trace *bool `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AtRestEncryptKey *string `access:"environment_database,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
QueryTimeout *int `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
DisableDatabaseSearch *bool `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
MigrationsStatementTimeoutSeconds *int `access:"environment_database,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ReplicaLagSettings []*ReplicaLagSettings `access:"environment_database,write_restrictable,cloud_restrictable"` // telemetry: none
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-12-12 08:16:10 -05:00
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
func (s *SqlSettings) SetDefaults(isUpdate bool) {
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.DriverName == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.DriverName = NewString(DatabaseDriverPostgres)
|
2017-07-31 12:59:32 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.DataSource == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.DataSource = NewString(SqlSettingsDefaultDataSource)
|
2016-07-06 18:54:54 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.DataSourceReplicas == nil {
|
|
|
|
|
s.DataSourceReplicas = []string{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.DataSourceSearchReplicas == nil {
|
|
|
|
|
s.DataSourceSearchReplicas = []string{}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
if isUpdate {
|
|
|
|
|
// When updating an existing configuration, ensure an encryption key has been specified.
|
2021-01-25 11:15:17 +01:00
|
|
|
if s.AtRestEncryptKey == nil || *s.AtRestEncryptKey == "" {
|
2019-06-06 20:57:01 +03:00
|
|
|
s.AtRestEncryptKey = NewString(NewRandomString(32))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// When generating a blank configuration, leave this key empty to be generated on server start.
|
|
|
|
|
s.AtRestEncryptKey = NewString("")
|
2016-07-06 18:54:54 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.MaxIdleConns == nil {
|
|
|
|
|
s.MaxIdleConns = NewInt(20)
|
2016-07-06 18:54:54 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.MaxOpenConns == nil {
|
|
|
|
|
s.MaxOpenConns = NewInt(300)
|
2016-07-06 18:54:54 -04:00
|
|
|
}
|
|
|
|
|
|
2018-06-28 09:45:20 -04:00
|
|
|
if s.ConnMaxLifetimeMilliseconds == nil {
|
|
|
|
|
s.ConnMaxLifetimeMilliseconds = NewInt(3600000)
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-28 09:37:15 +05:30
|
|
|
if s.ConnMaxIdleTimeMilliseconds == nil {
|
|
|
|
|
s.ConnMaxIdleTimeMilliseconds = NewInt(300000)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.Trace == nil {
|
|
|
|
|
s.Trace = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.QueryTimeout == nil {
|
|
|
|
|
s.QueryTimeout = NewInt(30)
|
2016-07-06 18:54:54 -04:00
|
|
|
}
|
2020-05-13 14:00:57 +02:00
|
|
|
|
|
|
|
|
if s.DisableDatabaseSearch == nil {
|
|
|
|
|
s.DisableDatabaseSearch = NewBool(false)
|
|
|
|
|
}
|
MM-33818: Add replica lag metric (#17148)
* MM-33818: Add replica lag metric
We add two new metrics for monitoring replica lag:
- Monitor absolute lag based on binlog distance/transaction queue length.
- Monitor time taken for the replica to catch up.
To achieve this, we add a config setting to run a user defined SQL query
on the database.
We need to specify a separate datasource field as part of the config because
in some databases, querying the replica lag value requires elevated credentials
which are not needed for usual running of the application, and can even be a security risk.
Arguably, a peculiar part of the design is the requirement of the query output to be in a (node, value)
format. But since from the application, the SQL query is a black box and the user can set any query
they want, we cannot, in any way templatize this.
And as an extra note, freno also does it in a similar way.
The last bit is because we need to have a separate datasources, now we consume one extra connection
rather than sharing it with the pool. This is an unfortunate result of the design, and while one extra
connection doesn't make much of a difference in a single-tenant scenario. It does make so, in a multi-tenant scenario.
But in a multi-tenant scenario, the expectation would already be to use a connection pool. So this
is not a big concern.
https://mattermost.atlassian.net/browse/MM-33818
```release-note
Two new gauge metrics were added:
mattermost_db_replica_lag_abs and mattermost_db_replica_lag_time, both
containing a label of "node", signifying which db host is the metric from.
These metrics signify the replica lag in absolute terms and in the time dimension
capturing the whole picture of replica lag.
To use these metrics, a separate config section ReplicaLagSettings was added
under SqlSettings. This is an array of maps which contain three keys: DataSource,
QueryAbsoluteLag, and QueryTimeLag. Each map entry is for a single replica instance.
DataSource contains the DB credentials to connect to the replica instance.
QueryAbsoluteLag is a plain SQL query that must return a single row of which the first column
must be the node value of the Prometheus metric, and the second column must be the value of the lag.
QueryTimeLag is the same as above, but used to measure the time lag.
As an example, for AWS Aurora instances, the QueryAbsoluteLag can be:
select server_id, highest_lsn_rcvd-durable_lsn as bindiff from aurora_global_db_instance_status() where server_id=<>
and QueryTimeLag can be:
select server_id, visibility_lag_in_msec from aurora_global_db_instance_status() where server_id=<>
For MySQL Group Replication, the absolute lag can be measured from the number of pending transactions
in the applier queue:
select member_id, count_transaction_remote_in_applier_queue FROM performance_schema.replication_group_member_stats where member_id=<>
Overall, what query to choose is left to the administrator, and depending on the database and need, an appropriate
query can be chosen.
```
* Trigger CI
* Fix tests
* address review comments
* Remove t.Parallel
It was spawning too many connections,
and overloading the docker container.
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-29 21:35:24 +05:30
|
|
|
|
2022-01-08 11:16:07 +03:00
|
|
|
if s.MigrationsStatementTimeoutSeconds == nil {
|
|
|
|
|
s.MigrationsStatementTimeoutSeconds = NewInt(100000)
|
|
|
|
|
}
|
|
|
|
|
|
MM-33818: Add replica lag metric (#17148)
* MM-33818: Add replica lag metric
We add two new metrics for monitoring replica lag:
- Monitor absolute lag based on binlog distance/transaction queue length.
- Monitor time taken for the replica to catch up.
To achieve this, we add a config setting to run a user defined SQL query
on the database.
We need to specify a separate datasource field as part of the config because
in some databases, querying the replica lag value requires elevated credentials
which are not needed for usual running of the application, and can even be a security risk.
Arguably, a peculiar part of the design is the requirement of the query output to be in a (node, value)
format. But since from the application, the SQL query is a black box and the user can set any query
they want, we cannot, in any way templatize this.
And as an extra note, freno also does it in a similar way.
The last bit is because we need to have a separate datasources, now we consume one extra connection
rather than sharing it with the pool. This is an unfortunate result of the design, and while one extra
connection doesn't make much of a difference in a single-tenant scenario. It does make so, in a multi-tenant scenario.
But in a multi-tenant scenario, the expectation would already be to use a connection pool. So this
is not a big concern.
https://mattermost.atlassian.net/browse/MM-33818
```release-note
Two new gauge metrics were added:
mattermost_db_replica_lag_abs and mattermost_db_replica_lag_time, both
containing a label of "node", signifying which db host is the metric from.
These metrics signify the replica lag in absolute terms and in the time dimension
capturing the whole picture of replica lag.
To use these metrics, a separate config section ReplicaLagSettings was added
under SqlSettings. This is an array of maps which contain three keys: DataSource,
QueryAbsoluteLag, and QueryTimeLag. Each map entry is for a single replica instance.
DataSource contains the DB credentials to connect to the replica instance.
QueryAbsoluteLag is a plain SQL query that must return a single row of which the first column
must be the node value of the Prometheus metric, and the second column must be the value of the lag.
QueryTimeLag is the same as above, but used to measure the time lag.
As an example, for AWS Aurora instances, the QueryAbsoluteLag can be:
select server_id, highest_lsn_rcvd-durable_lsn as bindiff from aurora_global_db_instance_status() where server_id=<>
and QueryTimeLag can be:
select server_id, visibility_lag_in_msec from aurora_global_db_instance_status() where server_id=<>
For MySQL Group Replication, the absolute lag can be measured from the number of pending transactions
in the applier queue:
select member_id, count_transaction_remote_in_applier_queue FROM performance_schema.replication_group_member_stats where member_id=<>
Overall, what query to choose is left to the administrator, and depending on the database and need, an appropriate
query can be chosen.
```
* Trigger CI
* Fix tests
* address review comments
* Remove t.Parallel
It was spawning too many connections,
and overloading the docker container.
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-29 21:35:24 +05:30
|
|
|
if s.ReplicaLagSettings == nil {
|
|
|
|
|
s.ReplicaLagSettings = []*ReplicaLagSettings{}
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type LogSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableConsole *bool `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ConsoleLevel *string `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ConsoleJson *bool `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
2021-04-13 23:45:56 +05:30
|
|
|
EnableColor *bool `access:"environment_logging,write_restrictable,cloud_restrictable"` // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableFile *bool `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileLevel *string `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileJson *bool `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileLocation *string `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableWebhookDebugging *bool `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableDiagnostics *bool `access:"environment_logging,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
EnableSentry *bool `access:"environment_logging,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AdvancedLoggingConfig *string `access:"environment_logging,write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-07-06 18:54:54 -04:00
|
|
|
|
2021-08-17 16:08:04 -04:00
|
|
|
func NewLogSettings() *LogSettings {
|
|
|
|
|
settings := &LogSettings{}
|
|
|
|
|
settings.SetDefaults()
|
|
|
|
|
return settings
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *LogSettings) SetDefaults() {
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.EnableConsole == nil {
|
|
|
|
|
s.EnableConsole = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ConsoleLevel == nil {
|
|
|
|
|
s.ConsoleLevel = NewString("DEBUG")
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-13 23:45:56 +05:30
|
|
|
if s.EnableColor == nil {
|
|
|
|
|
s.EnableColor = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.EnableFile == nil {
|
|
|
|
|
s.EnableFile = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileLevel == nil {
|
|
|
|
|
s.FileLevel = NewString("INFO")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileLocation == nil {
|
|
|
|
|
s.FileLocation = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableWebhookDebugging == nil {
|
|
|
|
|
s.EnableWebhookDebugging = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableDiagnostics == nil {
|
|
|
|
|
s.EnableDiagnostics = NewBool(true)
|
2017-08-31 01:54:16 +08:00
|
|
|
}
|
2018-04-27 12:49:45 -07:00
|
|
|
|
2020-05-21 16:13:37 +03:00
|
|
|
if s.EnableSentry == nil {
|
|
|
|
|
s.EnableSentry = NewBool(*s.EnableDiagnostics)
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-27 12:49:45 -07:00
|
|
|
if s.ConsoleJson == nil {
|
|
|
|
|
s.ConsoleJson = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileJson == nil {
|
|
|
|
|
s.FileJson = NewBool(true)
|
|
|
|
|
}
|
2020-07-15 14:40:36 -04:00
|
|
|
|
|
|
|
|
if s.AdvancedLoggingConfig == nil {
|
|
|
|
|
s.AdvancedLoggingConfig = NewString("")
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
2020-03-12 15:50:21 -04:00
|
|
|
type ExperimentalAuditSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
FileEnabled *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileName *string `access:"experimental_features,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
FileMaxSizeMB *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileMaxAgeDays *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileMaxBackups *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileCompress *bool `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileMaxQueueSize *int `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AdvancedLoggingConfig *string `access:"experimental_features,write_restrictable,cloud_restrictable"`
|
2020-03-12 15:50:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ExperimentalAuditSettings) SetDefaults() {
|
2020-03-17 16:12:56 -04:00
|
|
|
if s.FileEnabled == nil {
|
|
|
|
|
s.FileEnabled = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileName == nil {
|
|
|
|
|
s.FileName = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileMaxSizeMB == nil {
|
|
|
|
|
s.FileMaxSizeMB = NewInt(100)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileMaxAgeDays == nil {
|
|
|
|
|
s.FileMaxAgeDays = NewInt(0) // no limit on age
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileMaxBackups == nil { // no limit on number of backups
|
|
|
|
|
s.FileMaxBackups = NewInt(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileCompress == nil {
|
|
|
|
|
s.FileCompress = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileMaxQueueSize == nil {
|
|
|
|
|
s.FileMaxQueueSize = NewInt(1000)
|
2020-03-12 15:50:21 -04:00
|
|
|
}
|
2020-07-22 18:48:46 -04:00
|
|
|
|
|
|
|
|
if s.AdvancedLoggingConfig == nil {
|
|
|
|
|
s.AdvancedLoggingConfig = NewString("")
|
|
|
|
|
}
|
2020-03-12 15:50:21 -04:00
|
|
|
}
|
|
|
|
|
|
2019-05-13 10:53:46 -04:00
|
|
|
type NotificationLogSettings struct {
|
2020-09-30 21:09:56 +02:00
|
|
|
EnableConsole *bool `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
ConsoleLevel *string `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
ConsoleJson *bool `access:"write_restrictable,cloud_restrictable"`
|
2021-04-13 23:45:56 +05:30
|
|
|
EnableColor *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
2020-09-30 21:09:56 +02:00
|
|
|
EnableFile *bool `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileLevel *string `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileJson *bool `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
FileLocation *string `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
AdvancedLoggingConfig *string `access:"write_restrictable,cloud_restrictable"`
|
2019-05-13 10:53:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *NotificationLogSettings) SetDefaults() {
|
|
|
|
|
if s.EnableConsole == nil {
|
|
|
|
|
s.EnableConsole = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ConsoleLevel == nil {
|
|
|
|
|
s.ConsoleLevel = NewString("DEBUG")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableFile == nil {
|
|
|
|
|
s.EnableFile = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileLevel == nil {
|
|
|
|
|
s.FileLevel = NewString("INFO")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FileLocation == nil {
|
|
|
|
|
s.FileLocation = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ConsoleJson == nil {
|
|
|
|
|
s.ConsoleJson = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-13 23:45:56 +05:30
|
|
|
if s.EnableColor == nil {
|
|
|
|
|
s.EnableColor = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-13 10:53:46 -04:00
|
|
|
if s.FileJson == nil {
|
|
|
|
|
s.FileJson = NewBool(true)
|
|
|
|
|
}
|
2020-07-22 18:48:46 -04:00
|
|
|
|
|
|
|
|
if s.AdvancedLoggingConfig == nil {
|
|
|
|
|
s.AdvancedLoggingConfig = NewString("")
|
|
|
|
|
}
|
2019-05-13 10:53:46 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type PasswordSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
MinimumLength *int `access:"authentication_password"`
|
|
|
|
|
Lowercase *bool `access:"authentication_password"`
|
|
|
|
|
Number *bool `access:"authentication_password"`
|
|
|
|
|
Uppercase *bool `access:"authentication_password"`
|
|
|
|
|
Symbol *bool `access:"authentication_password"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-08-31 01:54:16 +08:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *PasswordSettings) SetDefaults() {
|
|
|
|
|
if s.MinimumLength == nil {
|
2019-05-21 20:03:36 +02:00
|
|
|
s.MinimumLength = NewInt(10)
|
2016-04-11 13:45:03 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Lowercase == nil {
|
2019-05-21 20:03:36 +02:00
|
|
|
s.Lowercase = NewBool(true)
|
2016-04-11 13:45:03 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Number == nil {
|
2019-05-21 20:03:36 +02:00
|
|
|
s.Number = NewBool(true)
|
2016-08-02 08:34:34 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Uppercase == nil {
|
2019-05-21 20:03:36 +02:00
|
|
|
s.Uppercase = NewBool(true)
|
2016-04-21 22:37:01 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Symbol == nil {
|
2019-05-21 20:03:36 +02:00
|
|
|
s.Symbol = NewBool(true)
|
2016-05-04 06:31:42 -07:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type FileSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableFileAttachments *bool `access:"site_file_sharing_and_downloads,cloud_restrictable"`
|
|
|
|
|
EnableMobileUpload *bool `access:"site_file_sharing_and_downloads,cloud_restrictable"`
|
|
|
|
|
EnableMobileDownload *bool `access:"site_file_sharing_and_downloads,cloud_restrictable"`
|
|
|
|
|
MaxFileSize *int64 `access:"environment_file_storage,cloud_restrictable"`
|
2021-08-12 17:43:10 +02:00
|
|
|
MaxImageResolution *int64 `access:"environment_file_storage,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
DriverName *string `access:"environment_file_storage,write_restrictable,cloud_restrictable"`
|
|
|
|
|
Directory *string `access:"environment_file_storage,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnablePublicLink *bool `access:"site_public_links,cloud_restrictable"`
|
|
|
|
|
ExtractContent *bool `access:"environment_file_storage,write_restrictable"`
|
|
|
|
|
ArchiveRecursion *bool `access:"environment_file_storage,write_restrictable"`
|
|
|
|
|
PublicLinkSalt *string `access:"site_public_links,cloud_restrictable"` // telemetry: none
|
|
|
|
|
InitialFont *string `access:"environment_file_storage,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AmazonS3AccessKeyId *string `access:"environment_file_storage,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AmazonS3SecretAccessKey *string `access:"environment_file_storage,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AmazonS3Bucket *string `access:"environment_file_storage,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AmazonS3PathPrefix *string `access:"environment_file_storage,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AmazonS3Region *string `access:"environment_file_storage,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AmazonS3Endpoint *string `access:"environment_file_storage,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AmazonS3SSL *bool `access:"environment_file_storage,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AmazonS3SignV2 *bool `access:"environment_file_storage,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AmazonS3SSE *bool `access:"environment_file_storage,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AmazonS3Trace *bool `access:"environment_file_storage,write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-05-04 06:31:42 -07:00
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
func (s *FileSettings) SetDefaults(isUpdate bool) {
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.EnableFileAttachments == nil {
|
|
|
|
|
s.EnableFileAttachments = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableMobileUpload == nil {
|
|
|
|
|
s.EnableMobileUpload = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableMobileDownload == nil {
|
|
|
|
|
s.EnableMobileDownload = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.MaxFileSize == nil {
|
2021-08-12 17:43:10 +02:00
|
|
|
s.MaxFileSize = NewInt64(100 * 1024 * 1024) // 100MB (IEC)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.MaxImageResolution == nil {
|
|
|
|
|
s.MaxImageResolution = NewInt64(7680 * 4320) // 8K, ~33MPX
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.DriverName == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.DriverName = NewString(ImageDriverLocal)
|
2016-07-06 08:23:24 -04:00
|
|
|
}
|
|
|
|
|
|
2020-08-04 13:58:48 +02:00
|
|
|
if s.Directory == nil || *s.Directory == "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.Directory = NewString(FileSettingsDefaultDirectory)
|
2016-07-06 08:23:24 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.EnablePublicLink == nil {
|
|
|
|
|
s.EnablePublicLink = NewBool(false)
|
2016-06-29 14:16:17 -04:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 07:41:05 +01:00
|
|
|
if s.ExtractContent == nil {
|
2021-04-07 13:27:20 +02:00
|
|
|
s.ExtractContent = NewBool(true)
|
2021-02-26 07:41:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ArchiveRecursion == nil {
|
|
|
|
|
s.ArchiveRecursion = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
if isUpdate {
|
|
|
|
|
// When updating an existing configuration, ensure link salt has been specified.
|
2021-01-25 11:15:17 +01:00
|
|
|
if s.PublicLinkSalt == nil || *s.PublicLinkSalt == "" {
|
2019-06-06 20:57:01 +03:00
|
|
|
s.PublicLinkSalt = NewString(NewRandomString(32))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// When generating a blank configuration, leave link salt empty to be generated on server start.
|
|
|
|
|
s.PublicLinkSalt = NewString("")
|
2016-12-21 19:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.InitialFont == nil {
|
|
|
|
|
// Defaults to "nunito-bold.ttf"
|
|
|
|
|
s.InitialFont = NewString("nunito-bold.ttf")
|
2016-12-21 19:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.AmazonS3AccessKeyId == nil {
|
|
|
|
|
s.AmazonS3AccessKeyId = NewString("")
|
2016-12-21 19:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.AmazonS3SecretAccessKey == nil {
|
|
|
|
|
s.AmazonS3SecretAccessKey = NewString("")
|
2016-12-21 19:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.AmazonS3Bucket == nil {
|
|
|
|
|
s.AmazonS3Bucket = NewString("")
|
2017-04-03 18:13:28 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-07 00:20:13 +02:00
|
|
|
if s.AmazonS3PathPrefix == nil {
|
|
|
|
|
s.AmazonS3PathPrefix = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.AmazonS3Region == nil {
|
|
|
|
|
s.AmazonS3Region = NewString("")
|
2017-09-01 13:21:09 -05:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if s.AmazonS3Endpoint == nil || *s.AmazonS3Endpoint == "" {
|
2019-01-31 08:12:01 -05:00
|
|
|
// Defaults to "s3.amazonaws.com"
|
|
|
|
|
s.AmazonS3Endpoint = NewString("s3.amazonaws.com")
|
2016-07-18 11:10:03 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.AmazonS3SSL == nil {
|
|
|
|
|
s.AmazonS3SSL = NewBool(true) // Secure by default.
|
2016-10-21 20:36:13 +08:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.AmazonS3SignV2 == nil {
|
|
|
|
|
s.AmazonS3SignV2 = new(bool)
|
|
|
|
|
// Signature v2 is not enabled by default.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AmazonS3SSE == nil {
|
|
|
|
|
s.AmazonS3SSE = NewBool(false) // Not Encrypted by default.
|
2016-11-24 05:26:45 -08:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.AmazonS3Trace == nil {
|
|
|
|
|
s.AmazonS3Trace = NewBool(false)
|
2017-09-20 17:38:27 +02:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
2021-03-02 14:37:21 +01:00
|
|
|
func (s *FileSettings) ToFileBackendSettings(enableComplianceFeature bool) filestore.FileBackendSettings {
|
2021-07-12 20:05:36 +02:00
|
|
|
if *s.DriverName == ImageDriverLocal {
|
2021-03-02 14:37:21 +01:00
|
|
|
return filestore.FileBackendSettings{
|
2021-02-15 10:09:28 +01:00
|
|
|
DriverName: *s.DriverName,
|
|
|
|
|
Directory: *s.Directory,
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-02 14:37:21 +01:00
|
|
|
return filestore.FileBackendSettings{
|
2021-02-15 10:09:28 +01:00
|
|
|
DriverName: *s.DriverName,
|
|
|
|
|
AmazonS3AccessKeyId: *s.AmazonS3AccessKeyId,
|
|
|
|
|
AmazonS3SecretAccessKey: *s.AmazonS3SecretAccessKey,
|
|
|
|
|
AmazonS3Bucket: *s.AmazonS3Bucket,
|
|
|
|
|
AmazonS3PathPrefix: *s.AmazonS3PathPrefix,
|
|
|
|
|
AmazonS3Region: *s.AmazonS3Region,
|
|
|
|
|
AmazonS3Endpoint: *s.AmazonS3Endpoint,
|
|
|
|
|
AmazonS3SSL: s.AmazonS3SSL == nil || *s.AmazonS3SSL,
|
|
|
|
|
AmazonS3SignV2: s.AmazonS3SignV2 != nil && *s.AmazonS3SignV2,
|
|
|
|
|
AmazonS3SSE: s.AmazonS3SSE != nil && *s.AmazonS3SSE && enableComplianceFeature,
|
|
|
|
|
AmazonS3Trace: s.AmazonS3Trace != nil && *s.AmazonS3Trace,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type EmailSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableSignUpWithEmail *bool `access:"authentication_email"`
|
|
|
|
|
EnableSignInWithEmail *bool `access:"authentication_email"`
|
|
|
|
|
EnableSignInWithUsername *bool `access:"authentication_email"`
|
|
|
|
|
SendEmailNotifications *bool `access:"site_notifications"`
|
|
|
|
|
UseChannelInEmailNotifications *bool `access:"experimental_features"`
|
|
|
|
|
RequireEmailVerification *bool `access:"authentication_email"`
|
|
|
|
|
FeedbackName *string `access:"site_notifications"`
|
|
|
|
|
FeedbackEmail *string `access:"site_notifications,cloud_restrictable"`
|
|
|
|
|
ReplyToAddress *string `access:"site_notifications,cloud_restrictable"`
|
|
|
|
|
FeedbackOrganization *string `access:"site_notifications"`
|
|
|
|
|
EnableSMTPAuth *bool `access:"environment_smtp,write_restrictable,cloud_restrictable"`
|
|
|
|
|
SMTPUsername *string `access:"environment_smtp,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
SMTPPassword *string `access:"environment_smtp,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
SMTPServer *string `access:"environment_smtp,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
SMTPPort *string `access:"environment_smtp,write_restrictable,cloud_restrictable"` // telemetry: none
|
2020-09-30 21:09:56 +02:00
|
|
|
SMTPServerTimeout *int `access:"cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
ConnectionSecurity *string `access:"environment_smtp,write_restrictable,cloud_restrictable"`
|
|
|
|
|
SendPushNotifications *bool `access:"environment_push_notification_server"`
|
|
|
|
|
PushNotificationServer *string `access:"environment_push_notification_server"` // telemetry: none
|
|
|
|
|
PushNotificationContents *string `access:"site_notifications"`
|
2021-02-15 22:26:19 +03:00
|
|
|
PushNotificationBuffer *int // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableEmailBatching *bool `access:"site_notifications"`
|
|
|
|
|
EmailBatchingBufferSize *int `access:"experimental_features"`
|
|
|
|
|
EmailBatchingInterval *int `access:"experimental_features"`
|
|
|
|
|
EnablePreviewModeBanner *bool `access:"site_notifications"`
|
|
|
|
|
SkipServerCertificateVerification *bool `access:"environment_smtp,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EmailNotificationContentsType *string `access:"site_notifications"`
|
|
|
|
|
LoginButtonColor *string `access:"experimental_features"`
|
|
|
|
|
LoginButtonBorderColor *string `access:"experimental_features"`
|
|
|
|
|
LoginButtonTextColor *string `access:"experimental_features"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-09-20 17:38:27 +02:00
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
func (s *EmailSettings) SetDefaults(isUpdate bool) {
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.EnableSignUpWithEmail == nil {
|
|
|
|
|
s.EnableSignUpWithEmail = NewBool(true)
|
2017-09-01 08:53:55 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableSignInWithEmail == nil {
|
2019-01-31 08:12:01 -05:00
|
|
|
s.EnableSignInWithEmail = NewBool(*s.EnableSignUpWithEmail)
|
2016-01-13 14:58:49 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableSignInWithUsername == nil {
|
2019-01-31 08:12:01 -05:00
|
|
|
s.EnableSignInWithUsername = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.SendEmailNotifications == nil {
|
|
|
|
|
s.SendEmailNotifications = NewBool(true)
|
2016-01-13 14:58:49 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-24 09:57:02 -08:00
|
|
|
if s.UseChannelInEmailNotifications == nil {
|
|
|
|
|
s.UseChannelInEmailNotifications = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.RequireEmailVerification == nil {
|
|
|
|
|
s.RequireEmailVerification = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FeedbackName == nil {
|
|
|
|
|
s.FeedbackName = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.FeedbackEmail == nil {
|
|
|
|
|
s.FeedbackEmail = NewString("test@example.com")
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-04 17:01:05 -05:00
|
|
|
if s.ReplyToAddress == nil {
|
|
|
|
|
s.ReplyToAddress = NewString("test@example.com")
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.FeedbackOrganization == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.FeedbackOrganization = NewString(EmailSettingsDefaultFeedbackOrganization)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableSMTPAuth == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
if s.ConnectionSecurity == nil || *s.ConnectionSecurity == ConnSecurityNone {
|
2019-01-31 08:12:01 -05:00
|
|
|
s.EnableSMTPAuth = NewBool(false)
|
|
|
|
|
} else {
|
|
|
|
|
s.EnableSMTPAuth = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.SMTPUsername == nil {
|
|
|
|
|
s.SMTPUsername = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.SMTPPassword == nil {
|
|
|
|
|
s.SMTPPassword = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if s.SMTPServer == nil || *s.SMTPServer == "" {
|
2022-03-02 14:26:57 -07:00
|
|
|
s.SMTPServer = NewString(EmailSMTPDefaultServer)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if s.SMTPPort == nil || *s.SMTPPort == "" {
|
2022-03-02 14:26:57 -07:00
|
|
|
s.SMTPPort = NewString(EmailSMTPDefaultPort)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
2020-03-10 18:34:31 +03:00
|
|
|
if s.SMTPServerTimeout == nil || *s.SMTPServerTimeout == 0 {
|
|
|
|
|
s.SMTPServerTimeout = NewInt(10)
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if s.ConnectionSecurity == nil || *s.ConnectionSecurity == ConnSecurityPlain {
|
|
|
|
|
s.ConnectionSecurity = NewString(ConnSecurityNone)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SendPushNotifications == nil {
|
2019-06-06 20:57:01 +03:00
|
|
|
s.SendPushNotifications = NewBool(!isUpdate)
|
2015-11-30 22:38:38 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PushNotificationServer == nil {
|
2019-06-06 20:57:01 +03:00
|
|
|
if isUpdate {
|
|
|
|
|
s.PushNotificationServer = NewString("")
|
|
|
|
|
} else {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PushNotificationServer = NewString(GenericNotificationServer)
|
2019-06-06 20:57:01 +03:00
|
|
|
}
|
2015-11-30 22:38:38 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PushNotificationContents == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PushNotificationContents = NewString(FullNotification)
|
2016-03-11 00:14:55 -03:00
|
|
|
}
|
|
|
|
|
|
2020-06-18 09:26:35 +05:30
|
|
|
if s.PushNotificationBuffer == nil {
|
|
|
|
|
s.PushNotificationBuffer = NewInt(1000)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableEmailBatching == nil {
|
|
|
|
|
s.EnableEmailBatching = NewBool(false)
|
2016-08-16 14:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EmailBatchingBufferSize == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.EmailBatchingBufferSize = NewInt(EmailBatchingBufferSize)
|
2016-08-16 14:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EmailBatchingInterval == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.EmailBatchingInterval = NewInt(EmailBatchingInterval)
|
2016-08-16 14:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
2018-05-23 02:10:27 +08:00
|
|
|
if s.EnablePreviewModeBanner == nil {
|
|
|
|
|
s.EnablePreviewModeBanner = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableSMTPAuth == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
if *s.ConnectionSecurity == ConnSecurityNone {
|
2019-01-31 08:12:01 -05:00
|
|
|
s.EnableSMTPAuth = NewBool(false)
|
2017-07-31 08:15:01 -07:00
|
|
|
} else {
|
2019-01-31 08:12:01 -05:00
|
|
|
s.EnableSMTPAuth = NewBool(true)
|
2017-07-31 08:15:01 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if *s.ConnectionSecurity == ConnSecurityPlain {
|
|
|
|
|
*s.ConnectionSecurity = ConnSecurityNone
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.SkipServerCertificateVerification == nil {
|
|
|
|
|
s.SkipServerCertificateVerification = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EmailNotificationContentsType == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.EmailNotificationContentsType = NewString(EmailNotificationContentsFull)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2018-01-02 13:36:31 -08:00
|
|
|
|
|
|
|
|
if s.LoginButtonColor == nil {
|
|
|
|
|
s.LoginButtonColor = NewString("#0000")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.LoginButtonBorderColor == nil {
|
|
|
|
|
s.LoginButtonBorderColor = NewString("#2389D7")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.LoginButtonTextColor == nil {
|
|
|
|
|
s.LoginButtonTextColor = NewString("#2389D7")
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type RateLimitSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"environment_rate_limiting,write_restrictable,cloud_restrictable"`
|
|
|
|
|
PerSec *int `access:"environment_rate_limiting,write_restrictable,cloud_restrictable"`
|
|
|
|
|
MaxBurst *int `access:"environment_rate_limiting,write_restrictable,cloud_restrictable"`
|
|
|
|
|
MemoryStoreSize *int `access:"environment_rate_limiting,write_restrictable,cloud_restrictable"`
|
|
|
|
|
VaryByRemoteAddr *bool `access:"environment_rate_limiting,write_restrictable,cloud_restrictable"`
|
|
|
|
|
VaryByUser *bool `access:"environment_rate_limiting,write_restrictable,cloud_restrictable"`
|
|
|
|
|
VaryByHeader string `access:"environment_rate_limiting,write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *RateLimitSettings) SetDefaults() {
|
|
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.PerSec == nil {
|
|
|
|
|
s.PerSec = NewInt(10)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.MaxBurst == nil {
|
|
|
|
|
s.MaxBurst = NewInt(100)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.MemoryStoreSize == nil {
|
|
|
|
|
s.MemoryStoreSize = NewInt(10000)
|
|
|
|
|
}
|
2018-01-31 09:49:15 -08:00
|
|
|
|
|
|
|
|
if s.VaryByRemoteAddr == nil {
|
|
|
|
|
s.VaryByRemoteAddr = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.VaryByUser == nil {
|
|
|
|
|
s.VaryByUser = NewBool(false)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PrivacySettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
ShowEmailAddress *bool `access:"site_users_and_teams"`
|
|
|
|
|
ShowFullName *bool `access:"site_users_and_teams"`
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *PrivacySettings) setDefaults() {
|
|
|
|
|
if s.ShowEmailAddress == nil {
|
|
|
|
|
s.ShowEmailAddress = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ShowFullName == nil {
|
|
|
|
|
s.ShowFullName = NewBool(true)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type SupportSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
TermsOfServiceLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
|
|
|
|
PrivacyPolicyLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AboutLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
|
|
|
|
HelpLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ReportAProblemLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
2022-02-23 08:04:29 -07:00
|
|
|
SupportEmail *string `access:"site_notifications"`
|
2021-04-06 10:39:48 -04:00
|
|
|
CustomTermsOfServiceEnabled *bool `access:"compliance_custom_terms_of_service"`
|
|
|
|
|
CustomTermsOfServiceReAcceptancePeriod *int `access:"compliance_custom_terms_of_service"`
|
|
|
|
|
EnableAskCommunityLink *bool `access:"site_customization"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *SupportSettings) SetDefaults() {
|
2021-07-21 13:15:29 +05:30
|
|
|
if !isSafeLink(s.TermsOfServiceLink) {
|
2021-07-12 20:05:36 +02:00
|
|
|
*s.TermsOfServiceLink = SupportSettingsDefaultTermsOfServiceLink
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.TermsOfServiceLink == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.TermsOfServiceLink = NewString(SupportSettingsDefaultTermsOfServiceLink)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
2021-07-21 13:15:29 +05:30
|
|
|
if !isSafeLink(s.PrivacyPolicyLink) {
|
2017-11-20 11:04:04 -06:00
|
|
|
*s.PrivacyPolicyLink = ""
|
2017-07-31 08:15:01 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PrivacyPolicyLink == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PrivacyPolicyLink = NewString(SupportSettingsDefaultPrivacyPolicyLink)
|
2017-03-27 12:43:27 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-21 13:15:29 +05:30
|
|
|
if !isSafeLink(s.AboutLink) {
|
2017-11-20 11:04:04 -06:00
|
|
|
*s.AboutLink = ""
|
2017-08-05 19:52:35 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AboutLink == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.AboutLink = NewString(SupportSettingsDefaultAboutLink)
|
2016-04-28 17:34:56 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-21 13:15:29 +05:30
|
|
|
if !isSafeLink(s.HelpLink) {
|
2017-11-20 11:04:04 -06:00
|
|
|
*s.HelpLink = ""
|
2015-12-01 11:04:24 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.HelpLink == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.HelpLink = NewString(SupportSettingsDefaultHelpLink)
|
2016-04-28 17:34:56 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-21 13:15:29 +05:30
|
|
|
if !isSafeLink(s.ReportAProblemLink) {
|
2017-11-20 11:04:04 -06:00
|
|
|
*s.ReportAProblemLink = ""
|
2015-12-01 11:04:24 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.ReportAProblemLink == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ReportAProblemLink = NewString(SupportSettingsDefaultReportAProblemLink)
|
2016-04-28 17:34:56 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SupportEmail == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.SupportEmail = NewString(SupportSettingsDefaultSupportEmail)
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2018-09-26 20:49:22 +00:00
|
|
|
|
2018-10-10 00:55:47 +00:00
|
|
|
if s.CustomTermsOfServiceEnabled == nil {
|
|
|
|
|
s.CustomTermsOfServiceEnabled = NewBool(false)
|
2018-09-26 20:49:22 +00:00
|
|
|
}
|
2018-11-09 02:18:14 +05:30
|
|
|
|
|
|
|
|
if s.CustomTermsOfServiceReAcceptancePeriod == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.CustomTermsOfServiceReAcceptancePeriod = NewInt(SupportSettingsDefaultReAcceptancePeriod)
|
2018-11-09 02:18:14 +05:30
|
|
|
}
|
2020-07-09 17:59:22 +05:30
|
|
|
|
|
|
|
|
if s.EnableAskCommunityLink == nil {
|
|
|
|
|
s.EnableAskCommunityLink = NewBool(true)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type AnnouncementSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableBanner *bool `access:"site_announcement_banner"`
|
|
|
|
|
BannerText *string `access:"site_announcement_banner"` // telemetry: none
|
|
|
|
|
BannerColor *string `access:"site_announcement_banner"`
|
|
|
|
|
BannerTextColor *string `access:"site_announcement_banner"`
|
|
|
|
|
AllowBannerDismissal *bool `access:"site_announcement_banner"`
|
|
|
|
|
AdminNoticesEnabled *bool `access:"site_notices"`
|
|
|
|
|
UserNoticesEnabled *bool `access:"site_notices"`
|
|
|
|
|
NoticesURL *string `access:"site_notices,write_restrictable"` // telemetry: none
|
|
|
|
|
NoticesFetchFrequency *int `access:"site_notices,write_restrictable"` // telemetry: none
|
|
|
|
|
NoticesSkipCache *bool `access:"site_notices,write_restrictable"` // telemetry: none
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *AnnouncementSettings) SetDefaults() {
|
|
|
|
|
if s.EnableBanner == nil {
|
|
|
|
|
s.EnableBanner = NewBool(false)
|
2015-12-01 11:04:24 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.BannerText == nil {
|
|
|
|
|
s.BannerText = NewString("")
|
2016-04-28 17:34:56 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.BannerColor == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.BannerColor = NewString(AnnouncementSettingsDefaultBannerColor)
|
2015-12-01 11:04:24 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.BannerTextColor == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.BannerTextColor = NewString(AnnouncementSettingsDefaultBannerTextColor)
|
2016-04-28 17:34:56 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AllowBannerDismissal == nil {
|
|
|
|
|
s.AllowBannerDismissal = NewBool(true)
|
2015-12-01 11:04:24 -08:00
|
|
|
}
|
2020-09-21 10:28:46 +03:00
|
|
|
|
|
|
|
|
if s.AdminNoticesEnabled == nil {
|
|
|
|
|
s.AdminNoticesEnabled = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.UserNoticesEnabled == nil {
|
|
|
|
|
s.UserNoticesEnabled = NewBool(true)
|
|
|
|
|
}
|
2020-09-29 15:17:38 +03:00
|
|
|
if s.NoticesURL == nil {
|
2021-08-16 19:46:44 +02:00
|
|
|
s.NoticesURL = NewString(AnnouncementSettingsDefaultNoticesJsonURL)
|
2020-09-29 15:17:38 +03:00
|
|
|
}
|
|
|
|
|
if s.NoticesSkipCache == nil {
|
|
|
|
|
s.NoticesSkipCache = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
if s.NoticesFetchFrequency == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.NoticesFetchFrequency = NewInt(AnnouncementSettingsDefaultNoticesFetchFrequencySeconds)
|
2020-09-29 15:17:38 +03:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2015-12-01 11:04:24 -08:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type ThemeSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableThemeSelection *bool `access:"experimental_features"`
|
|
|
|
|
DefaultTheme *string `access:"experimental_features"`
|
|
|
|
|
AllowCustomThemes *bool `access:"experimental_features"`
|
2017-11-20 11:04:04 -06:00
|
|
|
AllowedThemes []string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ThemeSettings) SetDefaults() {
|
|
|
|
|
if s.EnableThemeSelection == nil {
|
|
|
|
|
s.EnableThemeSelection = NewBool(true)
|
2015-12-01 11:04:24 -08:00
|
|
|
}
|
2015-12-08 13:38:43 -05:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.DefaultTheme == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.DefaultTheme = NewString(TeamSettingsDefaultTeamText)
|
2017-06-05 12:49:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AllowCustomThemes == nil {
|
|
|
|
|
s.AllowCustomThemes = NewBool(true)
|
2017-06-05 12:49:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AllowedThemes == nil {
|
|
|
|
|
s.AllowedThemes = []string{}
|
2017-06-05 12:49:38 -04:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-06-05 12:49:38 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type TeamSettings struct {
|
2021-09-14 13:22:59 -04:00
|
|
|
SiteName *string `access:"site_customization"`
|
|
|
|
|
MaxUsersPerTeam *int `access:"site_users_and_teams"`
|
|
|
|
|
EnableUserCreation *bool `access:"authentication_signup"`
|
|
|
|
|
EnableOpenServer *bool `access:"authentication_signup"`
|
|
|
|
|
EnableUserDeactivation *bool `access:"experimental_features"`
|
|
|
|
|
RestrictCreationToDomains *string `access:"authentication_signup"` // telemetry: none
|
|
|
|
|
EnableCustomUserStatuses *bool `access:"site_users_and_teams"`
|
|
|
|
|
EnableCustomBrand *bool `access:"site_customization"`
|
|
|
|
|
CustomBrandText *string `access:"site_customization"`
|
|
|
|
|
CustomDescriptionText *string `access:"site_customization"`
|
|
|
|
|
RestrictDirectMessage *string `access:"site_users_and_teams"`
|
|
|
|
|
UserStatusAwayTimeout *int64 `access:"experimental_features"`
|
|
|
|
|
MaxChannelsPerTeam *int64 `access:"site_users_and_teams"`
|
|
|
|
|
MaxNotificationsPerChannel *int64 `access:"environment_push_notification_server"`
|
|
|
|
|
EnableConfirmNotificationsToChannel *bool `access:"site_notifications"`
|
|
|
|
|
TeammateNameDisplay *string `access:"site_users_and_teams"`
|
|
|
|
|
ExperimentalViewArchivedChannels *bool `access:"experimental_features,site_users_and_teams"`
|
|
|
|
|
ExperimentalEnableAutomaticReplies *bool `access:"experimental_features"`
|
|
|
|
|
LockTeammateNameDisplay *bool `access:"site_users_and_teams"`
|
|
|
|
|
ExperimentalPrimaryTeam *string `access:"experimental_features"`
|
|
|
|
|
ExperimentalDefaultChannels []string `access:"experimental_features"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *TeamSettings) SetDefaults() {
|
2019-01-31 08:12:01 -05:00
|
|
|
|
2019-03-07 11:53:37 +00:00
|
|
|
if s.SiteName == nil || *s.SiteName == "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.SiteName = NewString(TeamSettingsDefaultSiteName)
|
2019-01-31 08:12:01 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.MaxUsersPerTeam == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.MaxUsersPerTeam = NewInt(TeamSettingsDefaultMaxUsersPerTeam)
|
2017-06-05 12:49:38 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-31 08:12:01 -05:00
|
|
|
if s.EnableUserCreation == nil {
|
|
|
|
|
s.EnableUserCreation = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnableOpenServer == nil {
|
|
|
|
|
s.EnableOpenServer = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.RestrictCreationToDomains == nil {
|
|
|
|
|
s.RestrictCreationToDomains = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-18 16:38:01 +05:30
|
|
|
if s.EnableCustomUserStatuses == nil {
|
|
|
|
|
s.EnableCustomUserStatuses = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableCustomBrand == nil {
|
|
|
|
|
s.EnableCustomBrand = NewBool(false)
|
2017-06-05 12:49:38 -04:00
|
|
|
}
|
|
|
|
|
|
2018-05-28 16:20:08 +02:00
|
|
|
if s.EnableUserDeactivation == nil {
|
|
|
|
|
s.EnableUserDeactivation = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.CustomBrandText == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.CustomBrandText = NewString(TeamSettingsDefaultCustomBrandText)
|
2017-09-05 19:28:46 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.CustomDescriptionText == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.CustomDescriptionText = NewString(TeamSettingsDefaultCustomDescriptionText)
|
2017-09-05 19:28:46 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.RestrictDirectMessage == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.RestrictDirectMessage = NewString(DirectMessageAny)
|
2017-09-05 19:28:46 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.UserStatusAwayTimeout == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.UserStatusAwayTimeout = NewInt64(TeamSettingsDefaultUserStatusAwayTimeout)
|
2016-06-09 12:08:02 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.MaxChannelsPerTeam == nil {
|
|
|
|
|
s.MaxChannelsPerTeam = NewInt64(2000)
|
2016-06-09 12:08:02 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.MaxNotificationsPerChannel == nil {
|
|
|
|
|
s.MaxNotificationsPerChannel = NewInt64(1000)
|
2016-06-09 12:08:02 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableConfirmNotificationsToChannel == nil {
|
|
|
|
|
s.EnableConfirmNotificationsToChannel = NewBool(true)
|
2016-06-28 14:53:44 -04:00
|
|
|
}
|
|
|
|
|
|
2018-04-12 12:02:36 -07:00
|
|
|
if s.ExperimentalEnableAutomaticReplies == nil {
|
|
|
|
|
s.ExperimentalEnableAutomaticReplies = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-05 05:43:55 -08:00
|
|
|
if s.ExperimentalPrimaryTeam == nil {
|
|
|
|
|
s.ExperimentalPrimaryTeam = NewString("")
|
2017-12-19 18:51:23 -05:00
|
|
|
}
|
2018-02-13 06:08:21 -05:00
|
|
|
|
2018-07-20 23:00:58 +02:00
|
|
|
if s.ExperimentalDefaultChannels == nil {
|
|
|
|
|
s.ExperimentalDefaultChannels = []string{}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-18 19:27:30 +05:30
|
|
|
if s.EnableUserCreation == nil {
|
|
|
|
|
s.EnableUserCreation = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-22 20:12:51 +01:00
|
|
|
if s.ExperimentalViewArchivedChannels == nil {
|
2020-09-25 11:01:09 -04:00
|
|
|
s.ExperimentalViewArchivedChannels = NewBool(true)
|
2018-07-30 15:06:08 -04:00
|
|
|
}
|
2019-11-14 08:32:20 -05:00
|
|
|
|
|
|
|
|
if s.LockTeammateNameDisplay == nil {
|
|
|
|
|
s.LockTeammateNameDisplay = NewBool(false)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-06-09 12:08:02 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type ClientRequirements struct {
|
2020-09-30 21:09:56 +02:00
|
|
|
AndroidLatestVersion string `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
AndroidMinVersion string `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
IosLatestVersion string `access:"write_restrictable,cloud_restrictable"`
|
|
|
|
|
IosMinVersion string `access:"write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-04-13 19:31:01 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type LdapSettings struct {
|
|
|
|
|
// Basic
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"authentication_ldap"`
|
|
|
|
|
EnableSync *bool `access:"authentication_ldap"`
|
|
|
|
|
LdapServer *string `access:"authentication_ldap"` // telemetry: none
|
|
|
|
|
LdapPort *int `access:"authentication_ldap"` // telemetry: none
|
|
|
|
|
ConnectionSecurity *string `access:"authentication_ldap"`
|
|
|
|
|
BaseDN *string `access:"authentication_ldap"` // telemetry: none
|
|
|
|
|
BindUsername *string `access:"authentication_ldap"` // telemetry: none
|
|
|
|
|
BindPassword *string `access:"authentication_ldap"` // telemetry: none
|
2016-12-14 11:11:51 +00:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
// Filtering
|
2021-04-06 10:39:48 -04:00
|
|
|
UserFilter *string `access:"authentication_ldap"` // telemetry: none
|
|
|
|
|
GroupFilter *string `access:"authentication_ldap"`
|
|
|
|
|
GuestFilter *string `access:"authentication_ldap"`
|
2020-09-28 09:52:16 -04:00
|
|
|
EnableAdminFilter *bool
|
|
|
|
|
AdminFilter *string
|
2019-01-10 15:17:31 -05:00
|
|
|
|
|
|
|
|
// Group Mapping
|
2021-04-06 10:39:48 -04:00
|
|
|
GroupDisplayNameAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
GroupIdAttribute *string `access:"authentication_ldap"`
|
2016-06-03 09:33:59 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
// User Mapping
|
2021-04-06 10:39:48 -04:00
|
|
|
FirstNameAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
LastNameAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
EmailAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
UsernameAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
NicknameAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
IdAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
PositionAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
LoginIdAttribute *string `access:"authentication_ldap"`
|
|
|
|
|
PictureAttribute *string `access:"authentication_ldap"`
|
2016-06-09 12:08:02 -04:00
|
|
|
|
2018-03-29 16:04:54 +02:00
|
|
|
// Synchronization
|
2021-04-06 10:39:48 -04:00
|
|
|
SyncIntervalMinutes *int `access:"authentication_ldap"`
|
2016-06-09 12:08:02 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
// Advanced
|
2021-04-06 10:39:48 -04:00
|
|
|
SkipCertificateVerification *bool `access:"authentication_ldap"`
|
|
|
|
|
PublicCertificateFile *string `access:"authentication_ldap"`
|
|
|
|
|
PrivateKeyFile *string `access:"authentication_ldap"`
|
|
|
|
|
QueryTimeout *int `access:"authentication_ldap"`
|
|
|
|
|
MaxPageSize *int `access:"authentication_ldap"`
|
2016-07-04 07:04:02 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
// Customization
|
2021-04-06 10:39:48 -04:00
|
|
|
LoginFieldName *string `access:"authentication_ldap"`
|
2018-01-02 13:36:31 -08:00
|
|
|
|
2021-04-06 10:39:48 -04:00
|
|
|
LoginButtonColor *string `access:"experimental_features"`
|
|
|
|
|
LoginButtonBorderColor *string `access:"experimental_features"`
|
|
|
|
|
LoginButtonTextColor *string `access:"experimental_features"`
|
2019-05-24 15:55:07 +02:00
|
|
|
|
2021-04-06 10:39:48 -04:00
|
|
|
Trace *bool `access:"authentication_ldap"` // telemetry: none
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-06-09 12:08:02 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *LdapSettings) SetDefaults() {
|
|
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
2016-01-05 11:13:25 -06:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
// When unset should default to LDAP Enabled
|
|
|
|
|
if s.EnableSync == nil {
|
|
|
|
|
s.EnableSync = NewBool(*s.Enable)
|
2016-01-05 11:13:25 -06:00
|
|
|
}
|
|
|
|
|
|
2020-01-13 12:50:01 -05:00
|
|
|
if s.EnableAdminFilter == nil {
|
|
|
|
|
s.EnableAdminFilter = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LdapServer == nil {
|
|
|
|
|
s.LdapServer = NewString("")
|
2016-01-05 11:13:25 -06:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LdapPort == nil {
|
|
|
|
|
s.LdapPort = NewInt(389)
|
2016-01-05 11:13:25 -06:00
|
|
|
}
|
2016-01-08 12:41:26 -06:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.ConnectionSecurity == nil {
|
|
|
|
|
s.ConnectionSecurity = NewString("")
|
2017-09-28 09:04:52 -04:00
|
|
|
}
|
|
|
|
|
|
2020-09-14 12:53:42 -06:00
|
|
|
if s.PublicCertificateFile == nil {
|
|
|
|
|
s.PublicCertificateFile = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.PrivateKeyFile == nil {
|
|
|
|
|
s.PrivateKeyFile = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.BaseDN == nil {
|
|
|
|
|
s.BaseDN = NewString("")
|
2016-01-08 12:41:26 -06:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.BindUsername == nil {
|
|
|
|
|
s.BindUsername = NewString("")
|
2016-01-08 12:41:26 -06:00
|
|
|
}
|
2016-01-22 16:31:58 -06:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.BindPassword == nil {
|
|
|
|
|
s.BindPassword = NewString("")
|
2016-01-19 19:41:39 +01:00
|
|
|
}
|
2016-01-22 16:31:58 -06:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.UserFilter == nil {
|
|
|
|
|
s.UserFilter = NewString("")
|
2016-01-19 19:41:39 +01:00
|
|
|
}
|
2016-03-01 14:17:29 -03:00
|
|
|
|
2019-10-14 11:38:17 -06:00
|
|
|
if s.GuestFilter == nil {
|
|
|
|
|
s.GuestFilter = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-13 12:50:01 -05:00
|
|
|
if s.AdminFilter == nil {
|
|
|
|
|
s.AdminFilter = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:17:31 -05:00
|
|
|
if s.GroupFilter == nil {
|
|
|
|
|
s.GroupFilter = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.GroupDisplayNameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.GroupDisplayNameAttribute = NewString(LdapSettingsDefaultGroupDisplayNameAttribute)
|
2019-01-10 15:17:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.GroupIdAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.GroupIdAttribute = NewString(LdapSettingsDefaultGroupIdAttribute)
|
2019-01-10 15:17:31 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.FirstNameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.FirstNameAttribute = NewString(LdapSettingsDefaultFirstNameAttribute)
|
2016-03-01 14:17:29 -03:00
|
|
|
}
|
2016-03-16 23:00:33 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LastNameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.LastNameAttribute = NewString(LdapSettingsDefaultLastNameAttribute)
|
2016-03-16 23:00:33 -04:00
|
|
|
}
|
2016-03-17 09:51:45 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EmailAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.EmailAttribute = NewString(LdapSettingsDefaultEmailAttribute)
|
2017-07-06 08:48:34 +08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.UsernameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.UsernameAttribute = NewString(LdapSettingsDefaultUsernameAttribute)
|
2016-06-14 09:38:19 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.NicknameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.NicknameAttribute = NewString(LdapSettingsDefaultNicknameAttribute)
|
2016-06-14 09:38:19 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.IdAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.IdAttribute = NewString(LdapSettingsDefaultIdAttribute)
|
2017-01-18 18:38:31 +05:30
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PositionAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PositionAttribute = NewString(LdapSettingsDefaultPositionAttribute)
|
2017-01-18 18:38:31 +05:30
|
|
|
}
|
|
|
|
|
|
2020-05-14 13:25:23 -06:00
|
|
|
if s.PictureAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PictureAttribute = NewString(LdapSettingsDefaultPictureAttribute)
|
2020-05-14 13:25:23 -06:00
|
|
|
}
|
|
|
|
|
|
2018-05-10 09:46:09 -07:00
|
|
|
// For those upgrading to the version when LoginIdAttribute was added
|
|
|
|
|
// they need IdAttribute == LoginIdAttribute not to break
|
|
|
|
|
if s.LoginIdAttribute == nil {
|
|
|
|
|
s.LoginIdAttribute = s.IdAttribute
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SyncIntervalMinutes == nil {
|
|
|
|
|
s.SyncIntervalMinutes = NewInt(60)
|
2017-01-18 18:38:31 +05:30
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.SkipCertificateVerification == nil {
|
|
|
|
|
s.SkipCertificateVerification = NewBool(false)
|
2016-08-04 09:25:37 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.QueryTimeout == nil {
|
|
|
|
|
s.QueryTimeout = NewInt(60)
|
2017-06-19 08:44:04 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.MaxPageSize == nil {
|
|
|
|
|
s.MaxPageSize = NewInt(0)
|
2017-06-19 08:44:04 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LoginFieldName == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.LoginFieldName = NewString(LdapSettingsDefaultLoginFieldName)
|
2017-06-19 08:44:04 -07:00
|
|
|
}
|
2018-01-02 13:36:31 -08:00
|
|
|
|
|
|
|
|
if s.LoginButtonColor == nil {
|
|
|
|
|
s.LoginButtonColor = NewString("#0000")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.LoginButtonBorderColor == nil {
|
|
|
|
|
s.LoginButtonBorderColor = NewString("#2389D7")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.LoginButtonTextColor == nil {
|
|
|
|
|
s.LoginButtonTextColor = NewString("#2389D7")
|
|
|
|
|
}
|
2019-05-24 15:55:07 +02:00
|
|
|
|
|
|
|
|
if s.Trace == nil {
|
|
|
|
|
s.Trace = NewBool(false)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-06-19 08:44:04 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type ComplianceSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"compliance_compliance_monitoring"`
|
|
|
|
|
Directory *string `access:"compliance_compliance_monitoring"` // telemetry: none
|
|
|
|
|
EnableDaily *bool `access:"compliance_compliance_monitoring"`
|
2021-04-23 09:19:13 -04:00
|
|
|
BatchSize *int `access:"compliance_compliance_monitoring"` // telemetry: none
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-06-19 08:44:04 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *ComplianceSettings) SetDefaults() {
|
|
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
2017-06-19 08:44:04 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Directory == nil {
|
|
|
|
|
s.Directory = NewString("./data/")
|
2017-06-19 08:44:04 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableDaily == nil {
|
|
|
|
|
s.EnableDaily = NewBool(false)
|
2016-08-04 09:25:37 -08:00
|
|
|
}
|
2021-04-23 09:19:13 -04:00
|
|
|
|
|
|
|
|
if s.BatchSize == nil {
|
|
|
|
|
s.BatchSize = NewInt(30000)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-08-04 09:25:37 -08:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type LocalizationSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
DefaultServerLocale *string `access:"site_localization"`
|
|
|
|
|
DefaultClientLocale *string `access:"site_localization"`
|
|
|
|
|
AvailableLocales *string `access:"site_localization"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-11-22 11:05:54 -08:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *LocalizationSettings) SetDefaults() {
|
|
|
|
|
if s.DefaultServerLocale == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.DefaultServerLocale = NewString(DefaultLocale)
|
2016-11-22 11:05:54 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.DefaultClientLocale == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.DefaultClientLocale = NewString(DefaultLocale)
|
2016-12-22 15:00:05 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AvailableLocales == nil {
|
|
|
|
|
s.AvailableLocales = NewString("")
|
2016-03-14 16:07:58 -07:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-03-14 16:07:58 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type SamlSettings struct {
|
|
|
|
|
// Basic
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"authentication_saml"`
|
|
|
|
|
EnableSyncWithLdap *bool `access:"authentication_saml"`
|
|
|
|
|
EnableSyncWithLdapIncludeAuth *bool `access:"authentication_saml"`
|
|
|
|
|
IgnoreGuestsLdapSync *bool `access:"authentication_saml"`
|
2016-03-14 16:07:58 -07:00
|
|
|
|
2021-04-06 10:39:48 -04:00
|
|
|
Verify *bool `access:"authentication_saml"`
|
|
|
|
|
Encrypt *bool `access:"authentication_saml"`
|
|
|
|
|
SignRequest *bool `access:"authentication_saml"`
|
2016-04-07 19:42:22 -04:00
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
IdpURL *string `access:"authentication_saml"` // telemetry: none
|
|
|
|
|
IdpDescriptorURL *string `access:"authentication_saml"` // telemetry: none
|
|
|
|
|
IdpMetadataURL *string `access:"authentication_saml"` // telemetry: none
|
2021-04-06 10:39:48 -04:00
|
|
|
ServiceProviderIdentifier *string `access:"authentication_saml"` // telemetry: none
|
|
|
|
|
AssertionConsumerServiceURL *string `access:"authentication_saml"` // telemetry: none
|
2016-06-02 16:47:26 -03:00
|
|
|
|
2021-04-06 10:39:48 -04:00
|
|
|
SignatureAlgorithm *string `access:"authentication_saml"`
|
|
|
|
|
CanonicalAlgorithm *string `access:"authentication_saml"`
|
2019-09-27 12:13:31 -06:00
|
|
|
|
2021-04-06 10:39:48 -04:00
|
|
|
ScopingIDPProviderId *string `access:"authentication_saml"`
|
|
|
|
|
ScopingIDPName *string `access:"authentication_saml"`
|
2018-03-20 13:19:34 -05:00
|
|
|
|
2021-04-06 10:39:48 -04:00
|
|
|
IdpCertificateFile *string `access:"authentication_saml"` // telemetry: none
|
|
|
|
|
PublicCertificateFile *string `access:"authentication_saml"` // telemetry: none
|
|
|
|
|
PrivateKeyFile *string `access:"authentication_saml"` // telemetry: none
|
2016-06-02 16:47:26 -03:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
// User Mapping
|
2021-04-06 10:39:48 -04:00
|
|
|
IdAttribute *string `access:"authentication_saml"`
|
|
|
|
|
GuestAttribute *string `access:"authentication_saml"`
|
2020-10-13 09:55:18 -06:00
|
|
|
EnableAdminAttribute *bool
|
|
|
|
|
AdminAttribute *string
|
2021-04-06 10:39:48 -04:00
|
|
|
FirstNameAttribute *string `access:"authentication_saml"`
|
|
|
|
|
LastNameAttribute *string `access:"authentication_saml"`
|
|
|
|
|
EmailAttribute *string `access:"authentication_saml"`
|
|
|
|
|
UsernameAttribute *string `access:"authentication_saml"`
|
|
|
|
|
NicknameAttribute *string `access:"authentication_saml"`
|
|
|
|
|
LocaleAttribute *string `access:"authentication_saml"`
|
|
|
|
|
PositionAttribute *string `access:"authentication_saml"`
|
2016-07-05 15:49:00 -04:00
|
|
|
|
2021-04-06 10:39:48 -04:00
|
|
|
LoginButtonText *string `access:"authentication_saml"`
|
2018-01-02 13:36:31 -08:00
|
|
|
|
2021-04-06 10:39:48 -04:00
|
|
|
LoginButtonColor *string `access:"experimental_features"`
|
|
|
|
|
LoginButtonBorderColor *string `access:"experimental_features"`
|
|
|
|
|
LoginButtonTextColor *string `access:"experimental_features"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-09-06 18:51:27 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *SamlSettings) SetDefaults() {
|
|
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableSyncWithLdap == nil {
|
|
|
|
|
s.EnableSyncWithLdap = NewBool(false)
|
2017-10-31 08:37:34 -07:00
|
|
|
}
|
|
|
|
|
|
2018-08-28 19:49:01 +02:00
|
|
|
if s.EnableSyncWithLdapIncludeAuth == nil {
|
|
|
|
|
s.EnableSyncWithLdapIncludeAuth = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-21 20:12:12 -06:00
|
|
|
if s.IgnoreGuestsLdapSync == nil {
|
|
|
|
|
s.IgnoreGuestsLdapSync = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-13 12:50:01 -05:00
|
|
|
if s.EnableAdminAttribute == nil {
|
|
|
|
|
s.EnableAdminAttribute = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Verify == nil {
|
|
|
|
|
s.Verify = NewBool(true)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Encrypt == nil {
|
|
|
|
|
s.Encrypt = NewBool(true)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2019-06-11 14:14:15 +03:00
|
|
|
if s.SignRequest == nil {
|
|
|
|
|
s.SignRequest = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-27 12:13:31 -06:00
|
|
|
if s.SignatureAlgorithm == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.SignatureAlgorithm = NewString(SamlSettingsDefaultSignatureAlgorithm)
|
2019-09-27 12:13:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.CanonicalAlgorithm == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.CanonicalAlgorithm = NewString(SamlSettingsDefaultCanonicalAlgorithm)
|
2019-09-27 12:13:31 -06:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.IdpURL == nil {
|
|
|
|
|
s.IdpURL = NewString("")
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.IdpDescriptorURL == nil {
|
|
|
|
|
s.IdpDescriptorURL = NewString("")
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2020-06-22 09:36:08 -06:00
|
|
|
if s.ServiceProviderIdentifier == nil {
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.IdpDescriptorURL != nil {
|
|
|
|
|
s.ServiceProviderIdentifier = NewString(*s.IdpDescriptorURL)
|
2020-06-22 09:36:08 -06:00
|
|
|
} else {
|
|
|
|
|
s.ServiceProviderIdentifier = NewString("")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.IdpMetadataURL == nil {
|
|
|
|
|
s.IdpMetadataURL = NewString("")
|
2020-01-09 21:25:20 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.IdpCertificateFile == nil {
|
|
|
|
|
s.IdpCertificateFile = NewString("")
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PublicCertificateFile == nil {
|
|
|
|
|
s.PublicCertificateFile = NewString("")
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PrivateKeyFile == nil {
|
|
|
|
|
s.PrivateKeyFile = NewString("")
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AssertionConsumerServiceURL == nil {
|
|
|
|
|
s.AssertionConsumerServiceURL = NewString("")
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2018-03-28 11:24:13 -04:00
|
|
|
if s.ScopingIDPProviderId == nil {
|
|
|
|
|
s.ScopingIDPProviderId = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ScopingIDPName == nil {
|
|
|
|
|
s.ScopingIDPName = NewString("")
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LoginButtonText == nil || *s.LoginButtonText == "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.LoginButtonText = NewString(UserAuthServiceSamlText)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2018-08-28 11:56:40 +02:00
|
|
|
if s.IdAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.IdAttribute = NewString(SamlSettingsDefaultIdAttribute)
|
2018-08-28 11:56:40 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-10 11:37:57 -06:00
|
|
|
if s.GuestAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.GuestAttribute = NewString(SamlSettingsDefaultGuestAttribute)
|
2019-10-10 11:37:57 -06:00
|
|
|
}
|
2020-01-13 12:50:01 -05:00
|
|
|
if s.AdminAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.AdminAttribute = NewString(SamlSettingsDefaultAdminAttribute)
|
2020-01-13 12:50:01 -05:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.FirstNameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.FirstNameAttribute = NewString(SamlSettingsDefaultFirstNameAttribute)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LastNameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.LastNameAttribute = NewString(SamlSettingsDefaultLastNameAttribute)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EmailAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.EmailAttribute = NewString(SamlSettingsDefaultEmailAttribute)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.UsernameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.UsernameAttribute = NewString(SamlSettingsDefaultUsernameAttribute)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.NicknameAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.NicknameAttribute = NewString(SamlSettingsDefaultNicknameAttribute)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PositionAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PositionAttribute = NewString(SamlSettingsDefaultPositionAttribute)
|
2016-12-14 11:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LocaleAttribute == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.LocaleAttribute = NewString(SamlSettingsDefaultLocaleAttribute)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
2018-01-02 13:36:31 -08:00
|
|
|
|
|
|
|
|
if s.LoginButtonColor == nil {
|
|
|
|
|
s.LoginButtonColor = NewString("#34a28b")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.LoginButtonBorderColor == nil {
|
|
|
|
|
s.LoginButtonBorderColor = NewString("#2389D7")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.LoginButtonTextColor == nil {
|
|
|
|
|
s.LoginButtonTextColor = NewString("#ffffff")
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-07-22 10:53:57 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type NativeAppSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
AppCustomURLSchemes []string `access:"site_customization,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
AppDownloadLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AndroidAppDownloadLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
|
|
|
|
IosAppDownloadLink *string `access:"site_customization,write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-07-06 10:35:17 +08:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *NativeAppSettings) SetDefaults() {
|
|
|
|
|
if s.AppDownloadLink == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.AppDownloadLink = NewString(NativeappSettingsDefaultAppDownloadLink)
|
2017-07-06 10:35:17 +08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AndroidAppDownloadLink == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.AndroidAppDownloadLink = NewString(NativeappSettingsDefaultAndroidAppDownloadLink)
|
2016-07-22 10:53:57 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.IosAppDownloadLink == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.IosAppDownloadLink = NewString(NativeappSettingsDefaultIosAppDownloadLink)
|
2016-07-22 10:53:57 -04:00
|
|
|
}
|
2021-01-19 21:16:22 +05:30
|
|
|
|
|
|
|
|
if s.AppCustomURLSchemes == nil {
|
|
|
|
|
s.AppCustomURLSchemes = GetDefaultAppCustomURLSchemes()
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-07-22 10:53:57 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type ElasticsearchSettings struct {
|
2021-08-16 19:46:44 +02:00
|
|
|
ConnectionURL *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
2021-04-06 10:39:48 -04:00
|
|
|
Username *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
Password *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableIndexing *bool `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableSearching *bool `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableAutocomplete *bool `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
Sniff *bool `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
PostIndexReplicas *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
PostIndexShards *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ChannelIndexReplicas *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
ChannelIndexShards *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
UserIndexReplicas *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
UserIndexShards *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AggregatePostsAfterDays *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
PostsAggregatorJobStartTime *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
IndexPrefix *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
LiveIndexingBatchSize *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
BulkIndexingTimeWindowSeconds *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
RequestTimeoutSeconds *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
SkipTLSVerification *bool `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
|
|
|
|
Trace *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2016-10-03 16:03:15 -04:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *ElasticsearchSettings) SetDefaults() {
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.ConnectionURL == nil {
|
|
|
|
|
s.ConnectionURL = NewString(ElasticsearchSettingsDefaultConnectionURL)
|
2016-10-03 16:03:15 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Username == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.Username = NewString(ElasticsearchSettingsDefaultUsername)
|
2016-10-03 16:03:15 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Password == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.Password = NewString(ElasticsearchSettingsDefaultPassword)
|
2016-10-03 16:03:15 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableIndexing == nil {
|
|
|
|
|
s.EnableIndexing = NewBool(false)
|
2017-08-31 01:54:16 +08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableSearching == nil {
|
|
|
|
|
s.EnableSearching = NewBool(false)
|
2016-10-03 16:03:15 -04:00
|
|
|
}
|
|
|
|
|
|
2019-03-15 17:53:53 +00:00
|
|
|
if s.EnableAutocomplete == nil {
|
|
|
|
|
s.EnableAutocomplete = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Sniff == nil {
|
|
|
|
|
s.Sniff = NewBool(true)
|
2016-12-09 10:26:56 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PostIndexReplicas == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PostIndexReplicas = NewInt(ElasticsearchSettingsDefaultPostIndexReplicas)
|
2017-01-30 15:43:34 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PostIndexShards == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PostIndexShards = NewInt(ElasticsearchSettingsDefaultPostIndexShards)
|
2017-04-17 07:54:26 -07:00
|
|
|
}
|
|
|
|
|
|
2019-03-15 17:53:53 +00:00
|
|
|
if s.ChannelIndexReplicas == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ChannelIndexReplicas = NewInt(ElasticsearchSettingsDefaultChannelIndexReplicas)
|
2019-03-15 17:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ChannelIndexShards == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ChannelIndexShards = NewInt(ElasticsearchSettingsDefaultChannelIndexShards)
|
2019-03-15 17:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.UserIndexReplicas == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.UserIndexReplicas = NewInt(ElasticsearchSettingsDefaultUserIndexReplicas)
|
2019-03-15 17:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.UserIndexShards == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.UserIndexShards = NewInt(ElasticsearchSettingsDefaultUserIndexShards)
|
2019-03-15 17:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.AggregatePostsAfterDays == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.AggregatePostsAfterDays = NewInt(ElasticsearchSettingsDefaultAggregatePostsAfterDays)
|
2017-01-30 15:43:34 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PostsAggregatorJobStartTime == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.PostsAggregatorJobStartTime = NewString(ElasticsearchSettingsDefaultPostsAggregatorJobStartTime)
|
2017-06-29 07:51:15 -07:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.IndexPrefix == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.IndexPrefix = NewString(ElasticsearchSettingsDefaultIndexPrefix)
|
2017-04-28 10:10:58 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.LiveIndexingBatchSize == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.LiveIndexingBatchSize = NewInt(ElasticsearchSettingsDefaultLiveIndexingBatchSize)
|
2017-02-10 07:04:14 -08:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.BulkIndexingTimeWindowSeconds == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.BulkIndexingTimeWindowSeconds = NewInt(ElasticsearchSettingsDefaultBulkIndexingTimeWindowSeconds)
|
2017-10-30 12:52:47 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.RequestTimeoutSeconds == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.RequestTimeoutSeconds = NewInt(ElasticsearchSettingsDefaultRequestTimeoutSeconds)
|
2017-05-18 16:26:52 +01:00
|
|
|
}
|
2019-05-30 16:48:19 +01:00
|
|
|
|
2019-06-23 12:03:55 +01:00
|
|
|
if s.SkipTLSVerification == nil {
|
|
|
|
|
s.SkipTLSVerification = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-30 16:48:19 +01:00
|
|
|
if s.Trace == nil {
|
2019-05-31 17:25:11 +01:00
|
|
|
s.Trace = NewString("")
|
2019-05-30 16:48:19 +01:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-05-18 16:26:52 +01:00
|
|
|
|
2020-05-20 01:29:55 +02:00
|
|
|
type BleveSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
IndexDir *string `access:"experimental_bleve"` // telemetry: none
|
|
|
|
|
EnableIndexing *bool `access:"experimental_bleve"`
|
|
|
|
|
EnableSearching *bool `access:"experimental_bleve"`
|
|
|
|
|
EnableAutocomplete *bool `access:"experimental_bleve"`
|
|
|
|
|
BulkIndexingTimeWindowSeconds *int `access:"experimental_bleve"`
|
2020-05-20 01:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (bs *BleveSettings) SetDefaults() {
|
|
|
|
|
if bs.IndexDir == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
bs.IndexDir = NewString(BleveSettingsDefaultIndexDir)
|
2020-05-20 01:29:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if bs.EnableIndexing == nil {
|
|
|
|
|
bs.EnableIndexing = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if bs.EnableSearching == nil {
|
|
|
|
|
bs.EnableSearching = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if bs.EnableAutocomplete == nil {
|
|
|
|
|
bs.EnableAutocomplete = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if bs.BulkIndexingTimeWindowSeconds == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
bs.BulkIndexingTimeWindowSeconds = NewInt(BleveSettingsDefaultBulkIndexingTimeWindowSeconds)
|
2020-05-20 01:29:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type DataRetentionSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableMessageDeletion *bool `access:"compliance_data_retention_policy"`
|
|
|
|
|
EnableFileDeletion *bool `access:"compliance_data_retention_policy"`
|
2022-01-20 17:46:03 -07:00
|
|
|
EnableBoardsDeletion *bool `access:"compliance_data_retention_policy"`
|
2021-04-06 10:39:48 -04:00
|
|
|
MessageRetentionDays *int `access:"compliance_data_retention_policy"`
|
|
|
|
|
FileRetentionDays *int `access:"compliance_data_retention_policy"`
|
2022-01-20 17:46:03 -07:00
|
|
|
BoardsRetentionDays *int `access:"compliance_data_retention_policy"`
|
2021-04-06 10:39:48 -04:00
|
|
|
DeletionJobStartTime *string `access:"compliance_data_retention_policy"`
|
2021-06-23 07:55:12 -04:00
|
|
|
BatchSize *int `access:"compliance_data_retention_policy"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-05-18 16:26:52 +01:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *DataRetentionSettings) SetDefaults() {
|
|
|
|
|
if s.EnableMessageDeletion == nil {
|
|
|
|
|
s.EnableMessageDeletion = NewBool(false)
|
2017-05-18 16:26:52 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableFileDeletion == nil {
|
|
|
|
|
s.EnableFileDeletion = NewBool(false)
|
2017-05-18 16:26:52 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-20 17:46:03 -07:00
|
|
|
if s.EnableBoardsDeletion == nil {
|
|
|
|
|
s.EnableBoardsDeletion = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.MessageRetentionDays == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.MessageRetentionDays = NewInt(DataRetentionSettingsDefaultMessageRetentionDays)
|
2017-05-18 16:26:52 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.FileRetentionDays == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.FileRetentionDays = NewInt(DataRetentionSettingsDefaultFileRetentionDays)
|
2017-05-18 16:26:52 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-20 17:46:03 -07:00
|
|
|
if s.BoardsRetentionDays == nil {
|
|
|
|
|
s.BoardsRetentionDays = NewInt(DataRetentionSettingsDefaultBoardsRetentionDays)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.DeletionJobStartTime == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.DeletionJobStartTime = NewString(DataRetentionSettingsDefaultDeletionJobStartTime)
|
2017-08-02 14:50:09 +01:00
|
|
|
}
|
2021-06-23 07:55:12 -04:00
|
|
|
|
|
|
|
|
if s.BatchSize == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.BatchSize = NewInt(DataRetentionSettingsDefaultBatchSize)
|
2021-06-23 07:55:12 -04:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-08-02 14:50:09 +01:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type JobSettings struct {
|
2021-11-08 11:45:59 +05:30
|
|
|
RunJobs *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
RunScheduler *bool `access:"write_restrictable,cloud_restrictable"` // telemetry: none
|
2021-10-15 11:03:54 +05:30
|
|
|
CleanupJobsThresholdDays *int `access:"write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-08-02 14:50:09 +01:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (s *JobSettings) SetDefaults() {
|
|
|
|
|
if s.RunJobs == nil {
|
|
|
|
|
s.RunJobs = NewBool(true)
|
2017-08-17 15:05:17 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.RunScheduler == nil {
|
|
|
|
|
s.RunScheduler = NewBool(true)
|
2017-08-17 15:05:17 +01:00
|
|
|
}
|
2021-10-15 11:03:54 +05:30
|
|
|
|
|
|
|
|
if s.CleanupJobsThresholdDays == nil {
|
|
|
|
|
s.CleanupJobsThresholdDays = NewInt(-1)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-08-17 15:05:17 +01:00
|
|
|
|
2020-09-28 12:18:47 -04:00
|
|
|
type CloudSettings struct {
|
2021-08-16 19:46:44 +02:00
|
|
|
CWSURL *string `access:"write_restrictable"`
|
|
|
|
|
CWSAPIURL *string `access:"write_restrictable"`
|
2020-09-28 12:18:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *CloudSettings) SetDefaults() {
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.CWSURL == nil {
|
|
|
|
|
s.CWSURL = NewString(CloudSettingsDefaultCwsURL)
|
2020-09-28 12:18:47 -04:00
|
|
|
}
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.CWSAPIURL == nil {
|
|
|
|
|
s.CWSAPIURL = NewString(CloudSettingsDefaultCwsAPIURL)
|
2021-03-23 15:27:40 +01:00
|
|
|
}
|
2020-09-28 12:18:47 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type PluginState struct {
|
|
|
|
|
Enable bool
|
|
|
|
|
}
|
2017-09-22 16:44:19 +01:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type PluginSettings struct {
|
2020-10-01 15:53:36 -04:00
|
|
|
Enable *bool `access:"plugins,write_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
EnableUploads *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
2021-08-16 19:46:44 +02:00
|
|
|
AllowInsecureDownloadURL *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
EnableHealthCheck *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
2021-02-15 22:26:19 +03:00
|
|
|
Directory *string `access:"plugins,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
ClientDirectory *string `access:"plugins,write_restrictable,cloud_restrictable"` // telemetry: none
|
|
|
|
|
Plugins map[string]map[string]interface{} `access:"plugins"` // telemetry: none
|
|
|
|
|
PluginStates map[string]*PluginState `access:"plugins"` // telemetry: none
|
2020-09-30 21:09:56 +02:00
|
|
|
EnableMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
|
|
|
|
EnableRemoteMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
|
|
|
|
AutomaticPrepackagedPlugins *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
|
|
|
|
RequirePluginSignature *bool `access:"plugins,write_restrictable,cloud_restrictable"`
|
2021-08-16 19:46:44 +02:00
|
|
|
MarketplaceURL *string `access:"plugins,write_restrictable,cloud_restrictable"`
|
2020-09-30 21:09:56 +02:00
|
|
|
SignaturePublicKeyFiles []string `access:"plugins,write_restrictable,cloud_restrictable"`
|
2021-08-16 19:46:44 +02:00
|
|
|
ChimeraOAuthProxyURL *string `access:"plugins,write_restrictable,cloud_restrictable"`
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-10-18 11:43:10 +01:00
|
|
|
|
2019-06-19 09:06:59 -04:00
|
|
|
func (s *PluginSettings) SetDefaults(ls LogSettings) {
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(true)
|
2017-10-25 13:23:01 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.EnableUploads == nil {
|
|
|
|
|
s.EnableUploads = NewBool(false)
|
2017-10-25 19:48:29 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.AllowInsecureDownloadURL == nil {
|
|
|
|
|
s.AllowInsecureDownloadURL = NewBool(false)
|
2019-06-26 15:45:07 -04:00
|
|
|
}
|
|
|
|
|
|
2019-08-12 18:48:02 -03:00
|
|
|
if s.EnableHealthCheck == nil {
|
|
|
|
|
s.EnableHealthCheck = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 16:02:26 -03:00
|
|
|
if s.Directory == nil || *s.Directory == "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.Directory = NewString(PluginSettingsDefaultDirectory)
|
2017-09-15 17:53:48 +01:00
|
|
|
}
|
|
|
|
|
|
2019-09-17 16:02:26 -03:00
|
|
|
if s.ClientDirectory == nil || *s.ClientDirectory == "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ClientDirectory = NewString(PluginSettingsDefaultClientDirectory)
|
2017-12-05 13:25:49 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.Plugins == nil {
|
2018-07-09 07:25:57 -07:00
|
|
|
s.Plugins = make(map[string]map[string]interface{})
|
2017-09-15 17:53:48 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if s.PluginStates == nil {
|
|
|
|
|
s.PluginStates = make(map[string]*PluginState)
|
2017-09-15 17:53:48 +01:00
|
|
|
}
|
2019-03-26 12:04:12 -07:00
|
|
|
|
|
|
|
|
if s.PluginStates["com.mattermost.nps"] == nil {
|
2019-06-19 09:06:59 -04:00
|
|
|
// Enable the NPS plugin by default if diagnostics are enabled
|
|
|
|
|
s.PluginStates["com.mattermost.nps"] = &PluginState{Enable: ls.EnableDiagnostics == nil || *ls.EnableDiagnostics}
|
2019-03-26 12:04:12 -07:00
|
|
|
}
|
2019-09-17 16:02:26 -03:00
|
|
|
|
2021-09-27 22:20:02 -03:00
|
|
|
if s.PluginStates["playbooks"] == nil {
|
2021-09-17 08:24:57 -07:00
|
|
|
// Enable the playbooks plugin by default
|
|
|
|
|
s.PluginStates["playbooks"] = &PluginState{Enable: true}
|
2020-09-10 21:05:20 -03:00
|
|
|
}
|
|
|
|
|
|
2020-12-04 15:09:05 -04:00
|
|
|
if s.PluginStates["com.mattermost.plugin-channel-export"] == nil && BuildEnterpriseReady == "true" {
|
|
|
|
|
// Enable the channel export plugin by default
|
|
|
|
|
s.PluginStates["com.mattermost.plugin-channel-export"] = &PluginState{Enable: true}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-06 13:28:37 -06:00
|
|
|
if s.PluginStates["focalboard"] == nil {
|
|
|
|
|
// Enable the focalboard plugin by default
|
|
|
|
|
s.PluginStates["focalboard"] = &PluginState{Enable: true}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 16:02:26 -03:00
|
|
|
if s.EnableMarketplace == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.EnableMarketplace = NewBool(PluginSettingsDefaultEnableMarketplace)
|
2019-09-17 16:02:26 -03:00
|
|
|
}
|
|
|
|
|
|
2020-01-15 13:38:55 -05:00
|
|
|
if s.EnableRemoteMarketplace == nil {
|
|
|
|
|
s.EnableRemoteMarketplace = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AutomaticPrepackagedPlugins == nil {
|
|
|
|
|
s.AutomaticPrepackagedPlugins = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.MarketplaceURL == nil || *s.MarketplaceURL == "" || *s.MarketplaceURL == PluginSettingsOldMarketplaceURL {
|
|
|
|
|
s.MarketplaceURL = NewString(PluginSettingsDefaultMarketplaceURL)
|
2019-09-17 16:02:26 -03:00
|
|
|
}
|
2019-11-18 19:02:41 -05:00
|
|
|
|
|
|
|
|
if s.RequirePluginSignature == nil {
|
|
|
|
|
s.RequirePluginSignature = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.SignaturePublicKeyFiles == nil {
|
|
|
|
|
s.SignaturePublicKeyFiles = []string{}
|
|
|
|
|
}
|
2021-07-13 13:32:08 +02:00
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.ChimeraOAuthProxyURL == nil {
|
|
|
|
|
s.ChimeraOAuthProxyURL = NewString("")
|
2021-07-13 13:32:08 +02:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-09-15 17:53:48 +01:00
|
|
|
|
2018-03-08 06:45:36 -05:00
|
|
|
type GlobalRelayMessageExportSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
CustomerType *string `access:"compliance_compliance_export"` // must be either A9 or A10, dictates SMTP server url
|
2021-08-12 11:49:16 +02:00
|
|
|
SMTPUsername *string `access:"compliance_compliance_export"`
|
|
|
|
|
SMTPPassword *string `access:"compliance_compliance_export"`
|
2021-04-06 10:39:48 -04:00
|
|
|
EmailAddress *string `access:"compliance_compliance_export"` // the address to send messages to
|
|
|
|
|
SMTPServerTimeout *int `access:"compliance_compliance_export"`
|
2018-03-08 06:45:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *GlobalRelayMessageExportSettings) SetDefaults() {
|
|
|
|
|
if s.CustomerType == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.CustomerType = NewString(GlobalrelayCustomerTypeA9)
|
2018-03-08 06:45:36 -05:00
|
|
|
}
|
2021-08-12 11:49:16 +02:00
|
|
|
if s.SMTPUsername == nil {
|
|
|
|
|
s.SMTPUsername = NewString("")
|
2018-03-08 06:45:36 -05:00
|
|
|
}
|
2021-08-12 11:49:16 +02:00
|
|
|
if s.SMTPPassword == nil {
|
|
|
|
|
s.SMTPPassword = NewString("")
|
2018-03-08 06:45:36 -05:00
|
|
|
}
|
|
|
|
|
if s.EmailAddress == nil {
|
|
|
|
|
s.EmailAddress = NewString("")
|
|
|
|
|
}
|
2020-07-16 11:21:55 +03:00
|
|
|
if s.SMTPServerTimeout == nil || *s.SMTPServerTimeout == 0 {
|
|
|
|
|
s.SMTPServerTimeout = NewInt(1800)
|
|
|
|
|
}
|
2018-03-08 06:45:36 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-30 09:07:04 -05:00
|
|
|
type MessageExportSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
EnableExport *bool `access:"compliance_compliance_export"`
|
|
|
|
|
ExportFormat *string `access:"compliance_compliance_export"`
|
|
|
|
|
DailyRunTime *string `access:"compliance_compliance_export"`
|
|
|
|
|
ExportFromTimestamp *int64 `access:"compliance_compliance_export"`
|
|
|
|
|
BatchSize *int `access:"compliance_compliance_export"`
|
|
|
|
|
DownloadExportResults *bool `access:"compliance_compliance_export"`
|
2018-02-07 09:02:46 -05:00
|
|
|
|
|
|
|
|
// formatter-specific settings - these are only expected to be non-nil if ExportFormat is set to the associated format
|
2021-04-06 10:39:48 -04:00
|
|
|
GlobalRelaySettings *GlobalRelayMessageExportSettings `access:"compliance_compliance_export"`
|
2017-11-30 09:07:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *MessageExportSettings) SetDefaults() {
|
|
|
|
|
if s.EnableExport == nil {
|
|
|
|
|
s.EnableExport = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-27 08:37:04 -04:00
|
|
|
if s.DownloadExportResults == nil {
|
|
|
|
|
s.DownloadExportResults = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-07 09:02:46 -05:00
|
|
|
if s.ExportFormat == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.ExportFormat = NewString(ComplianceExportTypeActiance)
|
2018-02-07 09:02:46 -05:00
|
|
|
}
|
|
|
|
|
|
2017-11-30 09:07:04 -05:00
|
|
|
if s.DailyRunTime == nil {
|
|
|
|
|
s.DailyRunTime = NewString("01:00")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.ExportFromTimestamp == nil {
|
|
|
|
|
s.ExportFromTimestamp = NewInt64(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.BatchSize == nil {
|
|
|
|
|
s.BatchSize = NewInt(10000)
|
|
|
|
|
}
|
2018-03-08 06:45:36 -05:00
|
|
|
|
|
|
|
|
if s.GlobalRelaySettings == nil {
|
|
|
|
|
s.GlobalRelaySettings = &GlobalRelayMessageExportSettings{}
|
|
|
|
|
}
|
2018-04-13 10:56:09 -04:00
|
|
|
s.GlobalRelaySettings.SetDefaults()
|
2017-11-30 09:07:04 -05:00
|
|
|
}
|
|
|
|
|
|
2018-03-29 07:04:17 -07:00
|
|
|
type DisplaySettings struct {
|
2021-08-16 19:46:44 +02:00
|
|
|
CustomURLSchemes []string `access:"site_customization"`
|
2021-04-06 10:39:48 -04:00
|
|
|
ExperimentalTimezone *bool `access:"experimental_features"`
|
2018-03-29 07:04:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *DisplaySettings) SetDefaults() {
|
2021-08-16 19:46:44 +02:00
|
|
|
if s.CustomURLSchemes == nil {
|
|
|
|
|
customURLSchemes := []string{}
|
|
|
|
|
s.CustomURLSchemes = customURLSchemes
|
2018-05-30 10:48:04 -04:00
|
|
|
}
|
|
|
|
|
|
2018-03-29 07:04:17 -07:00
|
|
|
if s.ExperimentalTimezone == nil {
|
2020-09-25 11:01:09 -04:00
|
|
|
s.ExperimentalTimezone = NewBool(true)
|
2018-03-29 07:04:17 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-22 22:13:39 +02:00
|
|
|
type GuestAccountsSettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"authentication_guest_access"`
|
|
|
|
|
AllowEmailAccounts *bool `access:"authentication_guest_access"`
|
|
|
|
|
EnforceMultifactorAuthentication *bool `access:"authentication_guest_access"`
|
|
|
|
|
RestrictCreationToDomains *string `access:"authentication_guest_access"`
|
2019-07-22 22:13:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *GuestAccountsSettings) SetDefaults() {
|
|
|
|
|
if s.Enable == nil {
|
|
|
|
|
s.Enable = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.AllowEmailAccounts == nil {
|
|
|
|
|
s.AllowEmailAccounts = NewBool(true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.EnforceMultifactorAuthentication == nil {
|
|
|
|
|
s.EnforceMultifactorAuthentication = NewBool(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.RestrictCreationToDomains == nil {
|
|
|
|
|
s.RestrictCreationToDomains = NewString("")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-24 16:11:32 -04:00
|
|
|
type ImageProxySettings struct {
|
2021-04-06 10:39:48 -04:00
|
|
|
Enable *bool `access:"environment_image_proxy"`
|
|
|
|
|
ImageProxyType *string `access:"environment_image_proxy"`
|
|
|
|
|
RemoteImageProxyURL *string `access:"environment_image_proxy"`
|
|
|
|
|
RemoteImageProxyOptions *string `access:"environment_image_proxy"`
|
2019-01-24 16:11:32 -04:00
|
|
|
}
|
|
|
|
|
|
2021-09-14 13:22:59 -04:00
|
|
|
func (s *ImageProxySettings) SetDefaults() {
|
2020-01-07 10:47:03 +01:00
|
|
|
if s.Enable == nil {
|
2021-09-14 13:22:59 -04:00
|
|
|
s.Enable = NewBool(false)
|
2019-01-24 16:11:32 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if s.ImageProxyType == nil {
|
2021-09-14 13:22:59 -04:00
|
|
|
s.ImageProxyType = NewString(ImageProxyTypeLocal)
|
2019-01-24 16:11:32 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if s.RemoteImageProxyURL == nil {
|
2021-09-14 13:22:59 -04:00
|
|
|
s.RemoteImageProxyURL = NewString("")
|
2019-01-24 16:11:32 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if s.RemoteImageProxyOptions == nil {
|
2021-09-14 13:22:59 -04:00
|
|
|
s.RemoteImageProxyOptions = NewString("")
|
2019-01-24 16:11:32 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 11:38:00 +01:00
|
|
|
// ImportSettings defines configuration settings for file imports.
|
|
|
|
|
type ImportSettings struct {
|
|
|
|
|
// The directory where to store the imported files.
|
|
|
|
|
Directory *string
|
|
|
|
|
// The number of days to retain the imported files before deleting them.
|
|
|
|
|
RetentionDays *int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ImportSettings) isValid() *AppError {
|
|
|
|
|
if *s.Directory == "" {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.import.directory.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if *s.RetentionDays <= 0 {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.import.retention_days_too_low.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetDefaults applies the default settings to the struct.
|
|
|
|
|
func (s *ImportSettings) SetDefaults() {
|
|
|
|
|
if s.Directory == nil || *s.Directory == "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.Directory = NewString(ImportSettingsDefaultDirectory)
|
2020-12-03 11:38:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.RetentionDays == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.RetentionDays = NewInt(ImportSettingsDefaultRetentionDays)
|
2020-12-03 11:38:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-09 11:58:31 +01:00
|
|
|
// ExportSettings defines configuration settings for file exports.
|
|
|
|
|
type ExportSettings struct {
|
|
|
|
|
// The directory where to store the exported files.
|
2021-02-15 22:26:19 +03:00
|
|
|
Directory *string // telemetry: none
|
2021-02-09 11:58:31 +01:00
|
|
|
// The number of days to retain the exported files before deleting them.
|
|
|
|
|
RetentionDays *int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ExportSettings) isValid() *AppError {
|
|
|
|
|
if *s.Directory == "" {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.export.directory.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if *s.RetentionDays <= 0 {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.export.retention_days_too_low.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetDefaults applies the default settings to the struct.
|
|
|
|
|
func (s *ExportSettings) SetDefaults() {
|
|
|
|
|
if s.Directory == nil || *s.Directory == "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.Directory = NewString(ExportSettingsDefaultDirectory)
|
2021-02-09 11:58:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.RetentionDays == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
s.RetentionDays = NewInt(ExportSettingsDefaultRetentionDays)
|
2021-02-09 11:58:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
type ConfigFunc func() *Config
|
2017-05-18 15:05:57 -04:00
|
|
|
|
2020-09-30 21:09:56 +02:00
|
|
|
const ConfigAccessTagType = "access"
|
2020-08-21 16:49:31 -04:00
|
|
|
const ConfigAccessTagWriteRestrictable = "write_restrictable"
|
2020-09-30 21:09:56 +02:00
|
|
|
const ConfigAccessTagCloudRestrictable = "cloud_restrictable"
|
2020-08-21 16:49:31 -04:00
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
// Allows read access if any PermissionSysconsoleRead* is allowed
|
2021-04-06 08:39:36 -06:00
|
|
|
const ConfigAccessTagAnySysConsoleRead = "*_read"
|
|
|
|
|
|
2020-08-21 16:49:31 -04:00
|
|
|
// Config fields support the 'access' tag with the following values corresponding to the suffix of the associated
|
2021-07-12 20:05:36 +02:00
|
|
|
// PermissionSysconsole* permission Id: 'about', 'reporting', 'user_management_users',
|
2020-08-21 16:49:31 -04:00
|
|
|
// 'user_management_groups', 'user_management_teams', 'user_management_channels',
|
2021-04-06 10:39:48 -04:00
|
|
|
// 'user_management_permissions', 'environment_web_server', 'environment_database', 'environment_elasticsearch',
|
|
|
|
|
// 'environment_file_storage', 'environment_image_proxy', 'environment_smtp', 'environment_push_notification_server',
|
|
|
|
|
// 'environment_high_availability', 'environment_rate_limiting', 'environment_logging', 'environment_session_lengths',
|
|
|
|
|
// 'environment_performance_monitoring', 'environment_developer', 'site', 'authentication', 'plugins',
|
2020-08-21 16:49:31 -04:00
|
|
|
// 'integrations', 'compliance', 'plugins', and 'experimental'. They grant read and/or write access to the config field
|
2021-07-12 20:05:36 +02:00
|
|
|
// to roles without PermissionManageSystem.
|
2020-08-21 16:49:31 -04:00
|
|
|
//
|
2021-07-12 20:05:36 +02:00
|
|
|
// The 'access' tag '*_read' checks for any Sysconsole read permission and grants access if any read permission is allowed.
|
2021-04-06 08:39:36 -06:00
|
|
|
//
|
2021-07-12 20:05:36 +02:00
|
|
|
// By default config values can be written with PermissionManageSystem, but if ExperimentalSettings.RestrictSystemAdmin is true
|
|
|
|
|
// and the access tag contains the value 'write_restrictable', then even PermissionManageSystem, does not grant write access.
|
2020-08-21 16:49:31 -04:00
|
|
|
//
|
2021-07-12 20:05:36 +02:00
|
|
|
// PermissionManageSystem always grants read access.
|
2020-08-21 16:49:31 -04:00
|
|
|
//
|
2020-09-30 21:09:56 +02:00
|
|
|
// Config values with the access tag 'cloud_restrictable' mean that are marked to be filtered when it's used in a cloud licensed
|
|
|
|
|
// environment with ExperimentalSettings.RestrictedSystemAdmin set to true.
|
|
|
|
|
//
|
2020-08-21 16:49:31 -04:00
|
|
|
// Example:
|
|
|
|
|
// type HairSettings struct {
|
2021-07-12 20:05:36 +02:00
|
|
|
// // Colour is writeable with either PermissionSysconsoleWriteReporting or PermissionSysconsoleWriteUserManagementGroups.
|
|
|
|
|
// // It is readable by PermissionSysconsoleReadReporting and PermissionSysconsoleReadUserManagementGroups permissions.
|
|
|
|
|
// // PermissionManageSystem grants read and write access.
|
2020-08-21 16:49:31 -04:00
|
|
|
// Colour string `access:"reporting,user_management_groups"`
|
|
|
|
|
//
|
2021-07-12 20:05:36 +02:00
|
|
|
// // Length is only readable and writable via PermissionManageSystem.
|
2020-08-21 16:49:31 -04:00
|
|
|
// Length string
|
|
|
|
|
//
|
2021-07-12 20:05:36 +02:00
|
|
|
// // Product is only writeable by PermissionManageSystem if ExperimentalSettings.RestrictSystemAdmin is false.
|
|
|
|
|
// // PermissionManageSystem can always read the value.
|
2020-08-21 16:49:31 -04:00
|
|
|
// Product bool `access:write_restrictable`
|
|
|
|
|
// }
|
2017-11-20 11:04:04 -06:00
|
|
|
type Config struct {
|
2020-03-12 15:50:21 -04:00
|
|
|
ServiceSettings ServiceSettings
|
|
|
|
|
TeamSettings TeamSettings
|
|
|
|
|
ClientRequirements ClientRequirements
|
|
|
|
|
SqlSettings SqlSettings
|
|
|
|
|
LogSettings LogSettings
|
|
|
|
|
ExperimentalAuditSettings ExperimentalAuditSettings
|
|
|
|
|
NotificationLogSettings NotificationLogSettings
|
|
|
|
|
PasswordSettings PasswordSettings
|
|
|
|
|
FileSettings FileSettings
|
|
|
|
|
EmailSettings EmailSettings
|
|
|
|
|
RateLimitSettings RateLimitSettings
|
|
|
|
|
PrivacySettings PrivacySettings
|
|
|
|
|
SupportSettings SupportSettings
|
|
|
|
|
AnnouncementSettings AnnouncementSettings
|
|
|
|
|
ThemeSettings ThemeSettings
|
|
|
|
|
GitLabSettings SSOSettings
|
|
|
|
|
GoogleSettings SSOSettings
|
|
|
|
|
Office365Settings Office365Settings
|
2020-12-08 19:58:37 -07:00
|
|
|
OpenIdSettings SSOSettings
|
2020-03-12 15:50:21 -04:00
|
|
|
LdapSettings LdapSettings
|
|
|
|
|
ComplianceSettings ComplianceSettings
|
|
|
|
|
LocalizationSettings LocalizationSettings
|
|
|
|
|
SamlSettings SamlSettings
|
|
|
|
|
NativeAppSettings NativeAppSettings
|
|
|
|
|
ClusterSettings ClusterSettings
|
|
|
|
|
MetricsSettings MetricsSettings
|
|
|
|
|
ExperimentalSettings ExperimentalSettings
|
|
|
|
|
AnalyticsSettings AnalyticsSettings
|
|
|
|
|
ElasticsearchSettings ElasticsearchSettings
|
2020-05-20 01:29:55 +02:00
|
|
|
BleveSettings BleveSettings
|
2020-03-12 15:50:21 -04:00
|
|
|
DataRetentionSettings DataRetentionSettings
|
|
|
|
|
MessageExportSettings MessageExportSettings
|
2021-11-08 11:45:59 +05:30
|
|
|
JobSettings JobSettings
|
2020-03-12 15:50:21 -04:00
|
|
|
PluginSettings PluginSettings
|
|
|
|
|
DisplaySettings DisplaySettings
|
|
|
|
|
GuestAccountsSettings GuestAccountsSettings
|
|
|
|
|
ImageProxySettings ImageProxySettings
|
2021-02-15 22:26:19 +03:00
|
|
|
CloudSettings CloudSettings // telemetry: none
|
2021-04-27 08:58:38 -07:00
|
|
|
FeatureFlags *FeatureFlags `access:"*_read" json:",omitempty"`
|
2021-02-15 22:26:19 +03:00
|
|
|
ImportSettings ImportSettings // telemetry: none
|
2021-02-09 11:58:31 +01:00
|
|
|
ExportSettings ExportSettings
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-07-07 15:21:02 +01:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (o *Config) Clone() *Config {
|
2021-07-28 13:15:46 +05:30
|
|
|
buf, err := json.Marshal(o)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
var ret Config
|
2021-07-28 13:15:46 +05:30
|
|
|
err = json.Unmarshal(buf, &ret)
|
|
|
|
|
if err != nil {
|
2017-11-20 11:04:04 -06:00
|
|
|
panic(err)
|
2017-07-07 15:21:02 +01:00
|
|
|
}
|
2017-11-20 11:04:04 -06:00
|
|
|
return &ret
|
|
|
|
|
}
|
2017-07-07 15:21:02 +01:00
|
|
|
|
2021-09-01 14:43:12 +02:00
|
|
|
func (o *Config) ToJSONFiltered(tagType, tagValue string) ([]byte, error) {
|
2020-09-30 21:09:56 +02:00
|
|
|
filteredConfigMap := structToMapFilteredByTag(*o, tagType, tagValue)
|
|
|
|
|
for key, value := range filteredConfigMap {
|
|
|
|
|
v, ok := value.(map[string]interface{})
|
|
|
|
|
if ok && len(v) == 0 {
|
|
|
|
|
delete(filteredConfigMap, key)
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-01 14:43:12 +02:00
|
|
|
return json.Marshal(filteredConfigMap)
|
2020-09-30 21:09:56 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (o *Config) GetSSOService(service string) *SSOSettings {
|
|
|
|
|
switch service {
|
2021-07-12 20:05:36 +02:00
|
|
|
case ServiceGitlab:
|
2017-11-20 11:04:04 -06:00
|
|
|
return &o.GitLabSettings
|
2021-07-12 20:05:36 +02:00
|
|
|
case ServiceGoogle:
|
2017-11-20 11:04:04 -06:00
|
|
|
return &o.GoogleSettings
|
2021-07-12 20:05:36 +02:00
|
|
|
case ServiceOffice365:
|
2020-02-14 09:55:40 -08:00
|
|
|
return o.Office365Settings.SSOSettings()
|
2021-07-12 20:05:36 +02:00
|
|
|
case ServiceOpenid:
|
2020-12-08 19:58:37 -07:00
|
|
|
return &o.OpenIdSettings
|
2017-10-26 13:21:35 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
return nil
|
|
|
|
|
}
|
2017-10-26 13:21:35 -04:00
|
|
|
|
2021-09-01 14:43:12 +02:00
|
|
|
func ConfigFromJSON(data io.Reader) *Config {
|
2018-01-30 17:23:00 -06:00
|
|
|
var o *Config
|
|
|
|
|
json.NewDecoder(data).Decode(&o)
|
|
|
|
|
return o
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-09-01 09:00:27 -04:00
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
// isUpdate detects a pre-existing config based on whether SiteURL has been changed
|
|
|
|
|
func (o *Config) isUpdate() bool {
|
|
|
|
|
return o.ServiceSettings.SiteURL != nil
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
func (o *Config) SetDefaults() {
|
2019-06-06 20:57:01 +03:00
|
|
|
isUpdate := o.isUpdate()
|
|
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
o.LdapSettings.SetDefaults()
|
|
|
|
|
o.SamlSettings.SetDefaults()
|
|
|
|
|
|
|
|
|
|
if o.TeamSettings.TeammateNameDisplay == nil {
|
2021-07-12 20:05:36 +02:00
|
|
|
o.TeamSettings.TeammateNameDisplay = NewString(ShowUsername)
|
2017-08-02 01:36:54 -07:00
|
|
|
|
2017-11-20 11:04:04 -06:00
|
|
|
if *o.SamlSettings.Enable || *o.LdapSettings.Enable {
|
2021-07-12 20:05:36 +02:00
|
|
|
*o.TeamSettings.TeammateNameDisplay = ShowFullName
|
2017-11-20 11:04:04 -06:00
|
|
|
}
|
2017-10-25 08:17:17 -04:00
|
|
|
}
|
|
|
|
|
|
2019-06-06 20:57:01 +03:00
|
|
|
o.SqlSettings.SetDefaults(isUpdate)
|
|
|
|
|
o.FileSettings.SetDefaults(isUpdate)
|
|
|
|
|
o.EmailSettings.SetDefaults(isUpdate)
|
2019-01-31 08:12:01 -05:00
|
|
|
o.PrivacySettings.setDefaults()
|
2020-02-14 09:55:40 -08:00
|
|
|
o.Office365Settings.setDefaults()
|
2020-12-08 19:58:37 -07:00
|
|
|
o.Office365Settings.setDefaults()
|
|
|
|
|
o.GitLabSettings.setDefaults("", "", "", "", "")
|
2021-08-16 19:46:44 +02:00
|
|
|
o.GoogleSettings.setDefaults(GoogleSettingsDefaultScope, GoogleSettingsDefaultAuthEndpoint, GoogleSettingsDefaultTokenEndpoint, GoogleSettingsDefaultUserAPIEndpoint, "")
|
2021-07-12 20:05:36 +02:00
|
|
|
o.OpenIdSettings.setDefaults(OpenidSettingsDefaultScope, "", "", "", "#145DBF")
|
2019-06-06 20:57:01 +03:00
|
|
|
o.ServiceSettings.SetDefaults(isUpdate)
|
2017-11-20 11:04:04 -06:00
|
|
|
o.PasswordSettings.SetDefaults()
|
|
|
|
|
o.TeamSettings.SetDefaults()
|
|
|
|
|
o.MetricsSettings.SetDefaults()
|
2018-06-12 10:16:39 -07:00
|
|
|
o.ExperimentalSettings.SetDefaults()
|
2017-11-20 11:04:04 -06:00
|
|
|
o.SupportSettings.SetDefaults()
|
|
|
|
|
o.AnnouncementSettings.SetDefaults()
|
|
|
|
|
o.ThemeSettings.SetDefaults()
|
|
|
|
|
o.ClusterSettings.SetDefaults()
|
2019-06-19 09:06:59 -04:00
|
|
|
o.PluginSettings.SetDefaults(o.LogSettings)
|
2017-11-20 11:04:04 -06:00
|
|
|
o.AnalyticsSettings.SetDefaults()
|
|
|
|
|
o.ComplianceSettings.SetDefaults()
|
|
|
|
|
o.LocalizationSettings.SetDefaults()
|
|
|
|
|
o.ElasticsearchSettings.SetDefaults()
|
2020-05-20 01:29:55 +02:00
|
|
|
o.BleveSettings.SetDefaults()
|
2017-11-20 11:04:04 -06:00
|
|
|
o.NativeAppSettings.SetDefaults()
|
|
|
|
|
o.DataRetentionSettings.SetDefaults()
|
|
|
|
|
o.RateLimitSettings.SetDefaults()
|
|
|
|
|
o.LogSettings.SetDefaults()
|
2020-03-12 15:50:21 -04:00
|
|
|
o.ExperimentalAuditSettings.SetDefaults()
|
2019-05-13 10:53:46 -04:00
|
|
|
o.NotificationLogSettings.SetDefaults()
|
2017-11-20 11:04:04 -06:00
|
|
|
o.JobSettings.SetDefaults()
|
2017-11-30 09:07:04 -05:00
|
|
|
o.MessageExportSettings.SetDefaults()
|
2018-03-29 07:04:17 -07:00
|
|
|
o.DisplaySettings.SetDefaults()
|
2019-07-22 22:13:39 +02:00
|
|
|
o.GuestAccountsSettings.SetDefaults()
|
2021-09-14 13:22:59 -04:00
|
|
|
o.ImageProxySettings.SetDefaults()
|
2020-09-28 12:18:47 -04:00
|
|
|
o.CloudSettings.SetDefaults()
|
2020-09-29 21:41:22 -07:00
|
|
|
if o.FeatureFlags == nil {
|
|
|
|
|
o.FeatureFlags = &FeatureFlags{}
|
|
|
|
|
o.FeatureFlags.SetDefaults()
|
|
|
|
|
}
|
2020-12-03 11:38:00 +01:00
|
|
|
o.ImportSettings.SetDefaults()
|
2021-02-09 11:58:31 +01:00
|
|
|
o.ExportSettings.SetDefaults()
|
2015-10-09 12:24:39 -07:00
|
|
|
}
|
|
|
|
|
|
2015-09-29 14:17:16 -07:00
|
|
|
func (o *Config) IsValid() *AppError {
|
2021-01-25 11:15:17 +01:00
|
|
|
if *o.ServiceSettings.SiteURL == "" && *o.EmailSettings.EnableEmailBatching {
|
2018-05-30 06:58:24 -07:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.site_url_email_batching.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
if *o.ClusterSettings.Enable && *o.EmailSettings.EnableEmailBatching {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.cluster_email_batching.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *o.ServiceSettings.SiteURL == "" && *o.ServiceSettings.AllowCookiesForSubdomains {
|
2018-06-19 19:40:26 +02:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.allow_cookies_for_subdomains.app_error", nil, "", http.StatusBadRequest)
|
2018-05-30 06:58:24 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
if err := o.TeamSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
2016-08-02 16:37:09 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
if err := o.SqlSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
2016-08-02 16:37:09 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
if err := o.FileSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
2016-08-16 14:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
if err := o.EmailSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
2016-08-16 14:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
if err := o.LdapSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := o.SamlSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if *o.PasswordSettings.MinimumLength < PasswordMinimumLength || *o.PasswordSettings.MinimumLength > PasswordMaximumLength {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.password_length.app_error", map[string]interface{}{"MinLength": PasswordMinimumLength, "MaxLength": PasswordMaximumLength}, "", http.StatusBadRequest)
|
2017-10-03 10:42:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := o.RateLimitSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := o.ServiceSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := o.ElasticsearchSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 01:29:55 +02:00
|
|
|
if err := o.BleveSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
if err := o.DataRetentionSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := o.LocalizationSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 11:38:05 +06:00
|
|
|
if err := o.MessageExportSettings.isValid(); err != nil {
|
2017-11-30 09:07:04 -05:00
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-30 10:48:04 -04:00
|
|
|
if err := o.DisplaySettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-24 16:11:32 -04:00
|
|
|
if err := o.ImageProxySettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2020-12-03 11:38:00 +01:00
|
|
|
|
|
|
|
|
if err := o.ImportSettings.isValid(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
2017-10-03 10:42:19 -04:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *TeamSettings) isValid() *AppError {
|
|
|
|
|
if *s.MaxUsersPerTeam <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.max_users.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.MaxChannelsPerTeam <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.max_channels.app_error", nil, "", http.StatusBadRequest)
|
2016-10-21 20:36:13 +08:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.MaxNotificationsPerChannel <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.max_notify_per_channel.app_error", nil, "", http.StatusBadRequest)
|
2016-11-24 05:26:45 -08:00
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if !(*s.RestrictDirectMessage == DirectMessageAny || *s.RestrictDirectMessage == DirectMessageTeam) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.restrict_direct_message.app_error", nil, "", http.StatusBadRequest)
|
2016-05-04 06:31:42 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if !(*s.TeammateNameDisplay == ShowFullName || *s.TeammateNameDisplay == ShowNicknameFullName || *s.TeammateNameDisplay == ShowUsername) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.teammate_name_display.app_error", nil, "", http.StatusBadRequest)
|
2017-06-30 16:06:59 +08:00
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if len(*s.SiteName) > SitenameMaxLength {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.sitename_length.app_error", map[string]interface{}{"MaxLength": SitenameMaxLength}, "", http.StatusBadRequest)
|
2017-10-03 10:42:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *SqlSettings) isValid() *AppError {
|
|
|
|
|
if *s.AtRestEncryptKey != "" && len(*s.AtRestEncryptKey) < 32 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.encrypt_sql.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if !(*s.DriverName == DatabaseDriverMysql || *s.DriverName == DatabaseDriverPostgres) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.sql_driver.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.MaxIdleConns <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.sql_idle.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.ConnMaxLifetimeMilliseconds < 0 {
|
2018-06-28 09:45:20 -04:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.sql_conn_max_lifetime_milliseconds.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-28 09:37:15 +05:30
|
|
|
if *s.ConnMaxIdleTimeMilliseconds < 0 {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.sql_conn_max_idle_time_milliseconds.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.QueryTimeout <= 0 {
|
2017-05-29 15:46:35 -04:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.sql_query_timeout.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.DataSource == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.sql_data_src.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.MaxOpenConns <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.sql_max_conn.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *FileSettings) isValid() *AppError {
|
|
|
|
|
if *s.MaxFileSize <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.max_file_size.app_error", nil, "", http.StatusBadRequest)
|
2016-05-24 15:07:42 +02:00
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if !(*s.DriverName == ImageDriverLocal || *s.DriverName == ImageDriverS3) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.file_driver.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.PublicLinkSalt != "" && len(*s.PublicLinkSalt) < 32 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.file_salt.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-08-04 13:58:48 +02:00
|
|
|
if *s.Directory == "" {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.directory.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *EmailSettings) isValid() *AppError {
|
2021-08-12 11:49:16 +02:00
|
|
|
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTLS || *s.ConnectionSecurity == ConnSecurityStarttls || *s.ConnectionSecurity == ConnSecurityPlain) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.email_security.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.EmailBatchingBufferSize <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.email_batching_buffer_size.app_error", nil, "", http.StatusBadRequest)
|
2016-08-16 14:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.EmailBatchingInterval < 30 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.email_batching_interval.app_error", nil, "", http.StatusBadRequest)
|
2016-08-16 14:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if !(*s.EmailNotificationContentsType == EmailNotificationContentsFull || *s.EmailNotificationContentsType == EmailNotificationContentsGeneric) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.email_notification_contents_type.app_error", nil, "", http.StatusBadRequest)
|
2017-08-05 19:52:35 -04:00
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *RateLimitSettings) isValid() *AppError {
|
|
|
|
|
if *s.MemoryStoreSize <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.rate_mem.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.PerSec <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.rate_sec.app_error", nil, "", http.StatusBadRequest)
|
2015-09-29 14:17:16 -07:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.MaxBurst <= 0 {
|
2017-10-03 10:42:19 -04:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.max_burst.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *LdapSettings) isValid() *AppError {
|
2021-08-12 11:49:16 +02:00
|
|
|
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTLS || *s.ConnectionSecurity == ConnSecurityStarttls) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_security.app_error", nil, "", http.StatusBadRequest)
|
2016-04-07 10:38:36 -04:00
|
|
|
}
|
2016-06-03 09:33:59 -04:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.SyncIntervalMinutes <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "", http.StatusBadRequest)
|
2016-06-03 09:33:59 -04:00
|
|
|
}
|
2016-06-28 14:53:44 -04:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.MaxPageSize < 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_max_page_size.app_error", nil, "", http.StatusBadRequest)
|
2016-07-04 07:04:02 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.Enable {
|
|
|
|
|
if *s.LdapServer == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_server", nil, "", http.StatusBadRequest)
|
2016-07-14 15:57:59 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.BaseDN == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_basedn", nil, "", http.StatusBadRequest)
|
2016-07-14 15:57:59 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.EmailAttribute == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_email", nil, "", http.StatusBadRequest)
|
2016-07-14 15:57:59 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.UsernameAttribute == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_username", nil, "", http.StatusBadRequest)
|
2016-07-14 15:57:59 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.IdAttribute == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_id", nil, "", http.StatusBadRequest)
|
2016-06-28 14:53:44 -04:00
|
|
|
}
|
2018-05-10 09:46:09 -07:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.LoginIdAttribute == "" {
|
2018-05-10 09:46:09 -07:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.ldap_login_id", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
2019-02-12 14:19:01 -04:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.UserFilter != "" {
|
|
|
|
|
if _, err := ldap.CompileFilter(*s.UserFilter); err != nil {
|
2019-02-12 14:19:01 -04:00
|
|
|
return NewAppError("ValidateFilter", "ent.ldap.validate_filter.app_error", nil, err.Error(), http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-14 11:38:17 -06:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.GuestFilter != "" {
|
|
|
|
|
if _, err := ldap.CompileFilter(*s.GuestFilter); err != nil {
|
2019-10-14 11:38:17 -06:00
|
|
|
return NewAppError("LdapSettings.isValid", "ent.ldap.validate_guest_filter.app_error", nil, err.Error(), http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-13 12:50:01 -05:00
|
|
|
|
|
|
|
|
if *s.AdminFilter != "" {
|
|
|
|
|
if _, err := ldap.CompileFilter(*s.AdminFilter); err != nil {
|
|
|
|
|
return NewAppError("LdapSettings.isValid", "ent.ldap.validate_admin_filter.app_error", nil, err.Error(), http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-28 14:53:44 -04:00
|
|
|
}
|
2016-07-05 15:49:00 -04:00
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *SamlSettings) isValid() *AppError {
|
|
|
|
|
if *s.Enable {
|
2021-08-16 19:46:44 +02:00
|
|
|
if *s.IdpURL == "" || !IsValidHTTPURL(*s.IdpURL) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_url.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if *s.IdpDescriptorURL == "" || !IsValidHTTPURL(*s.IdpDescriptorURL) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_descriptor_url.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.IdpCertificateFile == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_cert.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.EmailAttribute == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.UsernameAttribute == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.ServiceProviderIdentifier == "" {
|
2020-06-22 09:36:08 -06:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_spidentifier_attribute.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.Verify {
|
2021-08-16 19:46:44 +02:00
|
|
|
if *s.AssertionConsumerServiceURL == "" || !IsValidHTTPURL(*s.AssertionConsumerServiceURL) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.Encrypt {
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.PrivateKeyFile == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_private_key.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.PublicCertificateFile == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_public_cert.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.EmailAttribute == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "", http.StatusBadRequest)
|
2019-09-27 12:13:31 -06:00
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if !(*s.SignatureAlgorithm == SamlSettingsSignatureAlgorithmSha1 || *s.SignatureAlgorithm == SamlSettingsSignatureAlgorithmSha256 || *s.SignatureAlgorithm == SamlSettingsSignatureAlgorithmSha512) {
|
2019-09-27 12:13:31 -06:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_signature_algorithm.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
2021-07-12 20:05:36 +02:00
|
|
|
if !(*s.CanonicalAlgorithm == SamlSettingsCanonicalAlgorithmC14n || *s.CanonicalAlgorithm == SamlSettingsCanonicalAlgorithmC14n11) {
|
2019-09-27 12:13:31 -06:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_canonical_algorithm.app_error", nil, "", http.StatusBadRequest)
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
2019-10-10 11:37:57 -06:00
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.GuestAttribute != "" {
|
2020-01-07 10:47:03 +01:00
|
|
|
if !(strings.Contains(*s.GuestAttribute, "=")) {
|
2019-10-10 11:37:57 -06:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_guest_attribute.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
2020-01-07 10:47:03 +01:00
|
|
|
if len(strings.Split(*s.GuestAttribute, "=")) != 2 {
|
2019-10-10 11:37:57 -06:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_guest_attribute.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-13 12:50:01 -05:00
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.AdminAttribute != "" {
|
2020-01-13 12:50:01 -05:00
|
|
|
if !(strings.Contains(*s.AdminAttribute, "=")) {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_admin_attribute.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
if len(strings.Split(*s.AdminAttribute, "=")) != 2 {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.saml_admin_attribute.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-05 15:49:00 -04:00
|
|
|
}
|
2016-07-06 18:54:54 -04:00
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
return nil
|
|
|
|
|
}
|
2016-04-07 10:38:36 -04:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *ServiceSettings) isValid() *AppError {
|
2021-08-12 11:49:16 +02:00
|
|
|
if !(*s.ConnectionSecurity == ConnSecurityNone || *s.ConnectionSecurity == ConnSecurityTLS) {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.webserver_security.app_error", nil, "", http.StatusBadRequest)
|
2016-10-03 16:03:15 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-12 11:49:16 +02:00
|
|
|
if *s.ConnectionSecurity == ConnSecurityTLS && !*s.UseLetsEncrypt {
|
2021-03-15 20:22:25 +03:00
|
|
|
appErr := NewAppError("Config.IsValid", "model.config.is_valid.tls_cert_file_missing.app_error", nil, "", http.StatusBadRequest)
|
2018-10-16 16:51:46 +02:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.TLSCertFile == "" {
|
2018-10-16 16:51:46 +02:00
|
|
|
return appErr
|
2020-01-07 10:47:03 +01:00
|
|
|
} else if _, err := os.Stat(*s.TLSCertFile); os.IsNotExist(err) {
|
2018-10-16 16:51:46 +02:00
|
|
|
return appErr
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 20:22:25 +03:00
|
|
|
appErr = NewAppError("Config.IsValid", "model.config.is_valid.tls_key_file_missing.app_error", nil, "", http.StatusBadRequest)
|
2018-10-16 16:51:46 +02:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.TLSKeyFile == "" {
|
2018-10-16 16:51:46 +02:00
|
|
|
return appErr
|
2020-01-07 10:47:03 +01:00
|
|
|
} else if _, err := os.Stat(*s.TLSKeyFile); os.IsNotExist(err) {
|
2018-10-16 16:51:46 +02:00
|
|
|
return appErr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if len(s.TLSOverwriteCiphers) > 0 {
|
|
|
|
|
for _, cipher := range s.TLSOverwriteCiphers {
|
2018-10-16 16:51:46 +02:00
|
|
|
if _, ok := ServerTLSSupportedCiphers[cipher]; !ok {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.tls_overwrite_cipher.app_error", map[string]interface{}{"name": cipher}, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.ReadTimeout <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.read_timeout.app_error", nil, "", http.StatusBadRequest)
|
2016-10-03 16:03:15 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.WriteTimeout <= 0 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.write_timeout.app_error", nil, "", http.StatusBadRequest)
|
2016-10-03 16:03:15 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.TimeBetweenUserTypingUpdatesMilliseconds < 1000 {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.time_between_user_typing.app_error", nil, "", http.StatusBadRequest)
|
2017-01-30 15:43:34 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.MaximumLoginAttempts <= 0 {
|
2017-10-03 10:42:19 -04:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.login_attempts.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-22 19:20:59 +05:30
|
|
|
if *s.SiteURL != "" {
|
2020-01-07 10:47:03 +01:00
|
|
|
if _, err := url.ParseRequestURI(*s.SiteURL); err != nil {
|
2018-05-30 06:58:24 -07:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.site_url.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-22 19:20:59 +05:30
|
|
|
if *s.WebsocketURL != "" {
|
2020-01-07 10:47:03 +01:00
|
|
|
if _, err := url.ParseRequestURI(*s.WebsocketURL); err != nil {
|
2018-02-20 12:49:45 -08:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.websocket_url.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
host, port, _ := net.SplitHostPort(*s.ListenAddress)
|
2018-07-30 14:59:08 -04:00
|
|
|
var isValidHost bool
|
|
|
|
|
if host == "" {
|
|
|
|
|
isValidHost = true
|
|
|
|
|
} else {
|
2021-07-21 13:15:29 +05:30
|
|
|
isValidHost = (net.ParseIP(host) != nil) || isDomainName(host)
|
2018-07-30 14:59:08 -04:00
|
|
|
}
|
|
|
|
|
portInt, err := strconv.Atoi(port)
|
|
|
|
|
if err != nil || !isValidHost || portInt < 0 || portInt > math.MaxUint16 {
|
2017-10-03 10:42:19 -04:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if *s.ExperimentalGroupUnreadChannels != GroupUnreadChannelsDisabled &&
|
|
|
|
|
*s.ExperimentalGroupUnreadChannels != GroupUnreadChannelsDefaultOn &&
|
|
|
|
|
*s.ExperimentalGroupUnreadChannels != GroupUnreadChannelsDefaultOff {
|
2018-02-06 18:45:14 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.group_unread_channels.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-25 19:25:30 +05:30
|
|
|
if *s.CollapsedThreads != CollapsedThreadsDisabled && !*s.ThreadAutoFollow {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.collapsed_threads.autofollow.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if *s.CollapsedThreads != CollapsedThreadsDisabled &&
|
|
|
|
|
*s.CollapsedThreads != CollapsedThreadsDefaultOn &&
|
|
|
|
|
*s.CollapsedThreads != CollapsedThreadsDefaultOff {
|
2020-11-20 11:00:52 +02:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.collapsed_threads.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *ElasticsearchSettings) isValid() *AppError {
|
|
|
|
|
if *s.EnableIndexing {
|
2021-08-16 19:46:44 +02:00
|
|
|
if *s.ConnectionURL == "" {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.connection_url.app_error", nil, "", http.StatusBadRequest)
|
2017-05-18 16:26:52 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.EnableSearching && !*s.EnableIndexing {
|
2017-09-05 13:54:05 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.enable_searching.app_error", nil, "", http.StatusBadRequest)
|
2017-05-18 16:26:52 +01:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.EnableAutocomplete && !*s.EnableIndexing {
|
2019-03-15 17:53:53 +00:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.enable_autocomplete.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.AggregatePostsAfterDays < 1 {
|
2017-08-17 15:05:17 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.aggregate_posts_after_days.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if _, err := time.Parse("15:04", *s.PostsAggregatorJobStartTime); err != nil {
|
2017-08-17 15:05:17 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.posts_aggregator_job_start_time.app_error", nil, err.Error(), http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.LiveIndexingBatchSize < 1 {
|
2017-10-18 11:43:10 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.live_indexing_batch_size.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.BulkIndexingTimeWindowSeconds < 1 {
|
2017-10-25 13:23:01 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.bulk_indexing_time_window_seconds.app_error", nil, "", http.StatusBadRequest)
|
2017-10-25 19:48:29 +01:00
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.RequestTimeoutSeconds < 1 {
|
2017-10-25 19:48:29 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.request_timeout_seconds.app_error", nil, "", http.StatusBadRequest)
|
2017-10-25 13:23:01 +01:00
|
|
|
}
|
|
|
|
|
|
2017-10-03 10:42:19 -04:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 01:29:55 +02:00
|
|
|
func (bs *BleveSettings) isValid() *AppError {
|
|
|
|
|
if *bs.EnableIndexing {
|
2021-01-25 11:15:17 +01:00
|
|
|
if *bs.IndexDir == "" {
|
2020-05-20 01:29:55 +02:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.filename.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if *bs.EnableSearching {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.enable_searching.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
if *bs.EnableAutocomplete {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.enable_autocomplete.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if *bs.BulkIndexingTimeWindowSeconds < 1 {
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.bleve_search.bulk_indexing_time_window_seconds.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *DataRetentionSettings) isValid() *AppError {
|
|
|
|
|
if *s.MessageRetentionDays <= 0 {
|
2017-09-15 17:53:48 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.data_retention.message_retention_days_too_low.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.FileRetentionDays <= 0 {
|
2017-09-15 17:53:48 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.data_retention.file_retention_days_too_low.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if _, err := time.Parse("15:04", *s.DeletionJobStartTime); err != nil {
|
2017-09-15 17:53:48 +01:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.data_retention.deletion_job_start_time.app_error", nil, err.Error(), http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-29 14:17:16 -07:00
|
|
|
return nil
|
|
|
|
|
}
|
2015-12-07 15:13:31 -08:00
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *LocalizationSettings) isValid() *AppError {
|
2021-01-25 11:15:17 +01:00
|
|
|
if *s.AvailableLocales != "" {
|
2020-01-07 10:47:03 +01:00
|
|
|
if !strings.Contains(*s.AvailableLocales, *s.DefaultClientLocale) {
|
2017-10-03 10:42:19 -04:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.localization.available_locales.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 11:38:05 +06:00
|
|
|
func (s *MessageExportSettings) isValid() *AppError {
|
2020-01-07 10:47:03 +01:00
|
|
|
if s.EnableExport == nil {
|
2017-11-30 09:07:04 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.enable.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.EnableExport {
|
|
|
|
|
if s.ExportFromTimestamp == nil || *s.ExportFromTimestamp < 0 || *s.ExportFromTimestamp > GetMillis() {
|
2017-11-30 09:07:04 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.export_from.app_error", nil, "", http.StatusBadRequest)
|
2020-01-07 10:47:03 +01:00
|
|
|
} else if s.DailyRunTime == nil {
|
2017-11-30 09:07:04 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.daily_runtime.app_error", nil, "", http.StatusBadRequest)
|
2020-01-07 10:47:03 +01:00
|
|
|
} else if _, err := time.Parse("15:04", *s.DailyRunTime); err != nil {
|
2017-11-30 09:07:04 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.daily_runtime.app_error", nil, err.Error(), http.StatusBadRequest)
|
2020-01-07 10:47:03 +01:00
|
|
|
} else if s.BatchSize == nil || *s.BatchSize < 0 {
|
2017-11-30 09:07:04 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.batch_size.app_error", nil, "", http.StatusBadRequest)
|
2021-07-12 20:05:36 +02:00
|
|
|
} else if s.ExportFormat == nil || (*s.ExportFormat != ComplianceExportTypeActiance && *s.ExportFormat != ComplianceExportTypeGlobalrelay && *s.ExportFormat != ComplianceExportTypeCsv) {
|
2018-02-07 09:02:46 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.export_type.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 20:05:36 +02:00
|
|
|
if *s.ExportFormat == ComplianceExportTypeGlobalrelay {
|
2020-01-07 10:47:03 +01:00
|
|
|
if s.GlobalRelaySettings == nil {
|
2018-03-08 06:45:36 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.config_missing.app_error", nil, "", http.StatusBadRequest)
|
2021-07-12 20:05:36 +02:00
|
|
|
} else if s.GlobalRelaySettings.CustomerType == nil || (*s.GlobalRelaySettings.CustomerType != GlobalrelayCustomerTypeA9 && *s.GlobalRelaySettings.CustomerType != GlobalrelayCustomerTypeA10) {
|
2018-03-08 06:45:36 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.customer_type.app_error", nil, "", http.StatusBadRequest)
|
2020-01-07 10:47:03 +01:00
|
|
|
} else if s.GlobalRelaySettings.EmailAddress == nil || !strings.Contains(*s.GlobalRelaySettings.EmailAddress, "@") {
|
2018-03-08 06:45:36 -05:00
|
|
|
// validating email addresses is hard - just make sure it contains an '@' sign
|
|
|
|
|
// see https://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.email_address.app_error", nil, "", http.StatusBadRequest)
|
2021-08-12 11:49:16 +02:00
|
|
|
} else if s.GlobalRelaySettings.SMTPUsername == nil || *s.GlobalRelaySettings.SMTPUsername == "" {
|
2018-03-08 06:45:36 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.smtp_username.app_error", nil, "", http.StatusBadRequest)
|
2021-08-12 11:49:16 +02:00
|
|
|
} else if s.GlobalRelaySettings.SMTPPassword == nil || *s.GlobalRelaySettings.SMTPPassword == "" {
|
2018-03-08 06:45:36 -05:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.message_export.global_relay.smtp_password.app_error", nil, "", http.StatusBadRequest)
|
2018-02-07 09:02:46 -05:00
|
|
|
}
|
2017-11-30 09:07:04 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *DisplaySettings) isValid() *AppError {
|
2021-08-16 19:46:44 +02:00
|
|
|
if len(s.CustomURLSchemes) != 0 {
|
2019-05-25 22:47:06 +03:00
|
|
|
validProtocolPattern := regexp.MustCompile(`(?i)^\s*[A-Za-z][A-Za-z0-9.+-]*\s*$`)
|
2018-05-30 10:48:04 -04:00
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
for _, scheme := range s.CustomURLSchemes {
|
2018-05-30 10:48:04 -04:00
|
|
|
if !validProtocolPattern.MatchString(scheme) {
|
|
|
|
|
return NewAppError(
|
|
|
|
|
"Config.IsValid",
|
|
|
|
|
"model.config.is_valid.display.custom_url_schemes.app_error",
|
2018-06-05 13:18:59 -04:00
|
|
|
map[string]interface{}{"Scheme": scheme},
|
2018-05-30 10:48:04 -04:00
|
|
|
"",
|
|
|
|
|
http.StatusBadRequest,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
func (s *ImageProxySettings) isValid() *AppError {
|
|
|
|
|
if *s.Enable {
|
|
|
|
|
switch *s.ImageProxyType {
|
2021-07-12 20:05:36 +02:00
|
|
|
case ImageProxyTypeLocal:
|
2019-01-24 16:11:32 -04:00
|
|
|
// No other settings to validate
|
2021-07-12 20:05:36 +02:00
|
|
|
case ImageProxyTypeAtmosCamo:
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.RemoteImageProxyURL == "" {
|
2019-01-24 16:11:32 -04:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.atmos_camo_image_proxy_url.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 10:47:03 +01:00
|
|
|
if *s.RemoteImageProxyOptions == "" {
|
2019-01-24 16:11:32 -04:00
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.atmos_camo_image_proxy_options.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return NewAppError("Config.IsValid", "model.config.is_valid.image_proxy_type.app_error", nil, "", http.StatusBadRequest)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-03 14:45:36 -04:00
|
|
|
func (o *Config) GetSanitizeOptions() map[string]bool {
|
2015-12-07 15:13:31 -08:00
|
|
|
options := map[string]bool{}
|
2019-01-31 08:12:01 -05:00
|
|
|
options["fullname"] = *o.PrivacySettings.ShowFullName
|
|
|
|
|
options["email"] = *o.PrivacySettings.ShowEmailAddress
|
2015-12-07 15:13:31 -08:00
|
|
|
|
|
|
|
|
return options
|
|
|
|
|
}
|
2016-05-03 14:45:36 -04:00
|
|
|
|
|
|
|
|
func (o *Config) Sanitize() {
|
2021-01-25 11:15:17 +01:00
|
|
|
if o.LdapSettings.BindPassword != nil && *o.LdapSettings.BindPassword != "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
*o.LdapSettings.BindPassword = FakeSetting
|
2016-05-03 14:45:36 -04:00
|
|
|
}
|
|
|
|
|
|
2021-10-28 14:07:35 +02:00
|
|
|
if o.FileSettings.PublicLinkSalt != nil {
|
|
|
|
|
*o.FileSettings.PublicLinkSalt = FakeSetting
|
|
|
|
|
}
|
2019-06-25 15:36:26 +01:00
|
|
|
|
2021-10-28 14:07:35 +02:00
|
|
|
if o.FileSettings.AmazonS3SecretAccessKey != nil && *o.FileSettings.AmazonS3SecretAccessKey != "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
*o.FileSettings.AmazonS3SecretAccessKey = FakeSetting
|
2016-05-03 14:45:36 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if o.EmailSettings.SMTPPassword != nil && *o.EmailSettings.SMTPPassword != "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
*o.EmailSettings.SMTPPassword = FakeSetting
|
2019-06-25 15:36:26 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-28 14:07:35 +02:00
|
|
|
if o.GitLabSettings.Secret != nil && *o.GitLabSettings.Secret != "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
*o.GitLabSettings.Secret = FakeSetting
|
2016-05-03 14:45:36 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if o.GoogleSettings.Secret != nil && *o.GoogleSettings.Secret != "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
*o.GoogleSettings.Secret = FakeSetting
|
2020-08-31 02:18:39 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if o.Office365Settings.Secret != nil && *o.Office365Settings.Secret != "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
*o.Office365Settings.Secret = FakeSetting
|
2020-08-31 02:18:39 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 11:15:17 +01:00
|
|
|
if o.OpenIdSettings.Secret != nil && *o.OpenIdSettings.Secret != "" {
|
2021-07-12 20:05:36 +02:00
|
|
|
*o.OpenIdSettings.Secret = FakeSetting
|
2020-12-08 19:58:37 -07:00
|
|
|
}
|
|
|
|
|
|
2021-10-28 14:07:35 +02:00
|
|
|
if o.SqlSettings.DataSource != nil {
|
|
|
|
|
*o.SqlSettings.DataSource = FakeSetting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if o.SqlSettings.AtRestEncryptKey != nil {
|
|
|
|
|
*o.SqlSettings.AtRestEncryptKey = FakeSetting
|
|
|
|
|
}
|
2016-05-03 14:45:36 -04:00
|
|
|
|
2021-10-28 14:07:35 +02:00
|
|
|
if o.ElasticsearchSettings.Password != nil {
|
|
|
|
|
*o.ElasticsearchSettings.Password = FakeSetting
|
|
|
|
|
}
|
2019-06-25 15:36:26 +01:00
|
|
|
|
2016-05-03 14:45:36 -04:00
|
|
|
for i := range o.SqlSettings.DataSourceReplicas {
|
2021-07-12 20:05:36 +02:00
|
|
|
o.SqlSettings.DataSourceReplicas[i] = FakeSetting
|
2016-05-03 14:45:36 -04:00
|
|
|
}
|
2017-05-01 05:19:58 +01:00
|
|
|
|
|
|
|
|
for i := range o.SqlSettings.DataSourceSearchReplicas {
|
2021-07-12 20:05:36 +02:00
|
|
|
o.SqlSettings.DataSourceSearchReplicas[i] = FakeSetting
|
2017-05-01 05:19:58 +01:00
|
|
|
}
|
2020-08-20 09:01:22 -04:00
|
|
|
|
2021-10-28 14:07:35 +02:00
|
|
|
if o.MessageExportSettings.GlobalRelaySettings != nil &&
|
|
|
|
|
o.MessageExportSettings.GlobalRelaySettings.SMTPPassword != nil &&
|
|
|
|
|
*o.MessageExportSettings.GlobalRelaySettings.SMTPPassword != "" {
|
2021-08-12 11:49:16 +02:00
|
|
|
*o.MessageExportSettings.GlobalRelaySettings.SMTPPassword = FakeSetting
|
2020-08-20 09:01:22 -04:00
|
|
|
}
|
2020-08-31 02:18:39 -04:00
|
|
|
|
2021-08-16 19:46:44 +02:00
|
|
|
if o.ServiceSettings.GfycatAPISecret != nil && *o.ServiceSettings.GfycatAPISecret != "" {
|
|
|
|
|
*o.ServiceSettings.GfycatAPISecret = FakeSetting
|
2020-08-31 02:18:39 -04:00
|
|
|
}
|
2020-10-29 15:54:39 -07:00
|
|
|
|
2021-10-28 14:07:35 +02:00
|
|
|
if o.ServiceSettings.SplitKey != nil {
|
|
|
|
|
*o.ServiceSettings.SplitKey = FakeSetting
|
|
|
|
|
}
|
2016-05-03 14:45:36 -04:00
|
|
|
}
|
2020-09-30 21:09:56 +02:00
|
|
|
|
|
|
|
|
// structToMapFilteredByTag converts a struct into a map removing those fields that has the tag passed
|
|
|
|
|
// as argument
|
|
|
|
|
func structToMapFilteredByTag(t interface{}, typeOfTag, filterTag string) map[string]interface{} {
|
|
|
|
|
defer func() {
|
|
|
|
|
if r := recover(); r != nil {
|
2021-01-04 17:02:34 +03:00
|
|
|
mlog.Warn("Panicked in structToMapFilteredByTag. This should never happen.", mlog.Any("recover", r))
|
2020-09-30 21:09:56 +02:00
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
val := reflect.ValueOf(t)
|
|
|
|
|
elemField := reflect.TypeOf(t)
|
|
|
|
|
|
|
|
|
|
if val.Kind() != reflect.Struct {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out := map[string]interface{}{}
|
|
|
|
|
|
|
|
|
|
for i := 0; i < val.NumField(); i++ {
|
|
|
|
|
field := val.Field(i)
|
|
|
|
|
|
|
|
|
|
structField := elemField.Field(i)
|
|
|
|
|
tagPermissions := strings.Split(structField.Tag.Get(typeOfTag), ",")
|
|
|
|
|
if isTagPresent(filterTag, tagPermissions) {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var value interface{}
|
|
|
|
|
|
|
|
|
|
switch field.Kind() {
|
|
|
|
|
case reflect.Struct:
|
|
|
|
|
value = structToMapFilteredByTag(field.Interface(), typeOfTag, filterTag)
|
|
|
|
|
case reflect.Ptr:
|
|
|
|
|
indirectType := field.Elem()
|
|
|
|
|
if indirectType.Kind() == reflect.Struct {
|
|
|
|
|
value = structToMapFilteredByTag(indirectType.Interface(), typeOfTag, filterTag)
|
|
|
|
|
} else if indirectType.Kind() != reflect.Invalid {
|
|
|
|
|
value = indirectType.Interface()
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
value = field.Interface()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out[val.Type().Field(i).Name] = value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func isTagPresent(tag string, tags []string) bool {
|
|
|
|
|
for _, val := range tags {
|
|
|
|
|
tagValue := strings.TrimSpace(val)
|
|
|
|
|
if tagValue != "" && tagValue == tag {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-07-21 13:15:29 +05:30
|
|
|
|
|
|
|
|
// Copied from https://golang.org/src/net/dnsclient.go#L119
|
|
|
|
|
func isDomainName(s string) bool {
|
|
|
|
|
// See RFC 1035, RFC 3696.
|
|
|
|
|
// Presentation format has dots before every label except the first, and the
|
|
|
|
|
// terminal empty label is optional here because we assume fully-qualified
|
|
|
|
|
// (absolute) input. We must therefore reserve space for the first and last
|
|
|
|
|
// labels' length octets in wire format, where they are necessary and the
|
|
|
|
|
// maximum total length is 255.
|
|
|
|
|
// So our _effective_ maximum is 253, but 254 is not rejected if the last
|
|
|
|
|
// character is a dot.
|
|
|
|
|
l := len(s)
|
|
|
|
|
if l == 0 || l > 254 || l == 254 && s[l-1] != '.' {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
last := byte('.')
|
|
|
|
|
ok := false // Ok once we've seen a letter.
|
|
|
|
|
partlen := 0
|
|
|
|
|
for i := 0; i < len(s); i++ {
|
|
|
|
|
c := s[i]
|
|
|
|
|
switch {
|
|
|
|
|
default:
|
|
|
|
|
return false
|
|
|
|
|
case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_':
|
|
|
|
|
ok = true
|
|
|
|
|
partlen++
|
|
|
|
|
case '0' <= c && c <= '9':
|
|
|
|
|
// fine
|
|
|
|
|
partlen++
|
|
|
|
|
case c == '-':
|
|
|
|
|
// Byte before dash cannot be dot.
|
|
|
|
|
if last == '.' {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
partlen++
|
|
|
|
|
case c == '.':
|
|
|
|
|
// Byte before dot cannot be dot, dash.
|
|
|
|
|
if last == '.' || last == '-' {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if partlen > 63 || partlen == 0 {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
partlen = 0
|
|
|
|
|
}
|
|
|
|
|
last = c
|
|
|
|
|
}
|
|
|
|
|
if last == '-' || partlen > 63 {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func isSafeLink(link *string) bool {
|
|
|
|
|
if link != nil {
|
2021-08-16 19:46:44 +02:00
|
|
|
if IsValidHTTPURL(*link) {
|
2021-07-21 13:15:29 +05:30
|
|
|
return true
|
|
|
|
|
} else if strings.HasPrefix(*link, "/") {
|
|
|
|
|
return true
|
|
|
|
|
} else {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
}
|