<div class="gmail_quote">On Sun, May 24, 2009 at 1:53 AM, John Rankin <span dir="ltr">&lt;<a href="mailto:john.rankin@affinity.co.nz">john.rankin@affinity.co.nz</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It seems to me that we ought to be able to define a custom<br>
$AuthFunction that checks the IP address of the requestor,<br>
rather than asking for a username and password. Then the<br>
custom auth function can authenticate the request based on<br>
the fact that it comes from an IP address pmwiki trusts.<br>
It may have to grant &quot;admin&quot; rights, especially where the<br>
request is retrieving multiple pmwiki pages.<br>
</blockquote><div><br>Something along these lines might work (UNTESTED - basically just making a wrapper for PmWikiAuth())...<br><br>$AuthFunction = &#39;MyAuthFunction&#39;;<br>$PrivilegedIP = array(&#39;/^100\.100\.100\.[0-9]*$/&#39;, &#39;/^89\.90\.91\.92$/&#39;);<br>
<br>function MyAuthFunction($pagename, $level, $authprompt, $since)<br>{<br>   global $PrivilegedIP;<br>   if (!in_array($action, array(&#39;edit&#39;, &#39;attr&#39;)))<br>      foreach ($PrivilegedIP as $IPPat)<br>         if (preg_match($IPPat, $_SERVER[&#39;REMOTE_ADDR&#39;]))<br>
            return true;<br>   return PmWikiAuth($pagename, $level, $authprompt, $since);<br>}<br><br>You&#39;ll note I&#39;ve made a quick attempt to disallow editing and attribute-setting using this &quot;Privileged IP&quot; authentication.  If that&#39;s not desirable then just delete the line with &quot;if (!in_array...&quot;.  If there are other actions I&#39;m thinking of that should not be available then just edit the array (or, better yet, change it into a configurable var).<br>
<br>I *think* I&#39;ve read that $_SERVER[&#39;REMOTE_ADDR&#39;] can be spoofed, so be aware that this opens a potential security hole.  That&#39;s why I&#39;ve made a rudimentary effort to allow only browsing using this form of authentication.<br>
<br>-Peter<br></div></div>