Manage 30[12] HTTP redirect in access file to manage permissions

Dam_ned92

Joined: 2009-11-21
Posts: 1
Posted: Sat, 2009-11-21 17:17

Hi,

The test for Rewrite rules does not manage HTTP redirections.
I use it in ma architecture (based on apache reverse proxy to switch from http to https).
So I have done some few patch to handle it.

diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index c1c1f9d..f350501 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -653,7 +653,10 @@ class access_Core {
       fclose($fp);
     }
 
-    list ($response) = remote::do_request(url::abs_file("var/tmp/security_test/verify"));
+    $url = url::abs_file("var/tmp/security_test/verify");
+    do {
+       list ($response,$header) = remote::do_request($url);
+    } while (($response == "HTTP/1.1 302 Found" || $response == "HTTP/1.1 301 Moved Permanently") && $url = $header['Location']);
     $works = $response == "HTTP/1.1 200 OK";
     @dir::unlink(VARPATH . "tmp/security_test");

Feel free to use it.

Best regards.

--
Dam