[pmwiki-users] AuthUser and IP-based authorisation

Eemeli Aro eemeli at gmail.com
Tue Oct 14 06:28:02 CDT 2008


2008/10/14 John Rankin <john.rankin at affinity.co.nz>:
> What would be involved in extending AuthUser to grant access
> based on IP address?
>
> Specifically, would it be possible to grant read access to
> requests from a specific IP address, based on that address
> being defined as a username on SiteAdmin.AuthUser?

Hmmm. Here's something I just thought of as a possible answer, haven't
tested this so can't verify whether it'll work:

Add this to your config file:

$AuthUserFunctions['ip'] = 'AuthUserIP';
function AuthUserIP($pagename, $id, $pw, $pwlist) {
  $i = '';
  foreach ( (array)$pwlist as $d ) {
    if ($d==$id) { $i = $d; continue; }
    if ( $i && ( $_SERVER['REMOTE_ADDR'] == $d ) ) return true;
  }
  return false;
}

Then, use the following in you SiteAdmin.AuthUser file:

ip: username ip-address

With the values replaced with whatever you'll want to use such that
someone coming from "ip-address" is allowed to log in as "username".
It should be ok to define more than one IP-address. If you need more
than one username, add them on separate lines using the above format.

Then, try accessing the site from the defined IP address & log in with
the user name, leaving the password field blank. If it works, you
ought to be able to use PublishPDF by adding "&authid=username" to the
end of a request coming from that server.

eemeli



More information about the pmwiki-users mailing list