Revert last 4 commits
All checks were successful
Automated Container Build / build-and-push (push) Successful in 46s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 46s
This commit is contained in:
parent
e7a649d0d4
commit
c7d39144cd
5 changed files with 14 additions and 100 deletions
|
|
@ -335,20 +335,16 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error {
|
|||
var results []OfficeFile
|
||||
|
||||
checksums := make(map[string]string)
|
||||
dbPaths := []string{}
|
||||
rows, err := h.DB.Query("SELECT path, checksum FROM files WHERE checksum IS NOT NULL AND checksum != ''")
|
||||
rows, err := h.DB.Query("SELECT path, checksum FROM files WHERE checksum != '' AND is_trashed = 0")
|
||||
if err == nil {
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var p, c string
|
||||
if rows.Scan(&p, &c) == nil {
|
||||
checksums[p] = c
|
||||
dbPaths = append(dbPaths, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
walkPaths := []string{}
|
||||
|
||||
filepath.Walk(h.Config.StorageDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
|
|
@ -366,16 +362,12 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error {
|
|||
if strings.HasSuffix(strings.ToLower(info.Name()), ext) {
|
||||
relPath, _ := filepath.Rel(h.Config.StorageDir, path)
|
||||
relPathSlash := filepath.ToSlash(relPath)
|
||||
|
||||
chk := checksums[relPathSlash]
|
||||
walkPaths = append(walkPaths, relPathSlash)
|
||||
|
||||
results = append(results, OfficeFile{
|
||||
Name: info.Name(),
|
||||
Path: relPathSlash,
|
||||
Size: info.Size(),
|
||||
ModTime: info.ModTime().UTC().Format("2006-01-02T15:04:05Z"),
|
||||
Checksum: chk,
|
||||
Checksum: checksums[relPathSlash],
|
||||
})
|
||||
}
|
||||
return nil
|
||||
|
|
@ -388,8 +380,6 @@ func (h *OnlyOfficeHandler) ListOfficeFiles(c *fiber.Ctx) error {
|
|||
return c.JSON(fiber.Map{
|
||||
"files": results,
|
||||
"count": len(results),
|
||||
"debug_db": dbPaths,
|
||||
"debug_walk": walkPaths,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,21 +103,9 @@ func main() {
|
|||
c.Set("Cache-Control", "no-store, no-cache, must-revalidate")
|
||||
return c.Next()
|
||||
})
|
||||
app.Use(helmet.New(helmet.Config{
|
||||
// Relax cross-origin policies to allow OnlyOffice Document Server
|
||||
// iframe embedding from a different origin (e.g. office.elijahkuntz.com)
|
||||
CrossOriginEmbedderPolicy: "unsafe-none",
|
||||
CrossOriginResourcePolicy: "cross-origin",
|
||||
}))
|
||||
|
||||
// Build CSP with dynamic frame-src for the OnlyOffice Document Server
|
||||
onlyOfficeFrameSrc := "https://" + cfg.OnlyOfficeHost
|
||||
cspHeader := fmt.Sprintf(
|
||||
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' wss: https: http:; frame-src 'self' %s;",
|
||||
onlyOfficeFrameSrc,
|
||||
)
|
||||
app.Use(helmet.New())
|
||||
app.Use(func(c *fiber.Ctx) error {
|
||||
c.Set("Content-Security-Policy", cspHeader)
|
||||
c.Set("Content-Security-Policy", "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' wss: https: http:;")
|
||||
return c.Next()
|
||||
})
|
||||
allowedOrigins := os.Getenv("ALLOWED_ORIGINS")
|
||||
|
|
|
|||
Reference in a new issue