Added auth test, cleaned up directory
This commit is contained in:
parent
a866a1a61b
commit
e45e1251e1
25 changed files with 134 additions and 15 deletions
10
src/Auth.php
10
src/Auth.php
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Auth Abstraction
|
||||
* Authentication
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistribution of these files must retain the above copyright notice.
|
||||
|
@ -15,9 +15,9 @@
|
|||
namespace Pickles;
|
||||
|
||||
/**
|
||||
* Auth Abstract Class
|
||||
* Auth Parent Class
|
||||
*/
|
||||
abstract class Auth extends Object
|
||||
class Auth extends Object
|
||||
{
|
||||
/**
|
||||
* Basic Auth
|
||||
|
@ -29,12 +29,12 @@ abstract class Auth extends Object
|
|||
*/
|
||||
public function basic()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function oauth2()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,8 +102,23 @@ class Resource extends Object
|
|||
|
||||
// This class should be in the classes directory of the service
|
||||
$auth = '\\' . $this->config['pickles']['namespace'] . '\\Classes\\Auth';
|
||||
|
||||
// Strips preceding slashs when there is no namespace
|
||||
if (strpos($auth, '\\\\') === 0)
|
||||
{
|
||||
$auth = substr($auth, 2);
|
||||
}
|
||||
|
||||
$auth = new $auth();
|
||||
|
||||
// @todo Remove when switch is implemented
|
||||
if (!$auth->basic())
|
||||
{
|
||||
throw new \Exception('Invalid authentication credentials.', 401);
|
||||
}
|
||||
|
||||
// @todo Not yet implemented
|
||||
/*
|
||||
switch ($this->config['pickles']['auth'])
|
||||
{
|
||||
case 'basic':
|
||||
|
@ -112,7 +127,6 @@ class Resource extends Object
|
|||
throw new \Exception('Invalid authentication credentials.', 401);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'oauth2':
|
||||
$auth->oauth2();
|
||||
break;
|
||||
|
@ -121,6 +135,7 @@ class Resource extends Object
|
|||
throw new \Exception('Invalid authentication scheme.', 401);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// Hack together some new globals
|
||||
|
|
|
@ -63,6 +63,7 @@ class Router extends Object
|
|||
array_unshift($nouns, '', $this->config['pickles']['namespace'], 'Resources', $version);
|
||||
$class = implode('\\', $nouns);
|
||||
|
||||
// @todo Make namespace mandatory
|
||||
// Strips preceding slashs when there is no namespace
|
||||
if (strpos($class, '\\\\') === 0)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue