mirror of
https://github.com/ordinary-dev/phoenix
synced 2024-09-20 03:40:29 +05:00
15 lines
505 B
Go
15 lines
505 B
Go
|
package views
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
// Adds several headers to the response to improve security.
|
||
|
// For example, headers prevent embedding a site and passing information about the referrer.
|
||
|
func SecurityHeadersMiddleware(c *gin.Context) {
|
||
|
c.Writer.Header().Set("X-Frame-Options", "SAMEORIGIN")
|
||
|
c.Writer.Header().Set("X-Content-Type-Options", "nosniff")
|
||
|
c.Writer.Header().Set("Referrer-Policy", "same-origin")
|
||
|
c.Writer.Header().Set("Content-Security-Policy", "default-src 'self'")
|
||
|
}
|