passage en cas proxy pour imapunread

This commit is contained in:
afornerot 2021-07-05 14:07:18 +02:00
parent 3e9e581116
commit d61c2fc94d
6 changed files with 43 additions and 38 deletions

View File

@ -13,7 +13,6 @@
<file filelist="ninegate" name="/var/www/html/ninegate/app/config/template.yml" source="ninegate-template.yml" rm="True"/> <file filelist="ninegate" name="/var/www/html/ninegate/app/config/template.yml" source="ninegate-template.yml" rm="True"/>
<file filelist="ninegate" name="/var/www/html/ninegate/scripts/ninegate-postservice-00.sh" source="ninegate-postservice-00.sh" rm="True" mode="700" /> <file filelist="ninegate" name="/var/www/html/ninegate/scripts/ninegate-postservice-00.sh" source="ninegate-postservice-00.sh" rm="True" mode="700" />
<file filelist="ninegate" name="/var/www/html/ninegate/src/Cadoles/CoreBundle/Command/data/core-init-01.sql" source="ninegate-init-01.sql" rm="True"/> <file filelist="ninegate" name="/var/www/html/ninegate/src/Cadoles/CoreBundle/Command/data/core-init-01.sql" source="ninegate-init-01.sql" rm="True"/>
<file filelist="ninegate" name="/var/www/html/ninegate/web/imap-unread.php" source="ninegate-unread.php" rm="True"/>
<file filelist='ninegate' name='/etc/cron.d/ninegate' source='ninegate.cron' rm='True'/> <file filelist='ninegate' name='/etc/cron.d/ninegate' source='ninegate.cron' rm='True'/>
<file filelist='ninegate-migration' name='/var/www/html/envole-migration/config/config-db-ninegate.php' source='ninegate-migration.php' mkdir='True'/> <file filelist='ninegate-migration' name='/var/www/html/envole-migration/config/config-db-ninegate.php' source='ninegate-migration.php' mkdir='True'/>

View File

@ -30,7 +30,7 @@ class SecurityController extends Controller
// Init Client CAS // Init Client CAS
\phpCAS::setDebug("/var/log/phpcas/phpCAS-ninegate.log"); \phpCAS::setDebug("/var/log/phpcas/phpCAS-ninegate.log");
@\phpCAS::client(CAS_VERSION_2_0, $this->getParameter('cas_host'), $this->getParameter('cas_port'), is_null($this->getParameter('cas_path')) ? '' : $this->getParameter('cas_path'), false); @\phpCAS::proxy(CAS_VERSION_2_0, $this->getParameter('cas_host'), $this->getParameter('cas_port'), is_null($this->getParameter('cas_path')) ? '' : $this->getParameter('cas_path'), false);
\phpCAS::setNoCasServerValidation(); \phpCAS::setNoCasServerValidation();
@ -295,4 +295,29 @@ class SecurityController extends Controller
} }
} }
function imapunreadAction() {
if($this->getParameter("active_imapunread")) {
$ip=$this->getParameter("imapundread_ip");
// Init Client CAS
\phpCAS::setDebug("/var/log/phpcas/phpCAS-ninegate.log");
@\phpCAS::proxy(CAS_VERSION_2_0, $this->getParameter('cas_host'), $this->getParameter('cas_port'), is_null($this->getParameter('cas_path')) ? '' : $this->getParameter('cas_path'), false);
\phpCAS::setNoCasServerValidation();
\phpCAS::forceAuthentication();
$pt= \phpCAS::retrievePT('imap://'.$ip,$t,$f);
$a = \phpCAS::serviceMail("{".$ip.":993/imap/ssl/novalidate-cert}","imap://".$ip,0, $errc,$err,$pt);
$unseen = imap_status($a, "{".$ip.":993/imap/ssl/novalidate-cert}INBOX", SA_UNSEEN);
$count=$unseen->unseen;
$response = new Response(json_encode($count));
}
else
$response = new Response(json_encode(""));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
} }

View File

@ -10,3 +10,7 @@ cas_sp.test:
path: /test path: /test
defaults: { _controller: CadolesCASBundle:Security:test } defaults: { _controller: CadolesCASBundle:Security:test }
cas_sp.imapunread:
path: /imapunread
defaults: { _controller: CadolesCASBundle:Security:imapunread }

View File

@ -973,7 +973,7 @@ class InitDataCommand extends ContainerAwareCommand
$entityItem->addGroup($groupall); $entityItem->addGroup($groupall);
} }
$entityItem->setUrl($widroundcube_url); $entityItem->setUrl($widroundcube_url);
$entityItem->setBadgeurl("/ninegate/imap-unread.php"); $entityItem->setBadgeurl("/ninegate/cas/imapunread");
$em->persist($entityItem); $em->persist($entityItem);
} }

View File

@ -585,6 +585,18 @@ parameters:
noreply: %%ninegate_noreply noreply: %%ninegate_noreply
%end if %end if
%if %%is_defined('adresse_imap') or %%is_defined('adresse_ip_mail')
active_imapunread: true
%if %%is_defined('adresse_imap')
imapundread_ip: %%adresse_imap
%else
imapundread_ip: %%adresse_ip_mail
%end if
%else
active_imapunread: false
imapunread_ip:
%end if
# Doctrine Configuration # Doctrine Configuration
doctrine: doctrine:
dbal: dbal:

View File

@ -1,35 +0,0 @@
<?php
%if %%is_defined('adresse_imap') or %%is_defined('adresse_ip_mail')
require_once('/var/www/html/ninegate/vendor/jasig/phpcas/CAS.php');
require_once('configCAS/cas.inc.php');
// try to configure the phpCAS client
session_name("imapunread");
session_start();
if (__CAS_DEBUG){
phpCAS::setDebug("/var/log/phpcas/phpcas-imap.log");
}
$c= phpCAS::proxy(__CAS_VERSION, __CAS_SERVER, __CAS_PORT, __CAS_FOLDER, false);
phpCAS::setNoClearTicketsFromUrl();
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();
if (__CAS_LOGOUT){
if(method_exists('phpCAS','EoleLogoutRequests')) phpCAS::EoleLogoutRequests(false);
}
%if %%is_defined('adresse_imap')
$a = phpCAS::serviceMail("{%%adresse_imap:993/imap/ssl/novalidate-cert}","imap://%%adresse_imap",0, $errc,$err, phpCAS::retrievePT('imap://%%adresse_imap',$t,$f));
$unseen = imap_status($a, "{%%adresse_imap:993/imap/ssl/novalidate-cert}INBOX", SA_UNSEEN);
%else
$a = phpCAS::serviceMail("{%%adresse_ip_mail:993/imap/ssl/novalidate-cert}","imap://%%adresse_ip_mail",0, $errc,$err, phpCAS::retrievePT('imap://%%adresse_ip_mail',$t,$f));
$unseen = imap_status($a, "{%%adresse_ip_mail:993/imap/ssl/novalidate-cert}INBOX", SA_UNSEEN);
%end if
$count=$unseen->unseen;
echo $count;
%end if
?>