Revision [16266]

This is an old revision of Webauth made by GuyEdwards on 2007-03-08 13:10:43.

 

Using Webauth to identify the users
(note this is 99% just a copy of the work someone did on the ActiveDirectory authentication, just using the WEBAUTH_USER var instead)

Scenario

The user has already logged into your apache server after being authenticated by the webauth apache module. As per the ActiveDirectory page you still want to track chages however.

pre requisites

Working and tested webauth module

Solution

Working through http://wikkawiki.org/ActiveDirectory and applying the same changes, but in this case we know who the user is through use of another apache module, webauth: http://webauth.stanford.edu/obtain.html

1) Add a new field in the users database:
ALTER TABLE `wikka_users` ADD `alias` VARCHAR(75) NOT NULL


2) Add the following code in wikka.config.php
"user_identification" => "webauth",


3) In libs/Wakka.class.php about line 985, just after:
        // THE BIG EVIL NASTY ONE!
        function Run($tag, $method = "")
        {
                // do our stuff!
                if (!$this->method = trim($method)) $this->method = "show";
                if (!$this->tag = trim($tag)) $this->Redirect($this->Href("", $this->config["root_page"]));


Add the following code:
       // Check if webauth is on and webauth user known
        if (($this->config["user_identification"]=="webauth") && (!$this->GetUser()))
        {
            $idwebauth = $this->GetUserName();
            $sql = "SELECT name"
                . " FROM ".$this->config["table_prefix"]."users"
                . " WHERE alias = '"
                . mysql_real_escape_string($idwebauth)
                . "' limit 1";
            $hisname = $this->LoadSingle($sql);
            if ($hisname) {
                $this->SetUser($this->LoadUser($hisname["name"]));
            }
        }


4) In libs/Wakka.class.php on line 806 we modify the function GetUserName() to use the WEBAUTH_USER server variable:
ref: http://www.stanford.edu/services/webauth/manual/mod/mod_webauth.html

function GetUserName() {
   if ($user = $this->GetUser()){
      //$name = $user["name"];
      $name = $_SERVER["WEBAUTH_USER"];
   // start of new code
   }
   else if (!$name = $_SERVER["WEBAUTH_USER"]) {
       $name = $_SERVER["WEBAUTH_USER"];
       // belts, braces, thermos, survival bag....
       $name = trim(htmlentities(strip_tags($name)));
       //end of new code
   }
   else if (!$name = gethostbyaddr($_SERVER["REMOTE_ADDR"])) {
   $name = $_SERVER["REMOTE_ADDR"];
   }
   return $name;
}


How to use it?

Added webauth username to the alias field

....not working will try again tomorrow
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki