traefik/old/middlewares/secure.go

37 lines
1.3 KiB
Go
Raw Normal View History

2017-06-12 18:48:21 -06:00
package middlewares
import (
2018-11-14 10:18:03 +01:00
"github.com/containous/traefik/old/types"
2017-06-12 18:48:21 -06:00
"github.com/unrolled/secure"
)
// NewSecure constructs a new Secure instance with supplied options.
2018-01-02 10:10:04 +01:00
func NewSecure(headers *types.Headers) *secure.Secure {
if headers == nil || !headers.HasSecureHeadersDefined() {
return nil
}
2017-06-12 18:48:21 -06:00
opt := secure.Options{
AllowedHosts: headers.AllowedHosts,
HostsProxyHeaders: headers.HostsProxyHeaders,
SSLRedirect: headers.SSLRedirect,
SSLTemporaryRedirect: headers.SSLTemporaryRedirect,
SSLHost: headers.SSLHost,
SSLProxyHeaders: headers.SSLProxyHeaders,
STSSeconds: headers.STSSeconds,
STSIncludeSubdomains: headers.STSIncludeSubdomains,
STSPreload: headers.STSPreload,
ForceSTSHeader: headers.ForceSTSHeader,
FrameDeny: headers.FrameDeny,
CustomFrameOptionsValue: headers.CustomFrameOptionsValue,
ContentTypeNosniff: headers.ContentTypeNosniff,
BrowserXssFilter: headers.BrowserXSSFilter,
2018-03-02 14:24:03 +01:00
CustomBrowserXssValue: headers.CustomBrowserXSSValue,
2017-06-12 18:48:21 -06:00
ContentSecurityPolicy: headers.ContentSecurityPolicy,
PublicKey: headers.PublicKey,
ReferrerPolicy: headers.ReferrerPolicy,
IsDevelopment: headers.IsDevelopment,
}
return secure.New(opt)
}