mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-18 18:18:23 -05:00
MM-18062 - add support for Office365Settings Directory (tenant) Id (#13737)
* MM-18062 add directory id field to O365 settings
This commit is contained in:
parent
dd1c8c22dc
commit
ed52acd89c
3 changed files with 63 additions and 6 deletions
|
|
@ -1326,7 +1326,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||
samlEnabled := *config.SamlSettings.Enable
|
||||
gitlabEnabled := *config.GetSSOService("gitlab").Enable
|
||||
googleEnabled := *config.GetSSOService("google").Enable
|
||||
office365Enabled := *config.GetSSOService("office365").Enable
|
||||
office365Enabled := *config.Office365Settings.Enable
|
||||
|
||||
if samlEnabled || gitlabEnabled || googleEnabled || office365Enabled {
|
||||
c.Err = model.NewAppError("login", "api.user.login.invalid_credentials_sso", nil, "", http.StatusUnauthorized)
|
||||
|
|
|
|||
|
|
@ -882,6 +882,63 @@ func (s *SSOSettings) setDefaults(scope, authEndpoint, tokenEndpoint, userApiEnd
|
|||
}
|
||||
}
|
||||
|
||||
type Office365Settings struct {
|
||||
Enable *bool
|
||||
Secret *string
|
||||
Id *string
|
||||
Scope *string
|
||||
AuthEndpoint *string
|
||||
TokenEndpoint *string
|
||||
UserApiEndpoint *string
|
||||
DirectoryId *string
|
||||
}
|
||||
|
||||
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 {
|
||||
s.Scope = NewString(OFFICE365_SETTINGS_DEFAULT_SCOPE)
|
||||
}
|
||||
|
||||
if s.AuthEndpoint == nil {
|
||||
s.AuthEndpoint = NewString(OFFICE365_SETTINGS_DEFAULT_AUTH_ENDPOINT)
|
||||
}
|
||||
|
||||
if s.TokenEndpoint == nil {
|
||||
s.TokenEndpoint = NewString(OFFICE365_SETTINGS_DEFAULT_TOKEN_ENDPOINT)
|
||||
}
|
||||
|
||||
if s.UserApiEndpoint == nil {
|
||||
s.UserApiEndpoint = NewString(OFFICE365_SETTINGS_DEFAULT_USER_API_ENDPOINT)
|
||||
}
|
||||
|
||||
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
|
||||
ssoSettings.AuthEndpoint = s.AuthEndpoint
|
||||
ssoSettings.TokenEndpoint = s.TokenEndpoint
|
||||
ssoSettings.UserApiEndpoint = s.UserApiEndpoint
|
||||
return &ssoSettings
|
||||
}
|
||||
|
||||
type SqlSettings struct {
|
||||
DriverName *string `restricted:"true"`
|
||||
DataSource *string `restricted:"true"`
|
||||
|
|
@ -2511,7 +2568,7 @@ type Config struct {
|
|||
ThemeSettings ThemeSettings
|
||||
GitLabSettings SSOSettings
|
||||
GoogleSettings SSOSettings
|
||||
Office365Settings SSOSettings
|
||||
Office365Settings Office365Settings
|
||||
LdapSettings LdapSettings
|
||||
ComplianceSettings ComplianceSettings
|
||||
LocalizationSettings LocalizationSettings
|
||||
|
|
@ -2551,7 +2608,7 @@ func (o *Config) GetSSOService(service string) *SSOSettings {
|
|||
case SERVICE_GOOGLE:
|
||||
return &o.GoogleSettings
|
||||
case SERVICE_OFFICE365:
|
||||
return &o.Office365Settings
|
||||
return o.Office365Settings.SSOSettings()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -2586,7 +2643,7 @@ func (o *Config) SetDefaults() {
|
|||
o.FileSettings.SetDefaults(isUpdate)
|
||||
o.EmailSettings.SetDefaults(isUpdate)
|
||||
o.PrivacySettings.setDefaults()
|
||||
o.Office365Settings.setDefaults(OFFICE365_SETTINGS_DEFAULT_SCOPE, OFFICE365_SETTINGS_DEFAULT_AUTH_ENDPOINT, OFFICE365_SETTINGS_DEFAULT_TOKEN_ENDPOINT, OFFICE365_SETTINGS_DEFAULT_USER_API_ENDPOINT)
|
||||
o.Office365Settings.setDefaults()
|
||||
o.GitLabSettings.setDefaults("", "", "", "")
|
||||
o.GoogleSettings.setDefaults(GOOGLE_SETTINGS_DEFAULT_SCOPE, GOOGLE_SETTINGS_DEFAULT_AUTH_ENDPOINT, GOOGLE_SETTINGS_DEFAULT_TOKEN_ENDPOINT, GOOGLE_SETTINGS_DEFAULT_USER_API_ENDPOINT)
|
||||
o.ServiceSettings.SetDefaults(isUpdate)
|
||||
|
|
@ -2687,7 +2744,6 @@ func (o *Config) IsValid() *AppError {
|
|||
if err := o.ImageProxySettings.isValid(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -243,7 +243,8 @@
|
|||
"Scope": "User.Read",
|
||||
"AuthEndpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
||||
"TokenEndpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token",
|
||||
"UserApiEndpoint": "https://graph.microsoft.com/v1.0/me"
|
||||
"UserApiEndpoint": "https://graph.microsoft.com/v1.0/me",
|
||||
"DirectoryId": ""
|
||||
},
|
||||
"LdapSettings": {
|
||||
"Enable": false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue