Skip to content

fix: keep includeSubdomains when STSPreload is enabled - #74

Open
c879873067877881111 wants to merge 1 commit into
gin-contrib:masterfrom
c879873067877881111:fix/sts-preload-overwrites-includesubdomains
Open

fix: keep includeSubdomains when STSPreload is enabled#74
c879873067877881111 wants to merge 1 commit into
gin-contrib:masterfrom
c879873067877881111:fix/sts-preload-overwrites-includesubdomains

Conversation

@c879873067877881111

Copy link
Copy Markdown

When both STSIncludeSubdomains and STSPreload are set, the
Strict-Transport-Security header drops includeSubdomains and only sends:

max-age=315360000; preload

The preload branch in policy.go was overwriting stsSub instead of
appending to it:

if config.STSPreload {
    stsSub = "; preload"
}

Changed it to += so both directives are kept:

max-age=315360000; includeSubdomains; preload

Added a test for the both-enabled case.

Note: #52 also asks whether STSPreload should be enabled by default in
DefaultConfig(). I left that out here since it changes default behaviour —
happy to do a follow-up if you'd like.

Refs #52

STSPreload overwrote stsSub instead of appending, so enabling both
STSIncludeSubdomains and STSPreload dropped the includeSubdomains
directive from the Strict-Transport-Security header. Append the
preload directive instead so both are emitted.

Refs gin-contrib#52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant