Skip to content
Snippets Groups Projects
Commit 5dda909b authored by Peter Rotich's avatar Peter Rotich Committed by Peter Rotich
Browse files

Proof of concept for authentication

parent d01e9f24
No related branches found
No related tags found
No related merge requests found
......@@ -239,5 +239,28 @@ class Client {
return false;
}
static function authlogin($auth) {
//Expecting authtoken
// <user type><id of the user type>x<version id of the algo used>h<hash>
$matches = array();
$regex='/^(?P<type>\w{1})(?P<id>\d+)x(?P<v>\d+)h(?P<hash>.*)$/i';
if (!preg_match($regex, $auth, $matches))
return false;
switch($matches['type']) {
case 'c': //Collaborator c<id>x<algo id used>h<hash for algo>
if (($c = Collaborator::lookup($matches['id']))
&& strcasecmp($c->getAuthToken($matches['v']), $auth) == 0
)
return $c;
break;
case 'o': //Ticket owner
break;
}
return false;
}
}
?>
......@@ -22,8 +22,10 @@ if(!$thisclient || !$thisclient->isValid()) {
// * On login Client::login will redirect the user to tickets.php view.
// * See TODO above for planned multi-view.
$user = null;
if($_GET['t'] && $_GET['e'] && $_GET['a'])
if ($_GET['t'] && $_GET['e'] && $_GET['a'])
$user = Client::login($_GET['t'], $_GET['e'], $_GET['a'], $errors);
elseif ($_GET['auth'])
var_dump(Client::authlogin($_GET['auth']));
//XXX: For now we're assuming the user is the ticket owner
// (multi-view based on auth token will come later).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment