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
|
||||
* @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
|
||||
@ -854,8 +856,13 @@ class RestfulServer extends Controller
|
||||
*/
|
||||
protected function authenticate()
|
||||
{
|
||||
$authClass = $this->config()->authenticator;
|
||||
$member = $authClass::authenticate();
|
||||
$authClasses = $this->config()->authenticators;
|
||||
$member = null;
|
||||
foreach ($authClasses as $authClass) {
|
||||
if ($member = $authClass::authenticate()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Security::setCurrentUser($member);
|
||||
return $member;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user