Skip to content

Commit 3d01458

Browse files
committedJan 11, 2019
MM-13725 Fix client config overriding MFA enforcement set in limited config (mattermost#10095)
* Fix client config overriding MFA enforcement set in limited config * Add unit test
1 parent 92d71f4 commit 3d01458

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed
 

‎utils/config.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ func GenerateClientConfig(c *model.Config, diagnosticId string, license *model.L
592592
props["LdapNicknameAttributeSet"] = "false"
593593
props["LdapFirstNameAttributeSet"] = "false"
594594
props["LdapLastNameAttributeSet"] = "false"
595-
props["EnforceMultifactorAuthentication"] = "false"
596595
props["EnableCompliance"] = "false"
597596
props["EnableMobileFileDownload"] = "true"
598597
props["EnableMobileFileUpload"] = "true"
@@ -761,6 +760,8 @@ func GenerateLimitedClientConfig(c *model.Config, diagnosticId string, license *
761760
props["EnableCustomBrand"] = strconv.FormatBool(*c.TeamSettings.EnableCustomBrand)
762761
props["CustomBrandText"] = *c.TeamSettings.CustomBrandText
763762
props["CustomDescriptionText"] = *c.TeamSettings.CustomDescriptionText
763+
props["EnableMultifactorAuthentication"] = "false"
764+
props["EnforceMultifactorAuthentication"] = "false"
764765

765766
if license != nil {
766767
if *license.Features.LDAP {
@@ -773,6 +774,7 @@ func GenerateLimitedClientConfig(c *model.Config, diagnosticId string, license *
773774

774775
if *license.Features.MFA {
775776
props["EnableMultifactorAuthentication"] = strconv.FormatBool(*c.ServiceSettings.EnableMultifactorAuthentication)
777+
props["EnforceMultifactorAuthentication"] = strconv.FormatBool(*c.ServiceSettings.EnforceMultifactorAuthentication)
776778
}
777779

778780
if *license.Features.SAML {
@@ -795,10 +797,6 @@ func GenerateLimitedClientConfig(c *model.Config, diagnosticId string, license *
795797
props["EnableCustomTermsOfService"] = strconv.FormatBool(*c.SupportSettings.CustomTermsOfServiceEnabled)
796798
props["CustomTermsOfServiceReAcceptancePeriod"] = strconv.FormatInt(int64(*c.SupportSettings.CustomTermsOfServiceReAcceptancePeriod), 10)
797799
}
798-
799-
if *license.Features.MFA {
800-
props["EnforceMultifactorAuthentication"] = strconv.FormatBool(*c.ServiceSettings.EnforceMultifactorAuthentication)
801-
}
802800
}
803801

804802
return props

‎utils/config_test.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,10 @@ func TestGetClientConfig(t *testing.T) {
776776
"",
777777
nil,
778778
map[string]string{
779-
"DiagnosticId": "",
780-
"EmailNotificationContentsType": "full",
781-
"AllowCustomThemes": "true",
779+
"DiagnosticId": "",
780+
"EmailNotificationContentsType": "full",
781+
"AllowCustomThemes": "true",
782+
"EnforceMultifactorAuthentication": "false",
782783
},
783784
},
784785
{
@@ -826,6 +827,23 @@ func TestGetClientConfig(t *testing.T) {
826827
"AllowCustomThemes": "false",
827828
},
828829
},
830+
{
831+
"licensed for enforcement",
832+
&model.Config{
833+
ServiceSettings: model.ServiceSettings{
834+
EnforceMultifactorAuthentication: bToP(true),
835+
},
836+
},
837+
"tag1",
838+
&model.License{
839+
Features: &model.Features{
840+
MFA: bToP(true),
841+
},
842+
},
843+
map[string]string{
844+
"EnforceMultifactorAuthentication": "true",
845+
},
846+
},
829847
}
830848

831849
for _, testCase := range testCases {

0 commit comments

Comments
 (0)
Failed to load comments.