Modification protection des services, on utiliser les infos déclaré dans le fichier ini

This commit is contained in:
Michael RICOIS 2011-10-12 12:09:45 +00:00
parent d30b769b7e
commit de8fa78378
2 changed files with 21 additions and 13 deletions

View File

@ -18,9 +18,9 @@ class DocumentationController extends Zend_Controller_Action
public function indexAction()
{
$request = $this->getRequest();
$ws = $request->getParam('ws','Entreprise');
$ws = $request->getParam('ws','Entreprise');
$auth = Zend_Auth::getInstance();
//Si client possède un webservice particulier alors on redirige vers la doc clients
$clients = new Zend_Config_Ini('WsScore/Clients/Clients.ini');
foreach( $clients->toArray() as $section => $params ){
@ -37,22 +37,31 @@ class DocumentationController extends Zend_Controller_Action
} else {
// Liste de webservice protégé
$protectedWs = array(
'Interne' => array('mricois', 'ylenaour', 'dlasserre')
);
// Liste des webservices
$services = new Zend_Config_Ini('WsScore/Services.ini');
foreach( $services->toArray() as $section => $params ){
if ($params['actif']) {
$wsServices[$section] = $params;
}
}
// On vérifie que l'utilisateur peut accèder à la documentation
if ( array_key_exists($ws, $protectedWs) )
{
$username = $auth->getIdentity()->username;
if ( !in_array($username, $protectedWs[$ws]) )
$username = $auth->getIdentity()->username;
$idClient = $auth->getIdentity()->idClient;
if ( array_key_exists($ws, $wsServices) )
{
if ( isset($wsServices['idClient']) && $idClient!=$wsServices['idClient'] )
{
$this->renderScript('documentation/nodoc.phtml');
exit;
}
if ( isset($wsServices['user']) && !in_array($username, $wsServices['user']) )
{
$this->renderScript('documentation/nodoc.phtml');
exit;
}
}
// Gestion des versions
$configServiceVersions = new Zend_Config_Ini('WsScore/'.ucfirst($ws).'/Versions.ini');
foreach( $configServiceVersions->toArray() as $section => $params ){

View File

@ -64,8 +64,7 @@ class ServiceController extends Zend_Controller_Action
exit;
}
// Charger les classes et les types pour le service suivant la version
// Charger les classes et les types pour le service suivant la version
if (strtolower($serviceName) == 'clients') {
$pathServiceClassIni = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.ini';
$pathServiceClassPhp = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.php';