[MM-15639] Add config setting to explicitly define which IP headers are trusted (#10907)

* Add config setting to explicitly define which IP headers are trusted

* fix variable shadowing

* Optimize code flow; Add Ratelimit test for header set

* Extend Ratelimit tests

* Add additional unit tests

* Structured logging
Этот коммит содержится в:
Daniel Schalla
2019-05-24 20:22:13 +02:00
коммит произвёл GitHub
родитель e8af4872c6
Коммит 2d97f01781
11 изменённых файлов: 113 добавлений и 30 удалений

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

@@ -63,7 +63,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
)
c.App.T, _ = utils.GetTranslationsAndLocale(w, r)
c.App.RequestId = model.NewId()
c.App.IpAddress = utils.GetIpAddress(r)
c.App.IpAddress = utils.GetIpAddress(r, c.App.Config().ServiceSettings.TrustedProxyIPHeader)
c.App.UserAgent = r.UserAgent()
c.App.AcceptLanguage = r.Header.Get("Accept-Language")
c.Params = ParamsFromRequest(r)