Web - Protecting Files: Unterschied zwischen den Versionen
| Zeile 1: | Zeile 1: | ||
| + | == Links == | ||
| + | https://processwire.com/talk/topic/869-protected-files/ | ||
| + | https://processwire.com/talk/topic/10671-fieldtypesecurefile/ | ||
| + | |||
== Dateien vor direktem Download schützen == | == Dateien vor direktem Download schützen == | ||
Dateien die in HTML Seiten verlinkt sind oder irgendwo in der Dateistruktur liegen, kann man in der Regel direkt downloaden. | Dateien die in HTML Seiten verlinkt sind oder irgendwo in der Dateistruktur liegen, kann man in der Regel direkt downloaden. | ||
| Zeile 11: | Zeile 15: | ||
RewriteRule (.*) http://www.mydomain.com/file-download/?page=%1&file=%2 [L] | RewriteRule (.*) http://www.mydomain.com/file-download/?page=%1&file=%2 [L] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
| + | === Dateien außerhalb des Webfolders speichern === | ||
| + | Dadurch kann der Zugriff nicht direkt über den Browser erfolgen. | ||
=== Passthrough Script === | === Passthrough Script === | ||
| − | + | Ein Skript, dass Zugriff auf die betreffende Datei hat und die Datei (nur an berechtigte User) weitergibt. In der Praxis kann man direkte Zugriffe z.B. per htaccess auf das Passthrough Script umleiten. | |
=== Kryptische oder wechselnde Dateinamen === | === Kryptische oder wechselnde Dateinamen === | ||
Nur mittelmäßig sicher. | Nur mittelmäßig sicher. | ||
| + | |||
| + | == ProcessWire - Dateien schützen == | ||
| + | === ProcessWire - Pagfile Secure, sichere Seitendownloads === | ||
| + | https://processwire.com/talk/topic/15622-pagefilesecure-and-pageispublic-hook-not-working/ | ||
| + | |||
| + | ProcessWire bietet von Haus aus die Konfigurationsmöglichkeit $config->pagefileSecure | ||
| + | <syntaxhighlight lang="php"> | ||
| + | When, true, prevents http access to file assets of access protected pages. | ||
| + | * | ||
| + | * Set to true if you want files on non-public or unpublished pages to be | ||
| + | * protected from direct URL access. | ||
| + | * | ||
| + | * When used, such files will be delivered at a URL that is protected from public access. | ||
| + | $config->pagefileSecure = true; | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | Ergänzt wird diese Konfiguration mit der Option um Pfade zu schützen: | ||
| + | <syntaxhighlight lang="php"> | ||
| + | /** | ||
| + | * Prefix for secure page files | ||
| + | * | ||
| + | * One or more characters prefixed to the pathname of secured file dirs. | ||
| + | * | ||
| + | * If use of this feature originated with a pre-2.3 install, this may need to be | ||
| + | * specified as "." rather than "-". | ||
| + | * | ||
| + | */ | ||
| + | $config->pagefileSecurePathPrefix = '-'; | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | Dateien mit einem - als prefix werden von der htaccess in ProcessWire ohnehin automatisch geblockt. | ||
| + | |||
| + | |||
| + | === FieldtypeSecureFile === | ||
| + | https://processwire.com/talk/topic/10671-fieldtypesecurefile/ | ||
| + | https://github.com/wanze/FieldtypeSecureFile | ||
| + | Wird schon einige Zeit nicht mehr gepflegt. Vielleicht als Ausgangspunkt für eigene Entwicklungen nützlich. | ||
| + | |||
| + | In der Modulkonfiguration legt man einen Ordner (außerhalb des Webbereichs) fest. Außerdem wird ein Neuer Feldtyp definiert. Es gibt ein paar Funktionen die man nutzen kann um die Dateien zu holen und abhängig vom Userstatus auszuliefern oder auch nicht. | ||
Version vom 10. November 2021, 17:36 Uhr
Links
https://processwire.com/talk/topic/869-protected-files/ https://processwire.com/talk/topic/10671-fieldtypesecurefile/
Dateien vor direktem Download schützen
Dateien die in HTML Seiten verlinkt sind oder irgendwo in der Dateistruktur liegen, kann man in der Regel direkt downloaden. In manchen Fällen möchte man das nicht. Z.b. wenn nur eingeloggte User die Dateien sehen sollen. Im Folgenden einige Wege wie man Dateien schützen kann.
Ordner vor unberechtigtem Zugriff schützen
IndexIgnore *
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/site/assets/files/(.*)/(.*)$
RewriteRule (.*) http://www.mydomain.com/file-download/?page=%1&file=%2 [L]Dateien außerhalb des Webfolders speichern
Dadurch kann der Zugriff nicht direkt über den Browser erfolgen.
Passthrough Script
Ein Skript, dass Zugriff auf die betreffende Datei hat und die Datei (nur an berechtigte User) weitergibt. In der Praxis kann man direkte Zugriffe z.B. per htaccess auf das Passthrough Script umleiten.
Kryptische oder wechselnde Dateinamen
Nur mittelmäßig sicher.
ProcessWire - Dateien schützen
ProcessWire - Pagfile Secure, sichere Seitendownloads
https://processwire.com/talk/topic/15622-pagefilesecure-and-pageispublic-hook-not-working/
ProcessWire bietet von Haus aus die Konfigurationsmöglichkeit $config->pagefileSecure
When, true, prevents http access to file assets of access protected pages.
*
* Set to true if you want files on non-public or unpublished pages to be
* protected from direct URL access.
*
* When used, such files will be delivered at a URL that is protected from public access.
$config->pagefileSecure = true;
Ergänzt wird diese Konfiguration mit der Option um Pfade zu schützen:
/**
* Prefix for secure page files
*
* One or more characters prefixed to the pathname of secured file dirs.
*
* If use of this feature originated with a pre-2.3 install, this may need to be
* specified as "." rather than "-".
*
*/
$config->pagefileSecurePathPrefix = '-';
Dateien mit einem - als prefix werden von der htaccess in ProcessWire ohnehin automatisch geblockt.
FieldtypeSecureFile
https://processwire.com/talk/topic/10671-fieldtypesecurefile/ https://github.com/wanze/FieldtypeSecureFile
Wird schon einige Zeit nicht mehr gepflegt. Vielleicht als Ausgangspunkt für eigene Entwicklungen nützlich.
In der Modulkonfiguration legt man einen Ordner (außerhalb des Webbereichs) fest. Außerdem wird ein Neuer Feldtyp definiert. Es gibt ein paar Funktionen die man nutzen kann um die Dateien zu holen und abhängig vom Userstatus auszuliefern oder auch nicht.