mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
This reverts commit 3fcecd521a.
This commit is contained in:
committed by
GitHub
parent
daa6c4172a
commit
2999009052
@@ -378,10 +378,6 @@ func (a *App) trackConfig() {
|
||||
"isdefault_login_button_text_color": isDefault(*cfg.EmailSettings.LoginButtonTextColor, ""),
|
||||
})
|
||||
|
||||
a.SendDiagnostic(TRACK_CONFIG_EXTENSION, map[string]interface{}{
|
||||
"enable_experimental_extensions": *cfg.ExtensionSettings.EnableExperimentalExtensions,
|
||||
})
|
||||
|
||||
a.SendDiagnostic(TRACK_CONFIG_RATE, map[string]interface{}{
|
||||
"enable_rate_limiter": *cfg.RateLimitSettings.Enable,
|
||||
"vary_by_remote_address": *cfg.RateLimitSettings.VaryByRemoteAddr,
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
)
|
||||
|
||||
func (a *App) isExtensionSupportEnabled() bool {
|
||||
return *a.Config().ExtensionSettings.EnableExperimentalExtensions
|
||||
}
|
||||
|
||||
func (a *App) isExtensionValid(extensionId string) bool {
|
||||
extensionIsValid := false
|
||||
extensionIDs := a.Config().ExtensionSettings.AllowedExtensionsIDs
|
||||
|
||||
for _, id := range extensionIDs {
|
||||
if extensionId == id {
|
||||
extensionIsValid = true
|
||||
}
|
||||
}
|
||||
|
||||
return extensionIsValid
|
||||
}
|
||||
|
||||
func (a *App) ValidateExtension(extensionId string) *model.AppError {
|
||||
enabled := a.isExtensionSupportEnabled()
|
||||
if !enabled {
|
||||
return model.NewAppError("completeSaml", "api.user.saml.extension_unsupported", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
valid := a.isExtensionValid(extensionId)
|
||||
if !valid {
|
||||
params := map[string]interface{}{"ExtensionId": extensionId}
|
||||
return model.NewAppError("completeSaml", "api.user.saml.invalid_extension", params, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendMessageToExtension(w http.ResponseWriter, extensionId string, token string) *model.AppError {
|
||||
var err error
|
||||
var t *template.Template
|
||||
if len(extensionId) == 0 {
|
||||
return model.NewAppError("completeSaml", "api.user.saml.extension_id.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
t = template.New("complete_saml_extension_body")
|
||||
t, err = t.ParseFiles("templates/complete_saml_extension_body.html")
|
||||
|
||||
if err != nil {
|
||||
return model.NewAppError("completeSaml", "api.user.saml.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
var errMessage string
|
||||
if len(token) == 0 {
|
||||
loginError := model.NewAppError("completeSaml", "api.user.saml.app_error", nil, "", http.StatusInternalServerError)
|
||||
errMessage = loginError.Message
|
||||
}
|
||||
|
||||
data := struct {
|
||||
ExtensionId string
|
||||
Token string
|
||||
Error string
|
||||
}{
|
||||
extensionId,
|
||||
token,
|
||||
errMessage,
|
||||
}
|
||||
|
||||
if err := t.Execute(w, data); err != nil {
|
||||
return model.NewAppError("completeSaml", "api.user.saml.app_error", nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -203,10 +203,6 @@
|
||||
"LoginButtonBorderColor": "",
|
||||
"LoginButtonTextColor": ""
|
||||
},
|
||||
"ExtensionSettings": {
|
||||
"EnableExperimentalExtensions": false,
|
||||
"AllowedExtensionsIDs": []
|
||||
},
|
||||
"RateLimitSettings": {
|
||||
"Enable": false,
|
||||
"PerSec": 10,
|
||||
|
||||
@@ -979,21 +979,6 @@ func (s *EmailSettings) SetDefaults() {
|
||||
}
|
||||
}
|
||||
|
||||
type ExtensionSettings struct {
|
||||
EnableExperimentalExtensions *bool
|
||||
AllowedExtensionsIDs []string
|
||||
}
|
||||
|
||||
func (s *ExtensionSettings) SetDefaults() {
|
||||
if s.EnableExperimentalExtensions == nil {
|
||||
s.EnableExperimentalExtensions = NewBool(false)
|
||||
}
|
||||
|
||||
if s.AllowedExtensionsIDs == nil {
|
||||
s.AllowedExtensionsIDs = []string{}
|
||||
}
|
||||
}
|
||||
|
||||
type RateLimitSettings struct {
|
||||
Enable *bool
|
||||
PerSec *int
|
||||
@@ -1933,7 +1918,6 @@ type Config struct {
|
||||
PasswordSettings PasswordSettings
|
||||
FileSettings FileSettings
|
||||
EmailSettings EmailSettings
|
||||
ExtensionSettings ExtensionSettings
|
||||
RateLimitSettings RateLimitSettings
|
||||
PrivacySettings PrivacySettings
|
||||
SupportSettings SupportSettings
|
||||
@@ -2029,7 +2013,6 @@ func (o *Config) SetDefaults() {
|
||||
o.MessageExportSettings.SetDefaults()
|
||||
o.TimezoneSettings.SetDefaults()
|
||||
o.DisplaySettings.SetDefaults()
|
||||
o.ExtensionSettings.SetDefaults()
|
||||
}
|
||||
|
||||
func (o *Config) IsValid() *AppError {
|
||||
|
||||
@@ -17,7 +17,6 @@ const (
|
||||
OAUTH_ACTION_EMAIL_TO_SSO = "email_to_sso"
|
||||
OAUTH_ACTION_SSO_TO_EMAIL = "sso_to_email"
|
||||
OAUTH_ACTION_MOBILE = "mobile"
|
||||
OAUTH_ACTION_CLIENT = "client"
|
||||
)
|
||||
|
||||
type OAuthApp struct {
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
{{define "complete_saml_extension_body"}}
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var extensionId = {{.ExtensionId}};
|
||||
|
||||
if (!extensionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
chrome.runtime.sendMessage(
|
||||
extensionId,
|
||||
{
|
||||
value: {{.Token}},
|
||||
error: {{.Error}}
|
||||
},
|
||||
function(response) {
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
Login Successful
|
||||
</body>
|
||||
</html>
|
||||
|
||||
{{end}}
|
||||
17
web/saml.go
17
web/saml.go
@@ -32,7 +32,6 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
action := r.URL.Query().Get("action")
|
||||
redirectTo := r.URL.Query().Get("redirect_to")
|
||||
extensionId := r.URL.Query().Get("extension_id")
|
||||
relayProps := map[string]string{}
|
||||
relayState := ""
|
||||
|
||||
@@ -48,15 +47,6 @@ func loginWithSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
relayProps["redirect_to"] = redirectTo
|
||||
}
|
||||
|
||||
if len(extensionId) != 0 {
|
||||
relayProps["extension_id"] = extensionId
|
||||
err := c.App.ValidateExtension(extensionId)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(relayProps) > 0 {
|
||||
relayState = b64.StdEncoding.EncodeToString([]byte(model.MapToJson(relayProps)))
|
||||
}
|
||||
@@ -152,13 +142,6 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
switch action {
|
||||
case model.OAUTH_ACTION_MOBILE:
|
||||
ReturnStatusOK(w)
|
||||
case model.OAUTH_ACTION_CLIENT:
|
||||
err = c.App.SendMessageToExtension(w, relayProps["extension_id"], c.App.Session.Token)
|
||||
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
case model.OAUTH_ACTION_EMAIL_TO_SSO:
|
||||
http.Redirect(w, r, c.GetSiteURLHeader()+"/login?extra=signin_change", http.StatusFound)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user