Skip to content

Commit

Permalink
feat: support STSPreload
Browse files Browse the repository at this point in the history
        // If STSPreload is set to true, the `; preload` will be appended to the
        // Strict-Transport-Security header. Default is false.
        // Note that removal is non-trivial and enabling this means you need to
        // support https long-term. See https://hstspreload.org/ for more info.
  • Loading branch information
GswOne authored and appleboy committed May 5, 2024
1 parent 645b4bb commit e944b63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func (p *policy) loadConfig(config Config) {
if config.STSIncludeSubdomains {
stsSub = "; includeSubdomains"
}

if config.STSPreload {
stsSub = "; preload"
}
// TODO
// "max-age=%d%s" refactor
p.addHeader(
Expand Down
6 changes: 6 additions & 0 deletions secure.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ type Config struct {
// If STSIncludeSubdomains is set to true, the `includeSubdomains` will
// be appended to the Strict-Transport-Security header. Default is false.
STSIncludeSubdomains bool
// If STSPreload is set to true, the `; preload` will be appended to the
// Strict-Transport-Security header. Default is false.
// Note that removal is non-trivial and enabling this means you need to
// support https long-term. See https://hstspreload.org/ for more info.
STSPreload bool
// If FrameDeny is set to true, adds the X-Frame-Options header with
// the value of `DENY`. Default is false.
FrameDeny bool
Expand Down Expand Up @@ -75,6 +80,7 @@ func DefaultConfig() Config {
IsDevelopment: false,
STSSeconds: 315360000,
STSIncludeSubdomains: true,
STSPreload: true,
FrameDeny: true,
ContentTypeNosniff: true,
BrowserXssFilter: true,
Expand Down

0 comments on commit e944b63

Please sign in to comment.