mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
use authentication service
This commit is contained in:
parent
a5e975caa5
commit
55df94a993
|
@ -63,7 +63,7 @@ class RestapiController { /* {{{ */
|
|||
}
|
||||
}
|
||||
return $attrvalues;
|
||||
} /* }}} */
|
||||
} /* }}} */
|
||||
|
||||
protected function __getDocumentData($document) { /* {{{ */
|
||||
$data = array(
|
||||
|
@ -232,6 +232,7 @@ class RestapiController { /* {{{ */
|
|||
$dms = $this->container->dms;
|
||||
$settings = $this->container->config;
|
||||
$logger = $this->container->logger;
|
||||
$authenticator = $this->container->authenticator;
|
||||
|
||||
$params = $request->getParsedBody();
|
||||
if(empty($params['user']) || empty($params['pass'])) {
|
||||
|
@ -240,23 +241,7 @@ class RestapiController { /* {{{ */
|
|||
}
|
||||
$username = $params['user'];
|
||||
$password = $params['pass'];
|
||||
|
||||
// $userobj = $dms->getUserByLogin($username);
|
||||
$userobj = null;
|
||||
|
||||
/* Authenticate against LDAP server {{{ */
|
||||
if (!$userobj && isset($settings->_ldapHost) && strlen($settings->_ldapHost)>0) {
|
||||
require_once("../inc/inc.ClassLdapAuthentication.php");
|
||||
$authobj = new SeedDMS_LdapAuthentication($dms, $settings);
|
||||
$userobj = $authobj->authenticate($username, $password);
|
||||
} /* }}} */
|
||||
|
||||
/* Authenticate against SeedDMS database {{{ */
|
||||
if(!$userobj) {
|
||||
require_once("../inc/inc.ClassDbAuthentication.php");
|
||||
$authobj = new SeedDMS_DbAuthentication($dms, $settings);
|
||||
$userobj = $authobj->authenticate($username, $password);
|
||||
} /* }}} */
|
||||
$userobj = $authenticator->authenticate($username, $password);
|
||||
|
||||
if(!$userobj) {
|
||||
setcookie("mydms_session", '', time()-3600, $settings->_httpRoot);
|
||||
|
@ -2712,6 +2697,7 @@ $container['conversionmgr'] = $conversionmgr;
|
|||
$container['logger'] = $logger;
|
||||
$container['fulltextservice'] = $fulltextservice;
|
||||
$container['notifier'] = $notifier;
|
||||
$container['authenticator'] = $authenticator;
|
||||
$app->add(new Auth($container));
|
||||
|
||||
// Make CORS preflighted request possible
|
||||
|
@ -2799,11 +2785,11 @@ $app->get('/echo/{data}', \TestController::class.':echoData');
|
|||
$app->get('/statstotal', \RestapiController::class.':getStatsTotal');
|
||||
|
||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'])) {
|
||||
foreach($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'] as $hookObj) {
|
||||
if (method_exists($hookObj, 'addRoute')) {
|
||||
$hookObj->addRoute($app);
|
||||
}
|
||||
}
|
||||
foreach($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'] as $hookObj) {
|
||||
if (method_exists($hookObj, 'addRoute')) {
|
||||
$hookObj->addRoute($app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$app->run();
|
||||
|
|
Loading…
Reference in New Issue
Block a user