mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 12:41:30 +00:00
use authentication service
This commit is contained in:
parent
a5e975caa5
commit
55df94a993
|
@ -63,7 +63,7 @@ class RestapiController { /* {{{ */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $attrvalues;
|
return $attrvalues;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
protected function __getDocumentData($document) { /* {{{ */
|
protected function __getDocumentData($document) { /* {{{ */
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -232,6 +232,7 @@ class RestapiController { /* {{{ */
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->dms;
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->config;
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->logger;
|
||||||
|
$authenticator = $this->container->authenticator;
|
||||||
|
|
||||||
$params = $request->getParsedBody();
|
$params = $request->getParsedBody();
|
||||||
if(empty($params['user']) || empty($params['pass'])) {
|
if(empty($params['user']) || empty($params['pass'])) {
|
||||||
|
@ -240,23 +241,7 @@ class RestapiController { /* {{{ */
|
||||||
}
|
}
|
||||||
$username = $params['user'];
|
$username = $params['user'];
|
||||||
$password = $params['pass'];
|
$password = $params['pass'];
|
||||||
|
$userobj = $authenticator->authenticate($username, $password);
|
||||||
// $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);
|
|
||||||
} /* }}} */
|
|
||||||
|
|
||||||
if(!$userobj) {
|
if(!$userobj) {
|
||||||
setcookie("mydms_session", '', time()-3600, $settings->_httpRoot);
|
setcookie("mydms_session", '', time()-3600, $settings->_httpRoot);
|
||||||
|
@ -2712,6 +2697,7 @@ $container['conversionmgr'] = $conversionmgr;
|
||||||
$container['logger'] = $logger;
|
$container['logger'] = $logger;
|
||||||
$container['fulltextservice'] = $fulltextservice;
|
$container['fulltextservice'] = $fulltextservice;
|
||||||
$container['notifier'] = $notifier;
|
$container['notifier'] = $notifier;
|
||||||
|
$container['authenticator'] = $authenticator;
|
||||||
$app->add(new Auth($container));
|
$app->add(new Auth($container));
|
||||||
|
|
||||||
// Make CORS preflighted request possible
|
// Make CORS preflighted request possible
|
||||||
|
@ -2799,11 +2785,11 @@ $app->get('/echo/{data}', \TestController::class.':echoData');
|
||||||
$app->get('/statstotal', \RestapiController::class.':getStatsTotal');
|
$app->get('/statstotal', \RestapiController::class.':getStatsTotal');
|
||||||
|
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'])) {
|
||||||
foreach($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'] as $hookObj) {
|
foreach($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'] as $hookObj) {
|
||||||
if (method_exists($hookObj, 'addRoute')) {
|
if (method_exists($hookObj, 'addRoute')) {
|
||||||
$hookObj->addRoute($app);
|
$hookObj->addRoute($app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user