teldrive/pkg/middleware/security.go
2023-12-03 01:17:23 +05:30

20 lines
539 B
Go

package middleware
import (
"github.com/gin-contrib/secure"
"github.com/gin-gonic/gin"
)
func Security() gin.HandlerFunc {
return secure.New(secure.Config{
STSSeconds: 315360000,
STSIncludeSubdomains: true,
FrameDeny: true,
ContentTypeNosniff: true,
BrowserXssFilter: true,
ContentSecurityPolicy: "default-src 'self'",
IENoOpen: true,
ReferrerPolicy: "strict-origin-when-cross-origin",
SSLProxyHeaders: map[string]string{"X-Forwarded-Proto": "https"},
})
}