mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 16:30:17 +02:00
config: fix set_response_headers (#4026)
* config: fix set_response_headers * fix disabling to support route headers when global headers are disabled
This commit is contained in:
parent
b7d846464c
commit
681cf6fa27
6 changed files with 422 additions and 38 deletions
|
@ -1009,6 +1009,11 @@ func (o *Options) GetGoogleCloudServerlessAuthenticationServiceAccount() string
|
|||
|
||||
// GetSetResponseHeaders gets the SetResponseHeaders.
|
||||
func (o *Options) GetSetResponseHeaders(requireStrictTransportSecurity bool) map[string]string {
|
||||
return o.GetSetResponseHeadersForPolicy(nil, requireStrictTransportSecurity)
|
||||
}
|
||||
|
||||
// GetSetResponseHeadersForPolicy gets the SetResponseHeaders for a policy.
|
||||
func (o *Options) GetSetResponseHeadersForPolicy(policy *Policy, requireStrictTransportSecurity bool) map[string]string {
|
||||
hdrs := o.SetResponseHeaders
|
||||
if hdrs == nil {
|
||||
hdrs = make(map[string]string)
|
||||
|
@ -1016,12 +1021,23 @@ func (o *Options) GetSetResponseHeaders(requireStrictTransportSecurity bool) map
|
|||
hdrs[k] = v
|
||||
}
|
||||
}
|
||||
if _, ok := o.SetResponseHeaders[DisableHeaderKey]; ok {
|
||||
if _, ok := hdrs[DisableHeaderKey]; ok {
|
||||
hdrs = make(map[string]string)
|
||||
}
|
||||
|
||||
if policy != nil && policy.SetResponseHeaders != nil {
|
||||
for k, v := range policy.SetResponseHeaders {
|
||||
hdrs[k] = v
|
||||
}
|
||||
}
|
||||
if _, ok := hdrs[DisableHeaderKey]; ok {
|
||||
hdrs = make(map[string]string)
|
||||
}
|
||||
|
||||
if !requireStrictTransportSecurity {
|
||||
delete(hdrs, "Strict-Transport-Security")
|
||||
}
|
||||
|
||||
return hdrs
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue