Gin upgrade (#1174)

* upgrade gin / gin-jwt, and add a new 'trusted_proxies' option to provide trusted CIDRs
This commit is contained in:
Thibault "bui" Koechlin 2022-01-17 17:18:12 +01:00 committed by GitHub
parent 6e92da76ad
commit 40ed810c0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 91 additions and 64 deletions

View file

@ -90,6 +90,7 @@ type LocalApiServerCfg struct {
Profiles []*ProfileCfg `yaml:"-"`
LogLevel *log.Level `yaml:"log_level"`
UseForwardedForHeaders bool `yaml:"use_forwarded_for_headers,omitempty"`
TrustedProxies *[]string `yaml:"trusted_proxies,omitempty"`
CompressLogs *bool `yaml:"-"`
LogMaxSize int `yaml:"-"`
LogMaxAge int `yaml:"-"`
@ -112,7 +113,12 @@ func (c *Config) LoadAPIServer() error {
c.API.Server.LogMaxSize = c.Common.LogMaxSize
c.API.Server.LogMaxAge = c.Common.LogMaxAge
c.API.Server.LogMaxFiles = c.Common.LogMaxFiles
if c.API.Server.UseForwardedForHeaders && c.API.Server.TrustedProxies == nil {
c.API.Server.TrustedProxies = &[]string{"0.0.0.0/0"}
}
if c.API.Server.TrustedProxies != nil {
c.API.Server.UseForwardedForHeaders = true
}
if err := c.API.Server.LoadProfiles(); err != nil {
return errors.Wrap(err, "while loading profiles for LAPI")
}