Tweak WebSocket header-processing (#6929)

* fix

* consolidate code
Этот коммит содержится в:
Chris
2017-07-13 14:02:33 -07:00
коммит произвёл Christopher Speller
родитель a1f17c1f84
Коммит 5c3c909c85
3 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@@ -362,6 +362,15 @@ func TestWebsocketOriginSecurity(t *testing.T) {
t.Fatal("Should have errored because Origin contain AllowCorsFrom")
}
// Should fail because non-matching CORS
*utils.Cfg.ServiceSettings.AllowCorsFrom = "http://www.good.com"
_, _, err = websocket.DefaultDialer.Dial(url+model.API_URL_SUFFIX_V3+"/users/websocket", http.Header{
"Origin": []string{"http://www.good.co"},
})
if err == nil {
t.Fatal("Should have errored because Origin does not match host! SECURITY ISSUE!")
}
*utils.Cfg.ServiceSettings.AllowCorsFrom = ""
}