Merge pull request #209 from copenhagentruckwash/fix-unauthenticated-certificate-download-vulnerability
Require authentication token for wash certificate download endpoint
This commit is contained in:
@@ -20,7 +20,11 @@ if (!is_numeric($certificate_id) || $certificate_id < 1) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add authentication here
|
// Require a valid static token before serving certificates
|
||||||
|
if (!isset($_GET['secret_token']) || $_GET['secret_token'] !== $WORDPRESS_STATIC_TOKEN) {
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the certificate exists in the /output/certificates folder
|
// Check if the certificate exists in the /output/certificates folder
|
||||||
if (!file_exists("../output/certificates/wash_certificate_" . $certificate_id . ".pdf")) {
|
if (!file_exists("../output/certificates/wash_certificate_" . $certificate_id . ".pdf")) {
|
||||||
@@ -34,4 +38,4 @@ header('Content-Disposition: attachment; filename="wash certificate ' . $certifi
|
|||||||
|
|
||||||
// Output the certificate
|
// Output the certificate
|
||||||
readfile("../output/certificates/wash_certificate_" . $certificate_id . ".pdf");
|
readfile("../output/certificates/wash_certificate_" . $certificate_id . ".pdf");
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
Reference in New Issue
Block a user