Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions router/middleware/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@ func Secure(c *gin.Context) {
c.Header("X-Frame-Options", "DENY")
c.Header("X-Content-Type-Options", "nosniff")
c.Header("X-XSS-Protection", "1; mode=block")

// Also consider adding Content-Security-Policy headers
// TODO: consider adding Content-Security-Policy headers
// c.Header("Content-Security-Policy", "script-src 'self' https://cdnjs.cloudflare.com")
if c.Request.TLS != nil {
c.Header("Strict-Transport-Security", "max-age=31536000")
}
c.Header("Strict-Transport-Security", "max-age=63072000; includeSubDomains; preload")
}

// Cors is a middleware function that appends headers for
Expand Down
2 changes: 1 addition & 1 deletion router/middleware/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func TestMiddleware_Secure_TLS(t *testing.T) {
wantFrameOptions := "DENY"
wantContentTypeOptions := "nosniff"
wantProtection := "1; mode=block"
wantSecurity := "max-age=31536000"
wantSecurity := "max-age=63072000; includeSubDomains; preload"

// setup context
gin.SetMode(gin.TestMode)
Expand Down