|
@ -28,6 +28,9 @@ var Config struct { |
|
|
siteURL string |
|
|
siteURL string |
|
|
fastcgi bool |
|
|
fastcgi bool |
|
|
remoteUploads bool |
|
|
remoteUploads bool |
|
|
|
|
|
contentSecurityPolicy string |
|
|
|
|
|
fileContentSecurityPolicy string |
|
|
|
|
|
xFrameOptions string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var Templates = make(map[string]*pongo2.Template) |
|
|
var Templates = make(map[string]*pongo2.Template) |
|
@ -37,6 +40,11 @@ var timeStarted time.Time |
|
|
var timeStartedStr string |
|
|
var timeStartedStr string |
|
|
|
|
|
|
|
|
func setup() { |
|
|
func setup() { |
|
|
|
|
|
goji.Use(ContentSecurityPolicy(CSPOptions{ |
|
|
|
|
|
policy: Config.contentSecurityPolicy, |
|
|
|
|
|
frame: Config.xFrameOptions, |
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
if Config.noLogs { |
|
|
if Config.noLogs { |
|
|
goji.Abandon(middleware.Logger) |
|
|
goji.Abandon(middleware.Logger) |
|
|
} |
|
|
} |
|
@ -126,6 +134,14 @@ func main() { |
|
|
"serve through fastcgi") |
|
|
"serve through fastcgi") |
|
|
flag.BoolVar(&Config.remoteUploads, "remoteuploads", false, |
|
|
flag.BoolVar(&Config.remoteUploads, "remoteuploads", false, |
|
|
"enable remote uploads") |
|
|
"enable remote uploads") |
|
|
|
|
|
flag.StringVar(&Config.contentSecurityPolicy, "contentSecurityPolicy", |
|
|
|
|
|
"default-src 'self'; img-src 'self' data:; referrer none;", |
|
|
|
|
|
"value of default Content-Security-Policy header") |
|
|
|
|
|
flag.StringVar(&Config.fileContentSecurityPolicy, "fileContentSecurityPolicy", |
|
|
|
|
|
"default-src 'none'; img-src 'self'; object-src 'self'; media-src 'self'; sandbox; referrer none;", |
|
|
|
|
|
"value of Content-Security-Policy header for file access") |
|
|
|
|
|
flag.StringVar(&Config.xFrameOptions, "xFrameOptions", "SAMEORIGIN", |
|
|
|
|
|
"value of X-Frame-Options header") |
|
|
flag.Parse() |
|
|
flag.Parse() |
|
|
|
|
|
|
|
|
setup() |
|
|
setup() |
|
|