mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
556a115c83
This fixes an issue with missing modern security headers such as the X-Content-Type-Options, Referer-Policy, etc.
29 lines
546 B
Go
29 lines
546 B
Go
package middlewares
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/valyala/fasthttp"
|
|
)
|
|
|
|
// AssetOverride allows overriding and serving of specific embedded assets from disk.
|
|
func AssetOverride(root string, strip int, next fasthttp.RequestHandler) fasthttp.RequestHandler {
|
|
return func(ctx *fasthttp.RequestCtx) {
|
|
if root == "" {
|
|
next(ctx)
|
|
|
|
return
|
|
}
|
|
|
|
_, err := os.Stat(filepath.Join(root, string(fasthttp.NewPathSlashesStripper(strip)(ctx))))
|
|
if err != nil {
|
|
next(ctx)
|
|
|
|
return
|
|
}
|
|
|
|
fasthttp.FSHandler(root, strip)(ctx)
|
|
}
|
|
}
|