mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 08:19:23 +02:00
config: do not add route headers to global map (#4630)
config: do not add route headers to global map (#4629) Currently the GetSetResponseHeadersForPolicy() method may add entries to the global SetResponseHeaders map, which can lead to one route's headers being applied to other routes. Instead, make a copy of the SetResponseHeaders map before adding any route-specific response header entries. Add additional unit tests for GetSetResponseHeaders() and GetSetResponseHeadersForPolicy(). Co-authored-by: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com>
This commit is contained in:
parent
9f56ab2b00
commit
c32005d0fe
2 changed files with 62 additions and 3 deletions
|
@ -1121,9 +1121,12 @@ func (o *Options) GetSetResponseHeaders() map[string]string {
|
|||
|
||||
// GetSetResponseHeadersForPolicy gets the SetResponseHeaders for a policy.
|
||||
func (o *Options) GetSetResponseHeadersForPolicy(policy *Policy) map[string]string {
|
||||
hdrs := o.SetResponseHeaders
|
||||
if hdrs == nil {
|
||||
hdrs = make(map[string]string)
|
||||
hdrs := make(map[string]string)
|
||||
for k, v := range o.SetResponseHeaders {
|
||||
hdrs[k] = v
|
||||
}
|
||||
|
||||
if o.SetResponseHeaders == nil {
|
||||
for k, v := range defaultSetResponseHeaders {
|
||||
hdrs[k] = v
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue