mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-24 16:05:00 +08:00
Add siteURL to WS origin check (#9183)
* Add siteURL to WS origin check * Handle subpath * Only add site URL if not *
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -248,6 +249,14 @@ func (a *App) StopServer() {
|
||||
|
||||
func (a *App) OriginChecker() func(*http.Request) bool {
|
||||
if allowed := *a.Config().ServiceSettings.AllowCorsFrom; allowed != "" {
|
||||
if allowed != "*" {
|
||||
siteURL, err := url.Parse(*a.Config().ServiceSettings.SiteURL)
|
||||
if err == nil {
|
||||
siteURL.Path = ""
|
||||
allowed += " " + siteURL.String()
|
||||
}
|
||||
}
|
||||
|
||||
return utils.OriginChecker(allowed)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user