mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
163 lines
3.5 KiB
Go
163 lines
3.5 KiB
Go
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
const (
|
|
CONN_SECURITY_NONE = ""
|
|
CONN_SECURITY_TLS = "TLS"
|
|
CONN_SECURITY_STARTTLS = "STARTTLS"
|
|
|
|
IMAGE_DRIVER_LOCAL = "local"
|
|
IMAGE_DRIVER_S3 = "amazons3"
|
|
|
|
SERVICE_GITLAB = "gitlab"
|
|
)
|
|
|
|
type ServiceSettings struct {
|
|
Mode string
|
|
AllowTesting bool
|
|
UseSSL bool
|
|
Port string
|
|
Version string
|
|
InviteSalt string
|
|
PublicLinkSalt string
|
|
ResetSalt string
|
|
AnalyticsUrl string
|
|
AllowedLoginAttempts int
|
|
EnableOAuthServiceProvider bool
|
|
SegmentDeveloperKey string
|
|
GoogleDeveloperKey string
|
|
}
|
|
|
|
type SSOSettings struct {
|
|
Allow bool
|
|
Secret string
|
|
Id string
|
|
Scope string
|
|
AuthEndpoint string
|
|
TokenEndpoint string
|
|
UserApiEndpoint string
|
|
}
|
|
|
|
type SqlSettings struct {
|
|
DriverName string
|
|
DataSource string
|
|
DataSourceReplicas []string
|
|
MaxIdleConns int
|
|
MaxOpenConns int
|
|
Trace bool
|
|
AtRestEncryptKey string
|
|
}
|
|
|
|
type LogSettings struct {
|
|
ConsoleEnable bool
|
|
ConsoleLevel string
|
|
FileEnable bool
|
|
FileLevel string
|
|
FileFormat string
|
|
FileLocation string
|
|
}
|
|
|
|
type ImageSettings struct {
|
|
DriverName string
|
|
Directory string
|
|
EnablePublicLink bool
|
|
ThumbnailWidth uint
|
|
ThumbnailHeight uint
|
|
PreviewWidth uint
|
|
PreviewHeight uint
|
|
ProfileWidth uint
|
|
ProfileHeight uint
|
|
InitialFont string
|
|
AmazonS3AccessKeyId string
|
|
AmazonS3SecretAccessKey string
|
|
AmazonS3Bucket string
|
|
AmazonS3Region string
|
|
}
|
|
|
|
type EmailSettings struct {
|
|
AllowSignUpWithEmail bool
|
|
SendEmailNotifications bool
|
|
RequireEmailVerification bool
|
|
FeedbackName string
|
|
FeedbackEmail string
|
|
SMTPUsername string
|
|
SMTPPassword string
|
|
SMTPServer string
|
|
SMTPPort string
|
|
ConnectionSecurity string
|
|
|
|
// For Future Use
|
|
ApplePushServer string
|
|
ApplePushCertPublic string
|
|
ApplePushCertPrivate string
|
|
}
|
|
|
|
type RateLimitSettings struct {
|
|
EnableRateLimiter bool
|
|
PerSec int
|
|
MemoryStoreSize int
|
|
VaryByRemoteAddr bool
|
|
VaryByHeader string
|
|
}
|
|
|
|
type PrivacySettings struct {
|
|
ShowEmailAddress bool
|
|
ShowFullName bool
|
|
}
|
|
|
|
type TeamSettings struct {
|
|
SiteName string
|
|
MaxUsersPerTeam int
|
|
DefaultThemeColor string
|
|
EnableTeamCreation bool
|
|
EnableUserCreation bool
|
|
RestrictCreationToDomains string
|
|
}
|
|
|
|
type Config struct {
|
|
ServiceSettings ServiceSettings
|
|
TeamSettings TeamSettings
|
|
SqlSettings SqlSettings
|
|
LogSettings LogSettings
|
|
ImageSettings ImageSettings
|
|
EmailSettings EmailSettings
|
|
RateLimitSettings RateLimitSettings
|
|
PrivacySettings PrivacySettings
|
|
GitLabSettings SSOSettings
|
|
}
|
|
|
|
func (o *Config) ToJson() string {
|
|
b, err := json.Marshal(o)
|
|
if err != nil {
|
|
return ""
|
|
} else {
|
|
return string(b)
|
|
}
|
|
}
|
|
|
|
func (o *Config) GetSSOService(service string) *SSOSettings {
|
|
if service == SERVICE_GITLAB {
|
|
return &o.GitLabSettings
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func ConfigFromJson(data io.Reader) *Config {
|
|
decoder := json.NewDecoder(data)
|
|
var o Config
|
|
err := decoder.Decode(&o)
|
|
if err == nil {
|
|
return &o
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|