[dokuwiki] Re: signing requests

  • From: Robin Gareus <robin@xxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Tue, 10 Mar 2009 22:27:35 +0100

> yes, that's indeed a better solution. But it should be negated:
>    if (!$evt->advise_before()) auth_login(...)
> 

OOPS. My fault. advise_before() returns $event->_default which is true
by default.

I've also fixed a few whitespaces to conform with DokuWiki's coding
style. Find a new patch is attached.

robin
diff -rN -u old-robwiki/inc/HTTPClient.php new-robwiki/inc/HTTPClient.php
--- old-robwiki/inc/HTTPClient.php      2009-03-10 22:25:40.000000000 +0100
+++ new-robwiki/inc/HTTPClient.php      2009-03-10 22:25:40.000000000 +0100
@@ -158,6 +158,18 @@
         $this->error  = '';
         $this->status = 0;
 
+        $httpdata = array('url'    => $url,
+                          'data'   => $data,
+                          'method' => $method);
+        $evt = new Doku_Event('OUTGOING_HTTP_REQUEST',$httpdata);
+        if($evt->advise_before()){
+            $url    = $httpdata['url'];
+            $data   = $httpdata['data'];
+            $method = $httpdata['method'];
+        }
+        $evt->advise_after();
+        unset($evt);
+
         // parse URL into bits
         $uri = parse_url($url);
         $server = $uri['host'];
diff -rN -u old-robwiki/inc/auth.php new-robwiki/inc/auth.php
--- old-robwiki/inc/auth.php    2009-03-10 22:25:40.000000000 +0100
+++ new-robwiki/inc/auth.php    2009-03-10 22:25:40.000000000 +0100
@@ -81,7 +81,12 @@
         // external trust mechanism in place
         $auth->trustExternal($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r']);
       }else{
-        
auth_login($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r'],$_REQUEST['http_credentials']);
+        $evt = new Doku_Event('ACTION_ON_AUTH',$ACT);
+        if($evt->advise_before()){
+            
auth_login($_REQUEST['u'],$_REQUEST['p'],$_REQUEST['r'],$_REQUEST['http_credentials']);
+        }
+        $evt->advise_after();
+        unset($evt);
       }
     }
 

Other related posts: