Added Basic Auth functionality

This commit is contained in:
Josh Sherman 2014-10-03 07:30:10 -04:00
parent 89fc175701
commit 84a785d4c9

View file

@ -103,16 +103,17 @@ class Resource extends Object
throw new \Exception('Authentication is not configured properly.', 401); throw new \Exception('Authentication is not configured properly.', 401);
} }
/*
// This class should be in the classes directory of the service // This class should be in the classes directory of the service
$auth = '\\' . $this->config['pickles']['namespace'] . '\\Auth'; $auth = '\\' . $this->config['pickles']['namespace'] . '\\Classes\\Auth';
var_dump($auth);
$auth = new $auth(); $auth = new $auth();
switch ($this->config['pickles']['auth']) switch ($this->config['pickles']['auth'])
{ {
case 'basic': case 'basic':
$auth->basic(); if (!$auth->basic())
{
throw new \Exception('Invalid authentication credentials.', 401);
}
break; break;
case 'oauth2': case 'oauth2':
@ -123,7 +124,6 @@ class Resource extends Object
throw new \Exception('Invalid authentication scheme.', 401); throw new \Exception('Invalid authentication scheme.', 401);
break; break;
} }
*/
} }
// Hack together some new globals // Hack together some new globals