Skip to content

Commit 0e80970

Browse files
committed
fix: avoid config backup downloads
1 parent 77a6340 commit 0e80970

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

.docker/nginx/default.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ server {
4343
add_header Cache-Control "public, max-age=31536000, immutable";
4444
}
4545

46+
# Block zip files in content directory
47+
location ~ ^/content/.*\.zip$ {
48+
deny all;
49+
return 403;
50+
}
51+
4652
# Rewrite logging, should be turned off on production
4753
rewrite_log on;
4854

@@ -218,6 +224,12 @@ server {
218224
add_header Cache-Control "public, max-age=31536000, immutable";
219225
}
220226

227+
# Block zip files in content directory
228+
location ~ ^/content/.*\.zip$ {
229+
deny all;
230+
return 403;
231+
}
232+
221233
# Rewrite logging, should be turned off on production
222234
rewrite_log on;
223235

nginx.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ server {
6565
add_header Cache-Control "public, max-age=31536000, immutable";
6666
}
6767

68+
# Block zip files in content directory
69+
location ~ ^/content/.*\.zip$ {
70+
deny all;
71+
return 403;
72+
}
73+
6874
# Rewrite logging, should be turned off on production
6975
rewrite_log on;
7076

phpmyfaq/.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
9898
</IfModule>
9999
# the path to your phpMyFAQ installation
100100
RewriteBase /
101+
# Block zip files in content directory
102+
RewriteRule ^content/.*\.zip$ - [F,L]
101103
# Exclude assets from being handled by Symfony Router
102104
RewriteRule ^(admin/assets)($|/) - [L]
103105
# Error pages

phpmyfaq/src/phpMyFAQ/Controller/Api/SetupController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ final class SetupController extends AbstractController
3333
{
3434
public function check(Request $request): JsonResponse
3535
{
36+
$this->userIsAuthenticated();
37+
3638
if (trim($request->getContent()) === '') {
3739
return $this->json(['message' => 'No version given.'], Response::HTTP_BAD_REQUEST);
3840
}
@@ -68,6 +70,8 @@ public function check(Request $request): JsonResponse
6870

6971
public function backup(Request $request): JsonResponse
7072
{
73+
$this->userIsAuthenticated();
74+
7175
if (trim($request->getContent()) === '') {
7276
return $this->json(['message' => 'No version given.'], Response::HTTP_BAD_REQUEST);
7377
}
@@ -93,6 +97,8 @@ public function backup(Request $request): JsonResponse
9397

9498
public function updateDatabase(Request $request): JsonResponse
9599
{
100+
$this->userIsAuthenticated();
101+
96102
if (trim($request->getContent()) === '') {
97103
return $this->json(['message' => 'No version given.'], Response::HTTP_BAD_REQUEST);
98104
}

0 commit comments

Comments
 (0)