summaryrefslogtreecommitdiffstats
path: root/model/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/config.go')
-rw-r--r--model/config.go158
1 files changed, 158 insertions, 0 deletions
diff --git a/model/config.go b/model/config.go
new file mode 100644
index 000000000..31c2b16dc
--- /dev/null
+++ b/model/config.go
@@ -0,0 +1,158 @@
+// 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 {
+ ListenAddress string
+ MaximumLoginAttempts int
+ SegmentDeveloperKey string
+ GoogleDeveloperKey string
+ EnableOAuthServiceProvider bool
+ EnableIncomingWebhooks bool
+ EnableTesting bool
+}
+
+type SSOSettings struct {
+ Enable 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 {
+ EnableConsole bool
+ ConsoleLevel string
+ EnableFile bool
+ FileLevel string
+ FileFormat string
+ FileLocation string
+}
+
+type FileSettings struct {
+ DriverName string
+ Directory string
+ EnablePublicLink bool
+ PublicLinkSalt string
+ 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 {
+ EnableSignUpWithEmail bool
+ SendEmailNotifications bool
+ RequireEmailVerification bool
+ FeedbackName string
+ FeedbackEmail string
+ SMTPUsername string
+ SMTPPassword string
+ SMTPServer string
+ SMTPPort string
+ ConnectionSecurity string
+ InviteSalt string
+ PasswordResetSalt 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
+ EnableTeamCreation bool
+ EnableUserCreation bool
+ RestrictCreationToDomains string
+}
+
+type Config struct {
+ ServiceSettings ServiceSettings
+ TeamSettings TeamSettings
+ SqlSettings SqlSettings
+ LogSettings LogSettings
+ FileSettings FileSettings
+ 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
+ }
+}