mirror of
https://github.com/silverstripe/silverstripe-restfulserver
synced 2024-10-22 14:05:58 +02:00
Allow multiple authenticator classes
This commit is contained in:
parent
c11b7cdcda
commit
fa589c25fb
@ -59,9 +59,11 @@ class RestfulServer extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @config
|
* @config
|
||||||
* @var string Class name for an authenticator to use on API access
|
* @var array Class names for an authenticators to use on API access
|
||||||
*/
|
*/
|
||||||
private static $authenticator = BasicRestfulAuthenticator::class;
|
private static $authenticators = [
|
||||||
|
BasicRestfulAuthenticator::class
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If no extension is given in the request, resolve to this extension
|
* If no extension is given in the request, resolve to this extension
|
||||||
@ -854,8 +856,13 @@ class RestfulServer extends Controller
|
|||||||
*/
|
*/
|
||||||
protected function authenticate()
|
protected function authenticate()
|
||||||
{
|
{
|
||||||
$authClass = $this->config()->authenticator;
|
$authClasses = $this->config()->authenticators;
|
||||||
$member = $authClass::authenticate();
|
$member = null;
|
||||||
|
foreach ($authClasses as $authClass) {
|
||||||
|
if ($member = $authClass::authenticate()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Security::setCurrentUser($member);
|
Security::setCurrentUser($member);
|
||||||
return $member;
|
return $member;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user