Aperçu : route /api/preview en lecture seule et visualiseurs côté client
- GET /api/preview?path= et /api/public/{jeton}/preview : liste blanche d'extensions, inline, nosniff, CSP stricte, texte plafonné à 2 Mo
- Visualiseurs : texte brut, CSV paginé (PapaParse), Markdown sans HTML brut (react-markdown + remark-gfm), code colorisé (highlight.js), PDF natif
- Le HTML s'affiche comme du code, jamais rendu ; RTF/DOC/DOCX hors périmètre
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe81055421
commit
d4da3db132
14 files changed
+2378
-39
No files matched your search
+13
-5
@@ -8,6 +8,7 @@
|
||||
// POST /api/meta/tags {"paths":[...],"add":[...],"remove":[...]} tags
|
||||
// POST /api/meta/icon {"paths":[...],"icon":"server"} icône de dossiers ("" : défaut)
|
||||
// GET /api/file?path=a/b.pdf[&inline=1] téléchargement (Range, ETag) ; inline : affichage dans le navigateur si sûr
|
||||
// GET /api/preview?path=a/b.md aperçu en lecture seule (liste blanche, texte plafonné ; voir preview.go)
|
||||
// PUT /api/file?path=a/b.pdf[&conflict=fail|overwrite|rename][&mtime=ms] dépôt en flux
|
||||
// POST /api/folder {"path":"a/b"} création de dossier
|
||||
// POST /api/move {"from":"x","to":"y"} renommage / déplacement
|
||||
@@ -29,7 +30,7 @@
|
||||
// POST /api/shares/revoke-all révocation de tous les liens (administrateur)
|
||||
// GET /api/public/{jeton}[?sub=d] lien de partage (sans authentification)
|
||||
// POST /api/public/{jeton}/unlock mot de passe d'un lien protégé
|
||||
// GET /api/public/{jeton}/file|zip|thumb contenu d'un lien de partage
|
||||
// GET /api/public/{jeton}/file|zip|thumb|preview contenu d'un lien de partage
|
||||
// GET /api/settings / PUT paramètres (écriture : administrateur)
|
||||
// GET /api/logo / PUT (image/png) / DELETE logo 64x64
|
||||
// POST /api/account/password changement du mot de passe (compte local)
|
||||
@@ -63,10 +64,12 @@ type Handler struct {
|
||||
Auth *auth.Auth // nil : pas d'authentification intégrée
|
||||
Accounts *auth.Accounts // nil : pas de comptes (AUTH_MODE=none)
|
||||
|
||||
MaxJSON int64 // taille maximale d'un corps JSON (octets)
|
||||
Mode string // none, local, oidc ou both
|
||||
OIDCName string // libellé du bouton de connexion OIDC
|
||||
Version string
|
||||
MaxJSON int64 // taille maximale d'un corps JSON (octets)
|
||||
// PreviewMaxText : octets de texte servis au plus par /api/preview.
|
||||
PreviewMaxText int64
|
||||
Mode string // none, local, oidc ou both
|
||||
OIDCName string // libellé du bouton de connexion OIDC
|
||||
Version string
|
||||
|
||||
// SecureCookies : cookies de déverrouillage des liens marqués Secure même
|
||||
// en HTTP direct (URL publique en https).
|
||||
@@ -83,6 +86,9 @@ func (h *Handler) Init() *Handler {
|
||||
if h.MaxJSON == 0 {
|
||||
h.MaxJSON = 1 << 20
|
||||
}
|
||||
if h.PreviewMaxText == 0 {
|
||||
h.PreviewMaxText = DefaultPreviewMaxText
|
||||
}
|
||||
h.unlocks = auth.NewLimiter(10, 15*time.Minute)
|
||||
return h
|
||||
}
|
||||
@@ -139,6 +145,7 @@ func (h *Handler) Register(mux *http.ServeMux) {
|
||||
mux.HandleFunc("POST /api/meta/tags", h.editTags)
|
||||
mux.HandleFunc("POST /api/meta/icon", h.setIcon)
|
||||
mux.HandleFunc("GET /api/file", h.download)
|
||||
mux.HandleFunc("GET /api/preview", h.preview)
|
||||
mux.HandleFunc("PUT /api/file", h.upload)
|
||||
mux.HandleFunc("POST /api/folder", h.mkdir)
|
||||
mux.HandleFunc("POST /api/move", h.move)
|
||||
@@ -163,6 +170,7 @@ func (h *Handler) Register(mux *http.ServeMux) {
|
||||
mux.HandleFunc("GET /api/public/{token}/file", h.publicFile)
|
||||
mux.HandleFunc("GET /api/public/{token}/zip", h.publicZip)
|
||||
mux.HandleFunc("GET /api/public/{token}/thumb", h.publicThumb)
|
||||
mux.HandleFunc("GET /api/public/{token}/preview", h.publicPreview)
|
||||
mux.HandleFunc("GET /api/settings", h.readSettings)
|
||||
mux.HandleFunc("PUT /api/settings", h.writeSettings)
|
||||
mux.HandleFunc("GET /api/logo", h.readLogo)
|
||||
|
||||
Reference in new issue
Block a user