Browse Source

Add a default CSP

Disallows loading external ressources. Providers can override it with
their reverse proxy settings.
master
Simon Ser 4 years ago
parent
commit
3d2da43207
No known key found for this signature in database GPG Key ID: FDE7BE0E88F5E48
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      server.go

+ 7
- 0
server.go View File

@@ -168,6 +168,13 @@ func New(e *echo.Echo, options *Options) error {

e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ectx echo.Context) error {
ectx.Response().Header().Set("Content-Security-Policy", "default-src 'self'")
return next(ectx)
}
})

e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(ectx echo.Context) error {
ctx := &Context{Context: ectx, Server: s}
ctx.Set("context", ctx)



Loading…
Cancel
Save