Commit d1cccd34 authored by Stelios Milidonis's avatar Stelios Milidonis

release 5.22

parent 55771467
Pipeline #10206 failed with stage
in 0 seconds
......@@ -41,6 +41,9 @@ func TestGetConfig(t *testing.T) {
if *cfg.GitLabSettings.Secret != model.FAKE_SETTING && len(*cfg.GitLabSettings.Secret) != 0 {
require.FailNow(t, "did not sanitize properly")
}
if *cfg.PhabricatorSettings.Secret != model.FAKE_SETTING && len(*cfg.PhabricatorSettings.Secret) != 0 {
require.FailNow(t, "did not sanitize properly")
}
require.Equal(t, model.FAKE_SETTING, *cfg.SqlSettings.DataSource, "did not sanitize properly")
require.Equal(t, model.FAKE_SETTING, *cfg.SqlSettings.AtRestEncryptKey, "did not sanitize properly")
if !strings.Contains(strings.Join(cfg.SqlSettings.DataSourceReplicas, " "), model.FAKE_SETTING) && len(cfg.SqlSettings.DataSourceReplicas) != 0 {
......
......@@ -467,6 +467,7 @@ func (a *App) trackConfig() {
a.SendDiagnostic(TRACK_CONFIG_OAUTH, map[string]interface{}{
"enable_gitlab": cfg.GitLabSettings.Enable,
"enable_phabricator": cfg.PhabricatorSettings.Enable,
"enable_google": cfg.GoogleSettings.Enable,
"enable_office365": cfg.Office365Settings.Enable,
})
......
......@@ -18,6 +18,7 @@ import (
"github.com/mattermost/mattermost-server/v5/einterfaces"
"github.com/mattermost/mattermost-server/v5/model"
oauthgitlab "github.com/mattermost/mattermost-server/v5/model/gitlab"
oauthphabricato "github.com/mattermost/mattermost-server/v5/model/phabricator"
)
func TestIsUsernameTaken(t *testing.T) {
......
......@@ -28,7 +28,7 @@ else
env GOOS=windows GOARCH=amd64 $(GO) build -o $(GOBIN)/windows_amd64 $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./...
endif
build: build-linux build-windows build-osx
build: build-linux
build-client:
@echo Building mattermost web app
......@@ -95,71 +95,71 @@ endif
@# Make osx package
@# Copy binary
ifeq ($(BUILDER_GOOS_GOARCH),"darwin_amd64")
cp $(GOBIN)/mattermost $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOBIN)/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled
else
cp $(GOBIN)/darwin_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/darwin_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
endif
MMCTL_FILE="darwin_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(MMCTL_REL_TO_DOWNLOAD)/$$MMCTL_FILE && tar -xvf $$MMCTL_FILE -C $(DIST_PATH)/bin && rm $$MMCTL_FILE
@# Prepackage plugins
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
ARCH="osx-amd64"; \
cp tmpprepackaged/$$plugin_package-$$ARCH.tar.gz $(DIST_PATH)/prepackaged_plugins; \
cp tmpprepackaged/$$plugin_package-$$ARCH.tar.gz.sig $(DIST_PATH)/prepackaged_plugins; \
HAS_ARCH=`tar -tf $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz | grep -oE "dist/plugin-.*"`; \
if [ "$$HAS_ARCH" != "dist/plugin-darwin-amd64" ]; then \
echo "Contains $$HAS_ARCH in $$plugin_package-$$ARCH.tar.gz but needs dist/plugin-darwin-amd64"; \
exit 1; \
fi; \
gpg --verify $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz.sig $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz; \
if [ $$? -ne 0 ]; then \
echo "Failed to verify $$plugin_package-$$ARCH.tar.gz|$$plugin_package-$$ARCH.tar.gz.sig"; \
exit 1; \
fi; \
done
@# Package
tar -C dist -czf $(DIST_PATH)-$(BUILD_TYPE_NAME)-osx-amd64.tar.gz mattermost
@# Cleanup
rm -f $(DIST_PATH)/bin/mattermost
rm -f $(DIST_PATH)/bin/platform
rm -f $(DIST_PATH)/bin/mmctl
rm -f $(DIST_PATH)/prepackaged_plugins/*
@# Make windows package
@# Copy binary
ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64")
cp $(GOBIN)/mattermost.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
cp $(GOBIN)/platform.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
else
cp $(GOBIN)/windows_amd64/mattermost.exe $(DIST_PATH)/bin # from cross-compiled bin dir
cp $(GOBIN)/windows_amd64/platform.exe $(DIST_PATH)/bin # from cross-compiled bin dir
endif
MMCTL_FILE="windows_amd64.zip" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(MMCTL_REL_TO_DOWNLOAD)/$$MMCTL_FILE && unzip -o $$MMCTL_FILE -d $(DIST_PATH)/bin && rm $$MMCTL_FILE
@# Prepackage plugins
@for plugin_package in $(PLUGIN_PACKAGES) ; do \
ARCH="windows-amd64"; \
cp tmpprepackaged/$$plugin_package-$$ARCH.tar.gz $(DIST_PATH)/prepackaged_plugins; \
cp tmpprepackaged/$$plugin_package-$$ARCH.tar.gz.sig $(DIST_PATH)/prepackaged_plugins; \
HAS_ARCH=`tar -tf $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz | grep -oE "dist/plugin-.*"`; \
if [ "$$HAS_ARCH" != "dist/plugin-windows-amd64.exe" ]; then \
echo "Contains $$HAS_ARCH in $$plugin_package-$$ARCH.tar.gz but needs dist/plugin-windows-amd64.exe"; \
exit 1; \
fi; \
gpg --verify $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz.sig $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz; \
if [ $$? -ne 0 ]; then \
echo "Failed to verify $$plugin_package-$$ARCH.tar.gz|$$plugin_package-$$ARCH.tar.gz.sig"; \
exit 1; \
fi; \
done
@# Package
cd $(DIST_ROOT) && zip -9 -r -q -l mattermost-$(BUILD_TYPE_NAME)-windows-amd64.zip mattermost && cd ..
@# Cleanup
rm -f $(DIST_PATH)/bin/mattermost.exe
rm -f $(DIST_PATH)/bin/platform.exe
rm -f $(DIST_PATH)/bin/mmctl.exe
rm -f $(DIST_PATH)/prepackaged_plugins/*
# ifeq ($(BUILDER_GOOS_GOARCH),"darwin_amd64")
# cp $(GOBIN)/mattermost $(DIST_PATH)/bin # from native bin dir, not cross-compiled
# cp $(GOBIN)/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled
# else
# cp $(GOBIN)/darwin_amd64/mattermost $(DIST_PATH)/bin # from cross-compiled bin dir
# cp $(GOBIN)/darwin_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
# endif
# MMCTL_FILE="darwin_amd64.tar" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(MMCTL_REL_TO_DOWNLOAD)/$$MMCTL_FILE && tar -xvf $$MMCTL_FILE -C $(DIST_PATH)/bin && rm $$MMCTL_FILE
# @# Prepackage plugins
# @for plugin_package in $(PLUGIN_PACKAGES) ; do \
# ARCH="osx-amd64"; \
# cp tmpprepackaged/$$plugin_package-$$ARCH.tar.gz $(DIST_PATH)/prepackaged_plugins; \
# cp tmpprepackaged/$$plugin_package-$$ARCH.tar.gz.sig $(DIST_PATH)/prepackaged_plugins; \
# HAS_ARCH=`tar -tf $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz | grep -oE "dist/plugin-.*"`; \
# if [ "$$HAS_ARCH" != "dist/plugin-darwin-amd64" ]; then \
# echo "Contains $$HAS_ARCH in $$plugin_package-$$ARCH.tar.gz but needs dist/plugin-darwin-amd64"; \
# exit 1; \
# fi; \
# gpg --verify $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz.sig $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz; \
# if [ $$? -ne 0 ]; then \
# echo "Failed to verify $$plugin_package-$$ARCH.tar.gz|$$plugin_package-$$ARCH.tar.gz.sig"; \
# exit 1; \
# fi; \
# done
# @# Package
# tar -C dist -czf $(DIST_PATH)-$(BUILD_TYPE_NAME)-osx-amd64.tar.gz mattermost
# @# Cleanup
# rm -f $(DIST_PATH)/bin/mattermost
# rm -f $(DIST_PATH)/bin/platform
# rm -f $(DIST_PATH)/bin/mmctl
# rm -f $(DIST_PATH)/prepackaged_plugins/*
#
# @# Make windows package
# @# Copy binary
# ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64")
# cp $(GOBIN)/mattermost.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
# cp $(GOBIN)/platform.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
# else
# cp $(GOBIN)/windows_amd64/mattermost.exe $(DIST_PATH)/bin # from cross-compiled bin dir
# cp $(GOBIN)/windows_amd64/platform.exe $(DIST_PATH)/bin # from cross-compiled bin dir
# endif
# MMCTL_FILE="windows_amd64.zip" && curl -f -O -L https://github.com/mattermost/mmctl/releases/download/$(MMCTL_REL_TO_DOWNLOAD)/$$MMCTL_FILE && unzip -o $$MMCTL_FILE -d $(DIST_PATH)/bin && rm $$MMCTL_FILE
# @# Prepackage plugins
# @for plugin_package in $(PLUGIN_PACKAGES) ; do \
# ARCH="windows-amd64"; \
# cp tmpprepackaged/$$plugin_package-$$ARCH.tar.gz $(DIST_PATH)/prepackaged_plugins; \
# cp tmpprepackaged/$$plugin_package-$$ARCH.tar.gz.sig $(DIST_PATH)/prepackaged_plugins; \
# HAS_ARCH=`tar -tf $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz | grep -oE "dist/plugin-.*"`; \
# if [ "$$HAS_ARCH" != "dist/plugin-windows-amd64.exe" ]; then \
# echo "Contains $$HAS_ARCH in $$plugin_package-$$ARCH.tar.gz but needs dist/plugin-windows-amd64.exe"; \
# exit 1; \
# fi; \
# gpg --verify $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz.sig $(DIST_PATH)/prepackaged_plugins/$$plugin_package-$$ARCH.tar.gz; \
# if [ $$? -ne 0 ]; then \
# echo "Failed to verify $$plugin_package-$$ARCH.tar.gz|$$plugin_package-$$ARCH.tar.gz.sig"; \
# exit 1; \
# fi; \
# done
# @# Package
# cd $(DIST_ROOT) && zip -9 -r -q -l mattermost-$(BUILD_TYPE_NAME)-windows-amd64.zip mattermost && cd ..
# @# Cleanup
# rm -f $(DIST_PATH)/bin/mattermost.exe
# rm -f $(DIST_PATH)/bin/platform.exe
# rm -f $(DIST_PATH)/bin/mmctl.exe
# rm -f $(DIST_PATH)/prepackaged_plugins/*
@# Make linux package
@# Copy binary
......
......@@ -199,7 +199,7 @@ Examples:
Arguments:
from_auth:
The authentication service to migrate users accounts from.
Supported options: email, gitlab, ldap, saml.
Supported options: email, gitlab, phabricator, ldap, saml.
to_auth:
The authentication service to migrate users to.
......@@ -223,7 +223,7 @@ Examples:
Arguments:
from_auth:
The authentication service to migrate users accounts from.
Supported options: email, gitlab, ldap, saml.
Supported options: email, gitlab, phabricator, ldap, saml.
to_auth:
The authentication service to migrate users to.
......@@ -793,7 +793,7 @@ func migrateAuthToLdapCmdF(command *cobra.Command, args []string) error {
fromAuth := args[0]
matchField := args[2]
if len(fromAuth) == 0 || (fromAuth != "email" && fromAuth != "gitlab" && fromAuth != "saml") {
if len(fromAuth) == 0 || (fromAuth != "email" && fromAuth != "gitlab" && fromAuth != "phabricator" && fromAuth != "saml") {
return errors.New("Invalid from_auth argument")
}
......@@ -846,7 +846,7 @@ func migrateAuthToSamlCmdF(command *cobra.Command, args []string) error {
fromAuth := args[0]
if len(fromAuth) == 0 || (fromAuth != "email" && fromAuth != "gitlab" && fromAuth != "ldap") {
if len(fromAuth) == 0 || (fromAuth != "email" && fromAuth != "gitlab" && fromAuth != "phabricator" && fromAuth != "ldap") {
return errors.New("Invalid from_auth argument")
}
......
......@@ -10,6 +10,7 @@ import (
// Plugins
_ "github.com/mattermost/mattermost-server/v5/model/gitlab"
_ "github.com/mattermost/mattermost-server/model/phabricator"
// Enterprise Imports
_ "github.com/mattermost/mattermost-server/v5/imports"
......
......@@ -236,6 +236,7 @@ func GenerateLimitedClientConfig(c *model.Config, diagnosticID string, license *
props["EmailLoginButtonTextColor"] = *c.EmailSettings.LoginButtonTextColor
props["EnableSignUpWithGitLab"] = strconv.FormatBool(*c.GitLabSettings.Enable)
props["EnableSignUpWithPhabricator"] = strconv.FormatBool(*c.PhabricatorSettings.Enable)
props["TermsOfServiceLink"] = *c.SupportSettings.TermsOfServiceLink
props["PrivacyPolicyLink"] = *c.SupportSettings.PrivacyPolicyLink
......
This diff is collapsed.
File added
......@@ -42,6 +42,7 @@ const (
SERVICE_GITLAB = "gitlab"
SERVICE_GOOGLE = "google"
SERVICE_PHABRICATOR = "phabricator"
SERVICE_OFFICE365 = "office365"
GENERIC_NO_CHANNEL_NOTIFICATION = "generic_no_channel"
......@@ -54,6 +55,7 @@ const (
DIRECT_MESSAGE_TEAM = "team"
SHOW_USERNAME = "username"
SHOW_NICKNAME_USERNAME = "nickname_username"
SHOW_NICKNAME_FULLNAME = "nickname_full_name"
SHOW_FULLNAME = "full_name"
......@@ -2659,6 +2661,7 @@ type Config struct {
AnnouncementSettings AnnouncementSettings
ThemeSettings ThemeSettings
GitLabSettings SSOSettings
PhabricatorSettings SSOSettings
GoogleSettings SSOSettings
Office365Settings Office365Settings
LdapSettings LdapSettings
......@@ -2697,6 +2700,8 @@ func (o *Config) GetSSOService(service string) *SSOSettings {
switch service {
case SERVICE_GITLAB:
return &o.GitLabSettings
case SERVICE_PHABRICATOR:
return &o.PhabricatorSettings
case SERVICE_GOOGLE:
return &o.GoogleSettings
case SERVICE_OFFICE365:
......@@ -2737,6 +2742,7 @@ func (o *Config) SetDefaults() {
o.PrivacySettings.setDefaults()
o.Office365Settings.setDefaults()
o.GitLabSettings.setDefaults("", "", "", "")
o.PhabricatorSettings.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)
o.PasswordSettings.SetDefaults()
......@@ -2857,7 +2863,7 @@ func (s *TeamSettings) isValid() *AppError {
return NewAppError("Config.IsValid", "model.config.is_valid.restrict_direct_message.app_error", nil, "", http.StatusBadRequest)
}
if !(*s.TeammateNameDisplay == SHOW_FULLNAME || *s.TeammateNameDisplay == SHOW_NICKNAME_FULLNAME || *s.TeammateNameDisplay == SHOW_USERNAME) {
if !(*s.TeammateNameDisplay == SHOW_FULLNAME || *s.TeammateNameDisplay == SHOW_NICKNAME_FULLNAME || *s.TeammateNameDisplay == SHOW_NICKNAME_USERNAME || *s.TeammateNameDisplay == SHOW_USERNAME) {
return NewAppError("Config.IsValid", "model.config.is_valid.teammate_name_display.app_error", nil, "", http.StatusBadRequest)
}
......@@ -3331,6 +3337,10 @@ func (o *Config) Sanitize() {
*o.GitLabSettings.Secret = FAKE_SETTING
}
if len(*o.PhabricatorSettings.Secret) > 0 {
*o.PhabricatorSettings.Secret = FAKE_SETTING
}
*o.SqlSettings.DataSource = FAKE_SETTING
*o.SqlSettings.AtRestEncryptKey = FAKE_SETTING
......
package model
const (
USER_AUTH_SERVICE_PHABRICATOR = "phabricator"
)
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package oauthphabricator
import (
"encoding/json"
"io"
"strings"
"github.com/mattermost/mattermost-server/v5/einterfaces"
"github.com/mattermost/mattermost-server/v5/model"
)
type PhabricatorProvider struct {
}
type PhabricatorUser struct {
Id string `json:"phid"`
Username string `json:"userName"`
Email string `json:"primaryEmail"`
Name string `json:"realName"`
}
type PhabricatorConduitResult struct {
User PhabricatorUser `json:"result"`
}
func init() {
provider := &PhabricatorProvider{}
einterfaces.RegisterOauthProvider(model.USER_AUTH_SERVICE_PHABRICATOR, provider)
}
func userFromPhabricatorUser(phu *PhabricatorUser) *model.User {
user := &model.User{}
user.Username = model.CleanUsername(phu.Username)
splitName := strings.Split(phu.Name, " ")
if len(splitName) == 2 {
user.FirstName = splitName[0]
user.LastName = splitName[1]
} else if len(splitName) >= 2 {
user.FirstName = splitName[0]
user.LastName = strings.Join(splitName[1:], " ")
} else {
user.FirstName = phu.Name
}
strings.TrimSpace(user.Email)
user.Email = phu.Email
userId := phu.getAuthData()
user.AuthData = &userId
user.AuthService = model.USER_AUTH_SERVICE_PHABRICATOR
return user
}
func phabricatorUserFromJson(data io.Reader) *PhabricatorUser {
decoder := json.NewDecoder(data)
var phc PhabricatorConduitResult
err := decoder.Decode(&phc)
if err == nil {
return &phc.User
} else {
return nil
}
}
func (phu *PhabricatorUser) ToJson() string {
b, err := json.Marshal(phu)
if err != nil {
return ""
} else {
return string(b)
}
}
func (phu *PhabricatorUser) IsValid() bool {
if len(phu.Id) == 0 {
return false
}
if len(phu.Email) == 0 {
return false
}
return true
}
func (phu *PhabricatorUser) getAuthData() string {
return strings.Replace(phu.Id, "PHID-USER-", "PHID--", 1)
}
func (m *PhabricatorProvider) GetIdentifier() string {
return model.USER_AUTH_SERVICE_PHABRICATOR
}
func (m *PhabricatorProvider) GetUserFromJson(data io.Reader) *model.User {
phu := phabricatorUserFromJson(data)
if phu.IsValid() {
return userFromPhabricatorUser(phu)
}
return &model.User{}
}
func (m *PhabricatorProvider) GetAuthDataFromJson(data io.Reader) string {
phu := phabricatorUserFromJson(data)
if phu.IsValid() {
return phu.getAuthData()
}
return ""
}
......@@ -33,6 +33,7 @@ func (o *SwitchRequest) EmailToOAuth() bool {
return o.CurrentService == USER_AUTH_SERVICE_EMAIL &&
(o.NewService == USER_AUTH_SERVICE_SAML ||
o.NewService == USER_AUTH_SERVICE_GITLAB ||
o.NewService == USER_AUTH_SERVICE_PHABRICATOR ||
o.NewService == SERVICE_GOOGLE ||
o.NewService == SERVICE_OFFICE365)
}
......@@ -40,6 +41,7 @@ func (o *SwitchRequest) EmailToOAuth() bool {
func (o *SwitchRequest) OAuthToEmail() bool {
return (o.CurrentService == USER_AUTH_SERVICE_SAML ||
o.CurrentService == USER_AUTH_SERVICE_GITLAB ||
o.CurrentService == USER_AUTH_SERVICE_PHABRICATOR ||
o.CurrentService == SERVICE_GOOGLE ||
o.CurrentService == SERVICE_OFFICE365) && o.NewService == USER_AUTH_SERVICE_EMAIL
}
......
......@@ -570,19 +570,18 @@ func (u *User) GetFullName() string {
return ""
}
}
func (u *User) getDisplayName(baseName, nameFormat string) string {
displayName := baseName
if nameFormat == SHOW_NICKNAME_FULLNAME {
if nameFormat == SHOW_NICKNAME_FULLNAME || nameFormat == SHOW_NICKNAME_USERNAME {
if len(u.Nickname) > 0 {
displayName = u.Nickname
} else if fullName := u.GetFullName(); len(fullName) > 0 {
displayName = fullName
}
} else if nameFormat == SHOW_FULLNAME {
if fullName := u.GetFullName(); len(fullName) > 0 {
displayName = fullName
} else if fullName := u.GetFullName(); len(fullName) > 0 {
displayName = fullName
}
} else if nameFormat == SHOW_FULLNAME {
if fullName := u.GetFullName(); len(fullName) > 0 {
displayName = fullName
}
}
......@@ -662,7 +661,7 @@ func (u *User) IsSSOUser() bool {
}
func (u *User) IsOAuthUser() bool {
return u.AuthService == USER_AUTH_SERVICE_GITLAB
return u.AuthService == USER_AUTH_SERVICE_GITLAB || u.AuthService == USER_AUTH_SERVICE_PHABRICATOR
}
func (u *User) IsLDAPUser() bool {
......
......@@ -236,6 +236,16 @@
"TokenEndpoint": "https://www.googleapis.com/oauth2/v4/token",
"UserApiEndpoint": "https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses,nicknames,metadata"
},
"PhabricatorSettings": {
"Enable": false,
"Secret": "",
"Id": "",
"Scope": "",
"AuthEndpoint": "",
"TokenEndpoint": "",
"UserApiEndpoint": ""
},
"Office365Settings": {
"Enable": false,
"Secret": "",
......@@ -403,4 +413,4 @@
"CustomUrlSchemes": [],
"ExperimentalTimezone": false
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment