Add siteURL to WS origin check (#9183)
* Add siteURL to WS origin check * Handle subpath * Only add site URL if not *
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
de1ce2373d
Коммит
cff9ac0df8
@@ -11,6 +11,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -248,6 +249,14 @@ func (a *App) StopServer() {
|
|||||||
|
|
||||||
func (a *App) OriginChecker() func(*http.Request) bool {
|
func (a *App) OriginChecker() func(*http.Request) bool {
|
||||||
if allowed := *a.Config().ServiceSettings.AllowCorsFrom; allowed != "" {
|
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 utils.OriginChecker(allowed)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user