summaryrefslogtreecommitdiffstats
path: root/model/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/config.go')
-rw-r--r--model/config.go156
1 files changed, 156 insertions, 0 deletions
diff --git a/model/config.go b/model/config.go
index a8c63b1eb..32994a279 100644
--- a/model/config.go
+++ b/model/config.go
@@ -227,6 +227,31 @@ type LocalizationSettings struct {
AvailableLocales *string
}
+type SamlSettings struct {
+ // Basic
+ Enable *bool
+ Verify *bool
+ Encrypt *bool
+
+ IdpUrl *string
+ IdpDescriptorUrl *string
+ AssertionConsumerServiceURL *string
+
+ IdpCertificateFile *string
+ PublicCertificateFile *string
+ PrivateKeyFile *string
+
+ // User Mapping
+ FirstNameAttribute *string
+ LastNameAttribute *string
+ EmailAttribute *string
+ UsernameAttribute *string
+ NicknameAttribute *string
+ LocaleAttribute *string
+
+ LoginButtonText *string
+}
+
type Config struct {
ServiceSettings ServiceSettings
TeamSettings TeamSettings
@@ -242,6 +267,7 @@ type Config struct {
LdapSettings LdapSettings
ComplianceSettings ComplianceSettings
LocalizationSettings LocalizationSettings
+ SamlSettings SamlSettings
}
func (o *Config) ToJson() string {
@@ -627,6 +653,86 @@ func (o *Config) SetDefaults() {
o.LocalizationSettings.AvailableLocales = new(string)
*o.LocalizationSettings.AvailableLocales = ""
}
+
+ if o.SamlSettings.Enable == nil {
+ o.SamlSettings.Enable = new(bool)
+ *o.SamlSettings.Enable = false
+ }
+
+ if o.SamlSettings.Verify == nil {
+ o.SamlSettings.Verify = new(bool)
+ *o.SamlSettings.Verify = false
+ }
+
+ if o.SamlSettings.Encrypt == nil {
+ o.SamlSettings.Encrypt = new(bool)
+ *o.SamlSettings.Encrypt = false
+ }
+
+ if o.SamlSettings.IdpUrl == nil {
+ o.SamlSettings.IdpUrl = new(string)
+ *o.SamlSettings.IdpUrl = ""
+ }
+
+ if o.SamlSettings.IdpDescriptorUrl == nil {
+ o.SamlSettings.IdpDescriptorUrl = new(string)
+ *o.SamlSettings.IdpDescriptorUrl = ""
+ }
+
+ if o.SamlSettings.IdpCertificateFile == nil {
+ o.SamlSettings.IdpCertificateFile = new(string)
+ *o.SamlSettings.IdpCertificateFile = ""
+ }
+
+ if o.SamlSettings.PublicCertificateFile == nil {
+ o.SamlSettings.PublicCertificateFile = new(string)
+ *o.SamlSettings.PublicCertificateFile = ""
+ }
+
+ if o.SamlSettings.PrivateKeyFile == nil {
+ o.SamlSettings.PrivateKeyFile = new(string)
+ *o.SamlSettings.PrivateKeyFile = ""
+ }
+
+ if o.SamlSettings.AssertionConsumerServiceURL == nil {
+ o.SamlSettings.AssertionConsumerServiceURL = new(string)
+ *o.SamlSettings.AssertionConsumerServiceURL = ""
+ }
+
+ if o.SamlSettings.LoginButtonText == nil || *o.SamlSettings.LoginButtonText == "" {
+ o.SamlSettings.LoginButtonText = new(string)
+ *o.SamlSettings.LoginButtonText = USER_AUTH_SERVICE_SAML_TEXT
+ }
+
+ if o.SamlSettings.FirstNameAttribute == nil {
+ o.SamlSettings.FirstNameAttribute = new(string)
+ *o.SamlSettings.FirstNameAttribute = ""
+ }
+
+ if o.SamlSettings.LastNameAttribute == nil {
+ o.SamlSettings.LastNameAttribute = new(string)
+ *o.SamlSettings.LastNameAttribute = ""
+ }
+
+ if o.SamlSettings.EmailAttribute == nil {
+ o.SamlSettings.EmailAttribute = new(string)
+ *o.SamlSettings.EmailAttribute = ""
+ }
+
+ if o.SamlSettings.UsernameAttribute == nil {
+ o.SamlSettings.UsernameAttribute = new(string)
+ *o.SamlSettings.UsernameAttribute = ""
+ }
+
+ if o.SamlSettings.NicknameAttribute == nil {
+ o.SamlSettings.NicknameAttribute = new(string)
+ *o.SamlSettings.NicknameAttribute = ""
+ }
+
+ if o.SamlSettings.LocaleAttribute == nil {
+ o.SamlSettings.LocaleAttribute = new(string)
+ *o.SamlSettings.LocaleAttribute = ""
+ }
}
func (o *Config) IsValid() *AppError {
@@ -749,6 +855,56 @@ func (o *Config) IsValid() *AppError {
}
}
+ if *o.SamlSettings.Enable {
+ if len(*o.SamlSettings.IdpUrl) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_url.app_error", nil, "")
+ }
+
+ if len(*o.SamlSettings.IdpDescriptorUrl) == 0 || !IsValidHttpUrl(*o.SamlSettings.IdpDescriptorUrl) {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_descriptor_url.app_error", nil, "")
+ }
+
+ if len(*o.SamlSettings.IdpCertificateFile) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_cert.app_error", nil, "")
+ }
+
+ if len(*o.SamlSettings.EmailAttribute) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "")
+ }
+
+ if len(*o.SamlSettings.UsernameAttribute) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "")
+ }
+
+ if len(*o.SamlSettings.FirstNameAttribute) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_first_name_attribute.app_error", nil, "")
+ }
+
+ if len(*o.SamlSettings.LastNameAttribute) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_last_name_attribute.app_error", nil, "")
+ }
+
+ if *o.SamlSettings.Verify {
+ if len(*o.SamlSettings.AssertionConsumerServiceURL) == 0 || !IsValidHttpUrl(*o.SamlSettings.AssertionConsumerServiceURL) {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "")
+ }
+ }
+
+ if *o.SamlSettings.Encrypt {
+ if len(*o.SamlSettings.PrivateKeyFile) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_private_key.app_error", nil, "")
+ }
+
+ if len(*o.SamlSettings.PublicCertificateFile) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_public_cert.app_error", nil, "")
+ }
+ }
+
+ if len(*o.SamlSettings.EmailAttribute) == 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "")
+ }
+ }
+
return nil
}