This commit is contained in:
6543 2022-11-07 21:34:23 +01:00
parent fe444aa2c0
commit 60aefb4bf5
No known key found for this signature in database
GPG key ID: B8BE6D610E61C862
3 changed files with 2 additions and 20 deletions

View file

@ -6,7 +6,6 @@ import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/valyala/fasthttp"
"codeberg.org/codeberg/pages/html"
"codeberg.org/codeberg/pages/server/cache"
@ -52,14 +51,14 @@ func Handler(mainDomainSuffix, rawDomain string,
// Block all methods not required for static pages
if !ctx.IsMethod(http.MethodGet) && !ctx.IsMethod(http.MethodHead) && !ctx.IsMethod(http.MethodOptions) {
ctx.RespWriter.Header().Set("Allow", http.MethodGet+", "+http.MethodHead+", "+http.MethodOptions) // duplic 1
ctx.String("Method not allowed", fasthttp.StatusMethodNotAllowed)
ctx.String("Method not allowed", http.StatusMethodNotAllowed)
return
}
// Block blacklisted paths (like ACME challenges)
for _, blacklistedPath := range blacklistedPaths {
if strings.HasPrefix(ctx.Path(), blacklistedPath) {
html.ReturnErrorPage(ctx, "", fasthttp.StatusForbidden)
html.ReturnErrorPage(ctx, "", http.StatusForbidden)
return
}
}