-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CSP and other security related headers in the oCIS proxy se…
…rvice
- Loading branch information
1 parent
0272f94
commit 55a29eb
Showing
15 changed files
with
1,422 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package middleware | ||
|
||
import ( | ||
"github.com/unrolled/secure" | ||
"github.com/unrolled/secure/cspbuilder" | ||
"net/http" | ||
) | ||
|
||
// Security is a middleware to apply security relevant http headers like CSP. | ||
func Security() func(h http.Handler) http.Handler { | ||
// some way to configure them is necessary for external integrations | ||
// e.g. draw.io, OnlyOffice, Collabora .... | ||
cspBuilder := cspbuilder.Builder{ | ||
Directives: map[string][]string{ | ||
cspbuilder.ConnectSrc: {"'self'"}, | ||
cspbuilder.ChildSrc: {"'self'", "https://embed.diagrams.net/"}, | ||
cspbuilder.DefaultSrc: {"'none'"}, | ||
cspbuilder.FontSrc: {"'self'"}, | ||
cspbuilder.FrameSrc: {"'self'", "blob:"}, | ||
cspbuilder.ImgSrc: {"'self'", "data:", "blob:"}, | ||
cspbuilder.ManifestSrc: {"'self'"}, | ||
cspbuilder.MediaSrc: {"'self'"}, | ||
cspbuilder.ObjectSrc: {"'self'", "blob:"}, | ||
cspbuilder.ScriptSrc: {"'self'", "'unsafe-inline'"}, | ||
cspbuilder.StyleSrc: {"'self'", "'unsafe-inline'"}, | ||
}, | ||
} | ||
secureMiddleware := secure.New(secure.Options{ | ||
BrowserXssFilter: true, | ||
ContentSecurityPolicy: cspBuilder.MustBuild(), | ||
ContentTypeNosniff: true, | ||
CustomFrameOptionsValue: "SAMEORIGIN", | ||
ReferrerPolicy: "strict-origin-when-cross-origin", | ||
STSSeconds: 315360000, | ||
STSPreload: true, | ||
}) | ||
return func(next http.Handler) http.Handler { | ||
return secureMiddleware.Handler(next) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.