diff --git a/dicos/90_nineskeletor.xml b/dicos/90_nineskeletor.xml
index 83aa619..4074fa6 100644
--- a/dicos/90_nineskeletor.xml
+++ b/dicos/90_nineskeletor.xml
@@ -16,44 +16,165 @@
-
+
+
+
-
+
+ non
+
oui
-
+ /var/www/html/nineskeletor/.key
-
-
-
-
-
-
-
-
+ CAS
+ Ninegate
+ /ninegate
+ APIKeyNinegate
+
+
+
+ scribe
+ (&(ObjectClass=posixGroup)(cn=*))
+ (&(ObjectClass=person)(uid=*))
+ uid
+ givenname
+ sn
+ mail
+
+
+
+
+ oui
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Paramètres associés à l'Annuaire
+ Paramètres associés aux Mails
+ Paramètres associés à la Base de Données
+
+
non
nineskeletor
nineskeletor
+
+
non
+
+ nineskeletor_masteridentity
+ nineskeletor_urlidentity
+ nineskeletor_apikeyidentity
+
+ nineskeletor_mode_auth
+ nineskeletor_api_key
+ nineskeletor_ldaptemplate
+
+ nineskeletor_noreply
+ nineskeletor_activer_localmail
+ nineskeletor_smtphost
+ nineskeletor_smtpport
+ nineskeletor_smtpuser
+ nineskeletor_smtppwd
+ nineskeletor_smtpencryption
+ nineskeletor_smtpauthmode
+
+ nineskeletor_db_mode
+ nineskeletor_dbserver
+ nineskeletor_dbport
+ nineskeletor_allow_hosts
+ nineskeletor_dbuser
+ nineskeletor_dbpass
+
nineskeletor
nineskeletor
-
- ['default', 'externe', 'local']
-
+
+
+
+ oui
+
+ ninegate_test_ninegate
+ Ninegate
+ LDAP
+ LDAP
+
+
+
+
+
+ LDAP
+
+ nineskeletor_urlidentity
+ nineskeletor_apikeyidentity
+
+
+
+ Ninegate
+
+ nineskeletor_ldaptemplate
+
+
+
+
+
+ scribe
+
+ nineskeletor_ldapfiltergroup
+ nineskeletor_ldapfilteruser
+ nineskeletor_ldapuid
+ nineskeletor_ldapfirstname
+ nineskeletor_ldaplastname
+ nineskeletor_ldapmail
+
+
+
+
+
+ noreply@
+ domaine_messagerie_etab
+
+
+
+ oui
+
+ nineskeletor_smtphost
+ nineskeletor_smtpport
+ nineskeletor_smtpuser
+ nineskeletor_smtppwd
+ nineskeletor_smtpencryption
+ nineskeletor_smtpauthmode
+
+
+
+
local
nineskeletor_dbserver
@@ -69,6 +190,32 @@
nineskeletor_dbpass
nineskeletor_allow_hosts
+
+
+
+
+ ['LDAP','Ninegate']
+
+
+
+ ['CAS', 'LDAP', 'SQL']
+
+
+
+ ['scribe','open']
+
+
+
+ ['tls', 'ssl', 'null']
+
+
+ ['plain', 'login', 'cram-md5', 'null']
+
+
+
+ ['default', 'externe', 'local']
+
+
diff --git a/src/nineskeletor-1.0/config/packages/security.yaml b/src/nineskeletor-1.0/config/packages/security.yaml
index fbc54e0..99a780c 100644
--- a/src/nineskeletor-1.0/config/packages/security.yaml
+++ b/src/nineskeletor-1.0/config/packages/security.yaml
@@ -42,12 +42,8 @@ security:
- # ROLE_ADMIN = accède à tout
- # ROLE_VALIDATOR = accède aux validations de planning
- # ROLE_MASTER = accède à la gestion de client / projet / commande / tache
- # ROLE_USER = accède
- # ROLE_VISITOR = accède à rien
access_control:
- - { path: ^/user, roles: [ROLE_ADMIN, ROLE_MASTER, ROLE_STUDENT, ROLE_USER] }
- - { path: ^/master, roles: [ROLE_ADMIN, ROLE_MASTER] }
+ - { path: ^/user, roles: [ROLE_ADMIN, ROLE_MODO, ROLE_MASTER, ROLE_USER] }
+ - { path: ^/master, roles: [ROLE_ADMIN, ROLE_MODO, ROLE_MASTER] }
+ - { path: ^/modo, roles: [ROLE_ADMIN, ROLE_MODO] }
- { path: ^/admin, roles: [ROLE_ADMIN] }
diff --git a/src/nineskeletor-1.0/config/routes.yaml b/src/nineskeletor-1.0/config/routes.yaml
index b429c86..1c14140 100644
--- a/src/nineskeletor-1.0/config/routes.yaml
+++ b/src/nineskeletor-1.0/config/routes.yaml
@@ -60,9 +60,12 @@ app_cron_exec:
defaults: { _controller: App\Controller\CronController:exec }
app_cron_log:
- path: /admin/cron/log/{id}
- controller: App\Controller\Cron:log
- defaults: { id: "cron" }
+ path: /admin/cron/log
+ defaults: { _controller: App\Controller\CronController:log }
+
+app_cron_getlog:
+ path: /admin/cron/getlog/{id}
+ defaults: { _controller: App\Controller\CronController:getlog }
#== User ========================================================================================================
app_user:
diff --git a/src/nineskeletor-1.0/config/services.yaml b/src/nineskeletor-1.0/config/services.yaml
index 1baa713..79283a8 100644
--- a/src/nineskeletor-1.0/config/services.yaml
+++ b/src/nineskeletor-1.0/config/services.yaml
@@ -4,13 +4,27 @@
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
- appAlias: '%env(resolve:APP_ALIAS)%'
- appAuth: '%env(resolve:APP_AUTH)%'
- appName: '%env(resolve:APP_NAME)%'
appEnv: '%env(resolve:APP_ENV)%'
+ appSecret: '%env(resolve:APP_SECRET)%'
+
+ appAuth: '%env(resolve:APP_AUTH)%'
+ appAlias: '%env(resolve:APP_ALIAS)%'
+ appName: '%env(resolve:APP_NAME)%'
appCron: '%env(resolve:APP_CRON)%'
+ appMasteridentity: '%env(resolve:APP_MASTERIDENTITY)%'
+ appMasterurl: '%env(resolve:APP_MASTERURL)%'
+ appMasterkey: '%env(resolve:APP_MASTERKEY)%'
+
+ databaseName: '%env(resolve:DATABASE_NAME)%'
+ databaseUser: '%env(resolve:DATABASE_USER)%'
+ databasePassword: '%env(resolve:DATABASE_PASSWORD)%'
+ databaseHost: '%env(resolve:DATABASE_HOST)%'
+
appMailmethod: '%env(resolve:MAILER_METHOD)%'
+ appMailurl: '%env(resolve:MAILER_URL)%'
appMailnoreply: '%env(resolve:MAILER_NOREPLY)%'
+
+ ldapModel: '%env(resolve:LDAP_MODEL)%'
ldapHost: '%env(resolve:LDAP_HOST)%'
ldapPort: '%env(resolve:LDAP_PORT)%'
ldapUser: '%env(resolve:LDAP_USER)%'
@@ -20,7 +34,10 @@ parameters:
ldapFirstname: '%env(resolve:LDAP_FIRSTNAME)%'
ldapLastname: '%env(resolve:LDAP_LASTNAME)%'
ldapEmail: '%env(resolve:LDAP_EMAIL)%'
+ ldapFiltergroup: '%env(resolve:LDAP_FILTERGROUP)%'
+ ldapFilteruser: '%env(resolve:LDAP_FILTERUSER)%'
ldapAdmins: '%env(json:LDAP_ADMINS)%'
+
casHost: '%env(resolve:CAS_HOST)%'
casPort: '%env(resolve:CAS_PORT)%'
casPath: '%env(resolve:CAS_PATH)%'
@@ -29,6 +46,10 @@ parameters:
casLastname: '%env(resolve:CAS_LASTNAME)%'
casFirstname: '%env(resolve:CAS_FIRSTNAME)%'
+ proxyUser: '%env(resolve:PROXY_USE)%'
+ proxyHost: '%env(resolve:PROXY_HOST)%'
+ proxyPort: '%env(resolve:PROXY_PORT)%'
+
services:
# default configuration for services in *this* file
_defaults:
diff --git a/src/nineskeletor-1.0/scripts/.env.model b/src/nineskeletor-1.0/scripts/.env.model
index 09bdfc9..ed1adf7 100644
--- a/src/nineskeletor-1.0/scripts/.env.model
+++ b/src/nineskeletor-1.0/scripts/.env.model
@@ -1,36 +1,19 @@
-# In all environments, the following files are loaded if they exist,
-# the latter taking precedence over the former:
-#
-# * .env contains default values for the environment variables needed by the app
-# * .env.local uncommitted file with local overrides
-# * .env.$APP_ENV committed environment-specific defaults
-# * .env.$APP_ENV.local uncommitted environment-specific overrides
-#
-# Real environment variables win over .env files.
-#
-# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
-#
-# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
-# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
-
-###> symfony/framework-bundle ###
-APP_SECRET=52c1cb88ee822cd2643abe29e16a68a6
+# Symfony
+APP_ENV=PROD
+APP_SECRET=changemeinenvlocal
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
-###< symfony/framework-bundle ###
-###> symfony/mailer ###
-# MAILER_DSN=smtp://localhost
-###< symfony/mailer ###
-
-###< doctrine/doctrine-bundle ###
# Basic
+APP_WEBURL=
+APP_MASTERIDENTITY=LDAP
+APP_AUTH=MYSQL
APP_ALIAS=
APP_NAME=
-APP_AUTH=MYSQL
-APP_ENV=PROD
APP_CRON=true
+APP_MASTERURL=
+APP_MASTERKEY=
# BDD
DATABASE_NAME=
@@ -38,6 +21,27 @@ DATABASE_USER=
DATABASE_PASSWORD=
DATABASE_HOST=
+
+# MAIL sendmail / smtp
+MAILER_METHOD=sendmail
+MAILER_URL=
+MAILER_NOREPLY=noreply@noreply.fr
+
+
+# LDAP
+LDAP_MODEL=open
+LDAP_HOST=
+LDAP_PORT=
+LDAP_USER=
+LDAP_PASSWORD=
+LDAP_BASEDN=
+LDAP_USERNAME=uid
+LDAP_FIRSTNAME=givenname
+LDAP_LASTNAME=sn
+LDAP_EMAIL=mail
+LDAP_ADMINS='["admin"]'
+
+
# If APP_AUTH = CAS
CAS_HOST=
CAS_PORT=
@@ -46,3 +50,9 @@ CAS_USERNAME=username
CAS_EMAIL=email
CAS_LASTNAME=lastname
CAS_FIRSTNAME=firstname
+
+
+# Proxy
+PROXY_USE=false
+PROXY_HOST=
+PROXY_PORT=
\ No newline at end of file
diff --git a/src/nineskeletor-1.0/scripts/genkey.sh b/src/nineskeletor-1.0/scripts/genkey.sh
index 11b53f7..e1b6801 100755
--- a/src/nineskeletor-1.0/scripts/genkey.sh
+++ b/src/nineskeletor-1.0/scripts/genkey.sh
@@ -1,12 +1,9 @@
#!/bin/bash
# Se positionner sur la racine du projet
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-cd ${DIR}
-cd ..
-DIR=$(pwd)
+DIR="/var/www/html/nineskeletor/.key"
# Génération d'une clé d'API
-if [ ! -f $DIR/.key ]; then
- openssl rand -hex 32 > $DIR/.key
+if [ ! -f $DIR ]; then
+ openssl rand -hex 32 > $DIR
fi
diff --git a/src/nineskeletor-1.0/src/Command/AppInitCommand.php b/src/nineskeletor-1.0/src/Command/AppInitCommand.php
index 20c909f..addf4d3 100644
--- a/src/nineskeletor-1.0/src/Command/AppInitCommand.php
+++ b/src/nineskeletor-1.0/src/Command/AppInitCommand.php
@@ -23,6 +23,8 @@ class AppInitCommand extends Command
private $output;
private $filesystem;
private $rootlog;
+ private $appname;
+ private $appmailnoreply;
public function __construct(ContainerInterface $container,EntityManagerInterface $em)
{
@@ -43,9 +45,11 @@ class AppInitCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output)
{
- $this->output = $output;
- $this->filesystem = new Filesystem();
- $this->rootlog = $this->container->get('kernel')->getProjectDir()."/../var/log/";
+ $this->output = $output;
+ $this->filesystem = new Filesystem();
+ $this->rootlog = $this->container->get('kernel')->getProjectDir()."/../var/log/";
+ $this->appname = $this->container->getParameter('appName');
+ $this->appmailnoreply = $this->container->getParameter('appMailnoreply');
$output->writeln('APP = Default Data');
@@ -73,10 +77,10 @@ class AppInitCommand extends Command
$entity->setId(0);
$entity->setUsername("admin");
$entity->setPassword("admin");
- $entity->setFirstname("schedule");
- $entity->setLastname("admin");
- $entity->setEmail("admin@noreply@com");
- $entity->setRoles(["ROLE_ADMIN","ROLE_USER"]);
+ $entity->setFirstname($this->appname);
+ $entity->setLastname("Admin");
+ $entity->setEmail($this->appmailnoreply);
+ $entity->setRoles(["ROLE_ADMIN"]);
$entity->setAvatar("admin.jpg");
$this->em->persist($entity);
}
diff --git a/src/nineskeletor-1.0/src/Command/CronInitCommand.php b/src/nineskeletor-1.0/src/Command/CronInitCommand.php
index ad28771..6c55ab4 100644
--- a/src/nineskeletor-1.0/src/Command/CronInitCommand.php
+++ b/src/nineskeletor-1.0/src/Command/CronInitCommand.php
@@ -105,7 +105,7 @@ class CronInitCommand extends Command
$nextdate=$entity->getSubmitdate();
$nextdate->setTime(3,0);
$entity->setCommand("app:synchroUsers");
- $entity->setDescription("Synchronisation des Comptes Utilisateurs");
+ $entity->setDescription("Synchronisation des comptes utilisateurs");
$entity->setId(100);
$entity->setStatut(2);
$entity->setRepeatcall(0);
@@ -116,90 +116,16 @@ class CronInitCommand extends Command
$this->em->persist($entity);
}
-
- /*
-
- // Job Récupératoin la table de référence des articles
- // Toute les 1mn
- $entity = $this->em->getRepository('App:Cron')->find(10);
- if(!$entity) {
- $entity = new Cron;
- $entity->setId(10);
- $entity->setCommand("app:CrousGo");
- $entity->setDescription("Récupératoin des commandes CROUS & GO");
- $entity->setStatut(2);
- $entity->setRepeatcall(0);
- $entity->setRepeatexec(0);
- $entity->setRepeatinterval(60);
- $entity->setNextexecdate($entity->getSubmitdate());
- $this->em->persist($entity);
- }
-
- // Job Fermeture automatique des guichets
- // Toute les 1mn
- $entity = $this->em->getRepository('App:Cron')->find(20);
- if(!$entity) {
- $entity = new Cron;
- $entity->setId(20);
- $entity->setCommand("app:FermetureGuichet");
- $entity->setDescription("Fermeture automatique des guichets");
- $entity->setStatut(2);
- $entity->setRepeatcall(0);
- $entity->setRepeatexec(0);
- $entity->setRepeatinterval(60);
- $entity->setNextexecdate($entity->getSubmitdate());
- $this->em->persist($entity);
- }
-
- // Job Récupératoin la table de référence des articles
- // Toute les 24h à 3h00
- $entity = $this->em->getRepository('App:Cron')->find(1000);
+ // Job Dump
+ // Toute les 24h à 2h00
+ $entity = $this->em->getRepository('App:Cron')->find(220);
if(!$entity) {
$entity = new Cron;
$nextdate=$entity->getSubmitdate();
- $nextdate->setTime(3,0);
-
- $entity->setId(1000);
- $entity->setCommand("app:CodeArticle");
- $entity->setDescription("Récupératoin la table de référence des articles");
- $entity->setStatut(2);
- $entity->setRepeatcall(0);
- $entity->setRepeatexec(0);
- $entity->setRepeatinterval(86400);
- $entity->setNextexecdate($nextdate);
- $this->em->persist($entity);
- }
-
- // Job reinit des piles à 0
- // Toute les 24h à 3h00
- $entity = $this->em->getRepository('App:Cron')->find(1010);
- if(!$entity) {
- $entity = new Cron;
- $nextdate=$entity->getSubmitdate();
- $nextdate->setTime(3,0);
-
- $entity->setId(1010);
- $entity->setCommand("app:RazPile");
- $entity->setDescription("Remet les piles des services à 0");
- $entity->setStatut(2);
- $entity->setRepeatcall(0);
- $entity->setRepeatexec(0);
- $entity->setRepeatinterval(86400);
- $entity->setNextexecdate($nextdate);
- $this->em->persist($entity);
- }
-
- // Job reinit des piles à 0
- // Toute les 24h à 3h00
- $entity = $this->em->getRepository('App:Cron')->find(1020);
- if(!$entity) {
- $entity = new Cron;
- $nextdate=$entity->getSubmitdate();
- $nextdate->setTime(3,0);
-
- $entity->setId(1020);
- $entity->setCommand("app:RazCommande");
- $entity->setDescription("Cloture et Purge des Commandes");
+ $nextdate->setTime(2,0);
+ $entity->setCommand("app:dumpBdd");
+ $entity->setDescription("Sauvegarde de la BDD");
+ $entity->setId(220);
$entity->setStatut(2);
$entity->setRepeatcall(0);
$entity->setRepeatexec(0);
@@ -207,7 +133,6 @@ class CronInitCommand extends Command
$entity->setNextexecdate($nextdate);
$this->em->persist($entity);
}
- */
// On flush
$this->em->flush();
diff --git a/src/nineskeletor-1.0/src/Command/DumpBddCommand.php b/src/nineskeletor-1.0/src/Command/DumpBddCommand.php
new file mode 100644
index 0000000..acba59b
--- /dev/null
+++ b/src/nineskeletor-1.0/src/Command/DumpBddCommand.php
@@ -0,0 +1,92 @@
+container = $container;
+ $this->em = $em;
+ }
+
+ protected function configure()
+ {
+ $this
+ ->setName('app:dumpBdd')
+ ->setDescription('Sauvegarde de la BDD')
+ ->setHelp('Sauvegarde de la BDD')
+ ->addArgument('cronid', InputArgument::OPTIONAL, 'ID Cron Job')
+ ->addArgument('lastchance', InputArgument::OPTIONAL, 'Lastchance to run the cron')
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->output = $output;
+ $this->filesystem = new Filesystem();
+ $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/log/";
+ $alias = $this->container->getParameter('appAlias');
+
+ $this->writelnred('');
+ $this->writelnred('== app:dumpBdd');
+ $this->writelnred('==========================================================================================================');
+
+ $this->datahost = $this->container->getParameter('databaseHost');
+ $this->database = $this->container->getParameter('databaseName') ;
+ $this->username = $this->container->getParameter('databaseUser') ;
+ $this->password = $this->container->getParameter('databasePassword') ;
+
+ $cmd = sprintf('mysqldump -h %s -B %s -u %s --password=%s'
+ , $this->datahost
+ , $this->database
+ , $this->username
+ , $this->password
+ );
+
+ $result = $this->runCommand($cmd);
+ if($result['exit_status'] == 0) {
+ $this->filesystem->dumpFile($this->rootlog.$alias.".sql", $result['output']);
+ }
+
+ $this->writeln('');
+ return 1;
+ }
+
+ protected function runCommand($command)
+ {
+ $command .=" >&1";
+ exec($command, $output, $exit_status);
+ return array(
+ "output" => $output
+ , "exit_status" => $exit_status
+ );
+ }
+
+ private function writelnred($string) {
+ $this->output->writeln(''.$string.'>');
+ $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
+ }
+ private function writeln($string) {
+ $this->output->writeln($string);
+ $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
+ }
+}
diff --git a/src/nineskeletor-1.0/src/Command/PurgeFileCommand.php b/src/nineskeletor-1.0/src/Command/PurgeFileCommand.php
index 3de5bb4..e43f3a0 100644
--- a/src/nineskeletor-1.0/src/Command/PurgeFileCommand.php
+++ b/src/nineskeletor-1.0/src/Command/PurgeFileCommand.php
@@ -43,7 +43,7 @@ class PurgeFileCommand extends Command
{
$this->output = $output;
$this->filesystem = new Filesystem();
- $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/";
+ $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/log/";
$alias = $this->container->getParameter('appAlias');
$this->writelnred('');
diff --git a/src/nineskeletor-1.0/src/Command/SendMailCommand.php b/src/nineskeletor-1.0/src/Command/SendMailCommand.php
index c3b2833..5861a43 100644
--- a/src/nineskeletor-1.0/src/Command/SendMailCommand.php
+++ b/src/nineskeletor-1.0/src/Command/SendMailCommand.php
@@ -44,7 +44,7 @@ class SendMailCommand extends Command
{
$this->output = $output;
$this->filesystem = new Filesystem();
- $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/";
+ $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/log/";
$this->writelnred('');
$this->writelnred('== app:sendMail');
diff --git a/src/nineskeletor-1.0/src/Command/SynchroUsersCommand.php b/src/nineskeletor-1.0/src/Command/SynchroUsersCommand.php
index e3706a1..e690f57 100644
--- a/src/nineskeletor-1.0/src/Command/SynchroUsersCommand.php
+++ b/src/nineskeletor-1.0/src/Command/SynchroUsersCommand.php
@@ -23,6 +23,7 @@ class SynchroUsersCommand extends Command
private $rootlog;
private $ldap;
private $ldap_basedn;
+ private $ldapgroups=[];
public function __construct(ContainerInterface $container,EntityManagerInterface $em)
{
@@ -47,7 +48,7 @@ class SynchroUsersCommand extends Command
{
$this->output = $output;
$this->filesystem = new Filesystem();
- $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/logs/";
+ $this->rootlog = $this->container->get('kernel')->getRootDir()."/../var/log/";
$this->writelnred('');
$this->writelnred('== app:synchroUsers');
@@ -66,6 +67,16 @@ class SynchroUsersCommand extends Command
if($simulate) $this->writeln('** SIMULATION');
else $this->writeln('** REEL');
+ // Synchro
+ if($this->container->getParameter('appMasteridentity')=="LDAP")
+ $this->synchroLdap($simulate);
+ else
+ $this->synchroNinegate($simulate);
+
+ return 1;
+ }
+
+ protected function synchroLdap($simulate) {
$this->writeln('');
$this->writeln('=====================================================');
$this->writeln('== SYNCHONISATION ANNUAIRE ==========================');
@@ -85,43 +96,57 @@ class SynchroUsersCommand extends Command
$ldap_lastname = $this->container->getParameter('ldapLastname');
$ldap_email = $this->container->getParameter('ldapEmail');
$ldap_admins = $this->container->getParameter('ldapAdmins');
+ $ldap_model = $this->container->getParameter('ldapModel');
$fieldstoread = array($ldap_username,$ldap_firstname,$ldap_lastname,$ldap_email);
$ldapusers = array();
$ldapmails = array();
+
- // Classes
- $this->writeln('');
- $this->writeln('== CLASSES ==========================================');
- $results = $this->ldap->search("type=Classe", ['cn','description','gidNumber'], $this->ldap_basedn);
- foreach($results as $result) {
- $cn=$result["cn"];
- $ldapfilter="(|(&(type=Classe)(cn=$cn))(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))";
+ if($ldap_model=="scribe") {
+ $this->writeln('');
+ $this->writeln('== SCRIBE ===========================================');
- $label="CLASSE = ".$result["cn"];
- $this->writeln(" - $label");
- if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
+ // Classes
+ $this->writeln('');
+ $this->writeln('== CLASSES ==========================================');
+ $results = $this->ldap->search("type=Classe", ['cn','description','gidNumber'], $this->ldap_basedn);
+ foreach($results as $result) {
+ $cn=$result["cn"];
+ $ldapfilter="(|(&(type=Classe)(cn=$cn))(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))";
+
+ $label="CLASSE = ".$result["cn"];
+ $this->writeln(" - $label");
+ if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
+ }
+
+ // Options
+ $this->writeln('');
+ $this->writeln('== OPTIONS ==========================================');
+ $results = $this->ldap->search("type=Option", ['cn','description','gidNumber'], $this->ldap_basedn);
+ foreach($results as $result) {
+ $cn=$result["cn"];
+ $ldapfilter="(|(&(type=Option)(cn=$cn))(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))";
+
+ $label="OPTION = ".$result["cn"];
+ $this->writeln(" - $label");
+ if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
+ }
+
+ $ldap_filtergroup="(type=Groupe)";
+ $ldap_filteruser="(&(uid=*)(objectclass=inetOrgPerson)(!(description=Computer)))";
}
-
- // Options
- $this->writeln('');
- $this->writeln('== OPTIONS ==========================================');
- $results = $this->ldap->search("type=Option", ['cn','description','gidNumber'], $this->ldap_basedn);
- foreach($results as $result) {
- $cn=$result["cn"];
- $ldapfilter="(|(&(type=Option)(cn=$cn))(&(type=Equipe)(cn=profs-$cn))(&(ENTPersonProfils=Administratif)(divcod=$cn)))";
-
- $label="OPTION = ".$result["cn"];
- $this->writeln(" - $label");
- if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
+ else {
+ $ldap_filtergroup=$this->container->getParameter('ldapFiltergroup');
+ $ldap_filteruser=$this->container->getParameter('ldapFilteruser');
}
// Groupes
$this->writeln('');
$this->writeln('== GROUPES ==========================================');
- $results = $this->ldap->search("type=Groupe", ['cn','description','gidNumber'], $this->ldap_basedn);
+ $results = $this->ldap->search($ldap_filtergroup, ['cn','description','gidNumber'], $this->ldap_basedn);
foreach($results as $result) {
$cn=$result["cn"];
- $ldapfilter="(&(type=Groupe)(cn=$cn))";
+ $ldapfilter="(&(&".$ldap_filtergroup.")(cn=$cn))";
$label="GROUPE = ".$result["cn"];
$this->writeln(" - $label");
@@ -141,11 +166,12 @@ class SynchroUsersCommand extends Command
// Sur l'ensemble des utilisateurs de l'anuaire
$this->writeln("== Récupération des utilisateurs de l'annuaire");
- $results = $this->ldap->search("(&(uid=*)(objectclass=inetOrgPerson)(!(description=Computer)))", $fieldstoread, $this->ldap_basedn);
+ $results = $this->ldap->search($ldap_filteruser, $fieldstoread, $this->ldap_basedn);
$nbuserstotal=count($results);
$nbusers=0;
$tberrors=[];
+
// Pour chaque utilisateur ldap
$this->writeln('== Traitement des utilisateurs');
foreach($results as $result) {
@@ -224,6 +250,8 @@ class SynchroUsersCommand extends Command
$groups=$this->em->getRepository('App:Group')->findAll();
foreach($groups as $group) {
+ if(!$group->getldapfilter()) continue;
+
$ldapusersgroup=array();
$ldapfilter=$group->getLdapfilter();
@@ -325,7 +353,61 @@ class SynchroUsersCommand extends Command
}
$this->writeln('');
- return 1;
+ $this->writeln('== GROUPS ============================================');
+ $groups=$this->em->getRepository("App:Group")->findAll();
+ foreach($groups as $group) {
+ if(!$group->getLdapfilter()) continue;
+ if(!in_array($group->getId(),$this->ldapgroups)) {
+ $this->writeln(" - Suppression dans Bundle >> ".$group->getName());
+ if(!$simulate) {
+ $this->em->remove($group);
+ $this->em->flush();
+
+ }
+ }
+ }
+
+ $this->writeln('');
+ }
+
+
+
+ protected function synchroNinegate($simulate) {
+ $this->writeln('');
+ $this->writeln('=====================================================');
+ $this->writeln('== SYNCHONISATION NINEGATE ==========================');
+ $this->writeln('=====================================================');
+
+ $this->writeln('');
+ $this->writeln('=====================================================');
+ $this->writeln('== SYNCHONISATION NINEGATE TO BUNDLE ================');
+ $this->writeln('=====================================================');
+
+ $appmasterurl = $this->getParameter("appmasterurl");
+ if(stripos($appmasterurl,"/")===0)
+ $url="https://".$this->getParameter("appWeburl").$appmasterurl;
+ else
+ $url=$masterurl;
+
+ $indomaine = (stripos($url,$this->getParameter("appWeburl"))!==false);
+
+ // Recherche des élèments de masterIdentify
+ $headers = ['Accept' => 'application/json'];
+ $query = [];
+
+ /* si hor domaine on utilise le proxy si proxy il y a */
+ if(!$indomaine) {
+ $PROXYactivate = $em->getRepository("CadolesCoreBundle:Config")->find("PROXYactivate")->getValue();
+ if($PROXYactivate) {
+ $PROXYserver = $em->getRepository("CadolesCoreBundle:Config")->find("PROXYserver")->getValue();
+ $PROXYport = $em->getRepository("CadolesCoreBundle:Config")->find("PROXYport")->getValue();
+ \Unirest\Request::proxy($PROXYserver, $PROXYport, CURLPROXY_HTTP, true);
+ }
+ }
+
+ // Récupération des informations utilisateurs issus du masteridentity
+ $response = \Unirest\Request::get($url.'/rest/user/'.$masterapikey.'/'.$user->getUsername(),$headers,$query);
+
}
private function writelnred($string) {
@@ -347,7 +429,9 @@ class SynchroUsersCommand extends Command
$group->setLdapfilter($ldapfilter);
$this->em->persist($group);
- $this->em->flush();
+ $this->em->flush();
+
+ array_push($this->ldapgroups,$group->getId());
}
protected function addtoGroup($user,$group) {
@@ -373,7 +457,7 @@ class SynchroUsersCommand extends Command
$ldapfilter="(|(&(uid=".$user->getUsername().")(ENTPersonProfils=enseignant))(&(uid=".$user->getUsername().")(typeadmin=0))(&(uid=".$user->getUsername().")(typeadmin=2)))";
$results = $this->ldap->search($ldapfilter, ['uid'], $this->ldap_basedn);
if($results) $user->setRoles(["ROLE_MASTER"]);
- else $user->setRoles(["ROLE_STUDENT"]);
+ else $user->setRoles(["ROLE_USER"]);
}
$this->em->persist($user);
diff --git a/src/nineskeletor-1.0/src/Controller/CronController.php b/src/nineskeletor-1.0/src/Controller/CronController.php
index 4ade2f0..7f67661 100644
--- a/src/nineskeletor-1.0/src/Controller/CronController.php
+++ b/src/nineskeletor-1.0/src/Controller/CronController.php
@@ -11,6 +11,8 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\HttpFoundation\BinaryFileResponse;
+use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use App\Entity\Cron as Entity;
use App\Form\CronType as Form;
@@ -70,53 +72,27 @@ class CronController extends AbstractController
]);
}
- public function execAction(Request $request, $id)
+ public function log()
+ {
+ return $this->render($this->render.'logs.html.twig', [
+ 'useheader' => true,
+ 'usesidebar' => true,
+ ]);
+ }
+
+ public function getlog(Request $request, $id)
{
- set_time_limit(0);
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository($this->labelentity)->find($id);
-
- if (!$entity) {
- throw $this->createNotFoundException('Unable to find entity.');
- }
-
- $kernel = $this->get('kernel');
- $application = new Application($kernel);
- $application->setAutoExit(false);
- $command = $application->find($entity->getCommand());
- $jsonparameter=json_decode($entity->getJsonargument(),true);
- $parameter = ($jsonparameter?new ArrayInput($jsonparameter):new ArrayInput([]));
-
-
- $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL,false);
- $command->run($parameter, $output);
- $content = $output->fetch();
-
- return $this->render('CadolesCoreBundle:Core:command.html.twig', [
- 'useheader' => true,
- 'usemenu' => false,
- 'usesidebar' => true,
- "title" => $entity->getDescription(),
- "return_path" =>"cadoles_cron_config",
- "content" =>$content
- ]);
- }
-
- public function logAction(Request $request, $id)
- {
- $kernel = $this->get('kernel');
- $path = $this->get('kernel')->getRootDir() . '/../var/logs/'.$id.'.log';
- $content = file_get_contents($path);
-
- return $this->render('CadolesCronBundle:Cron:logs.html.twig', [
- 'useheader' => true,
- 'usemenu' => false,
- 'usesidebar' => true,
- "title" => "LOG = ".$id,
- "content" => $content
- ]);
- }
+ $path = $this->getParameter('kernel.project_dir');
+ if($id=="dump")
+ $file = $path . '/var/log/' . $this->getParameter("appAlias") . '.sql';
+ else
+ $file = $path . '/var/log/'.$id.'.log';
+
+ $response = new BinaryFileResponse($file);
+ $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);
+ return $response;
+ }
protected function getErrorForm($id,$form,$request,$data,$mode) {
diff --git a/src/nineskeletor-1.0/src/Form/UserType.php b/src/nineskeletor-1.0/src/Form/UserType.php
index 06ee0e3..5adf5a2 100644
--- a/src/nineskeletor-1.0/src/Form/UserType.php
+++ b/src/nineskeletor-1.0/src/Form/UserType.php
@@ -56,8 +56,8 @@ class UserType extends AbstractType
if($options["mode"]!="profil") {
$choices=[];
$choices['Administrateur']='ROLE_ADMIN';
- $choices['Professeur']='ROLE_MASTER';
- $choices['Elève']='ROLE_STUDENT';
+ $choices['Modérateur']='ROLE_MODO';
+ $choices['Master']='ROLE_MASTER';
$choices['Utilisateur']='ROLE_USER';
$builder->add('roles',
diff --git a/tmpl/nineskeletor-env.local b/tmpl/nineskeletor-env.local
index d4b4fe3..38974ae 100644
--- a/tmpl/nineskeletor-env.local
+++ b/tmpl/nineskeletor-env.local
@@ -1,24 +1,33 @@
-# Basic = Redefine local
+# SYMFONY
+APP_ENV=PROD
+APP_SECRET=%%pwdreader("",%%nineskeletor_api_key)
+#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
+#TRUSTED_HOSTS='^(localhost|example\.com)$'
+
+
+# BASIC
+APP_WEBURL=%%web_url
+APP_AUTH=CAS
APP_ALIAS=nineskeletor
APP_NAME=Nineskeletor
-APP_ENV=prod
-APP_SECRET=%%pwdreader("","/var/www/html/nineskeletor/.key")
-APP_AUTH=CAS
+APP_CRON=true
+APP_MASTERIDENTITY=%%nineskeletor_masteridentity
+%if %%getVar("nineskeletor_masteridentity", 'LDAP') == "LDAP"
+APP_MASTERURL=
+APP_MASTERKEY=
+%else
+APP_MASTERURL=%%nineskeletor_urlidentity
+APP_MASTERKEY=%%nineskeletor_apikeyidentity
+%end if
-# MAIL sendmail / smtp
-MAILER_METHOD=sendmail
-MAILER_URL=
-MAILER_NOREPLY=noreply@noreply.fr
-
-
-# Bdd = Redefine local
+# BDD
DATABASE_NAME=nineskeletor
DATABASE_USER=nineskeletor
DATABASE_PASSWORD=tochange
-%if %%getVar("ninegate_db_mode", 'non') == "externe"
-DATABASE_HOST=%%ninegate_dbserver
-%else if %%getVar("ninegate_db_mode", 'non') == "default"
+%if %%getVar("nineskeletor_db_mode", 'non') == "externe"
+DATABASE_HOST=%%nineskeletor_dbserver
+%else if %%getVar("nineskeletor_db_mode", 'non') == "default"
%set dbhost = %%getVar('edb_host', 'non')
%if %%dbhost == 'non' and %%mode_conteneur_actif == 'oui':
DATABASE_HOST=%%adresse_ip_mysql
@@ -34,7 +43,67 @@ DATABASE_HOST=%%adresse_ip_mysql
%end if
-# CAS = Redefine local
+# MAIL sendmail / smtp
+%if %%getVar("nineskeletor_activer_localmail", "oui") == "oui"
+MAILER_METHOD=sendmail
+MAILER_URL=
+%else
+MAILER_METHOD=smtp
+MAILER_URL=smtp://%%nineskeletor_smtphost:%%nineskeletor_smtpport?encryption=%%nineskeletor_smtpencryption&auth_mode=%%nineskeletor_smtpauthmode&username=%%nineskeletor_smtpuser&password=%%nineskeletor_smtppwd
+%end if
+MAILER_NOREPLY=noreply@noreply.fr
+
+
+# LDAP
+%if %%getVar("nineskeletor_masteridentity", 'LDAP') == "LDAP"
+LDAP_MODEL=%%nineskeletor_ldaptemplate
+%else
+LDAP_MODEL=open
+%end if
+LDAP_HOST=%%adresse_ip_ldap
+LDAP_PORT=%%ldap_port
+LDAP_USER=%%ldap_reader
+LDAP_PASSWORD=%%pwdreader("",%%ldap_reader_passfile)
+LDAP_BASEDN=%%ldap_base_dn
+%if %%getVar("nineskeletor_ldaptemplate", 'scribe') == "scribe"
+LDAP_USERNAME=uid
+LDAP_FIRSTNAME=givenname
+LDAP_LASTNAME=sn
+LDAP_EMAIL=mail
+LDAP_FILTERGROUP=(cn=*)
+LDAP_FILTERUSER=(uid=*)
+%else
+LDAP_USERNAME=%%nineskeletor_ldapuid
+LDAP_FIRSTNAME=%%nineskeletor_ldapfirstname
+LDAP_LASTNAME=%%nineskeletor_ldaplastname
+LDAP_EMAIL=%%nineskeletor_ldapmail
+LDAP_FILTERGROUP=%%nineskeletor_ldapfiltergroup
+LDAP_FILTERUSER=%%nineskeletor_ldapfilteruser
+%end if
+%if %%getVar("activer_addadmin", "non") == "non"
+LDAP_ADMINS='["admin"]'
+%else
+LDAP_ADMINS='["admin","%%uid_addadmin"]'
+%end if
+
+
+# CAS
CAS_HOST=%%eolesso_adresse
CAS_PORT=%%eolesso_port
-CAS_PATH=%%eolesso_cas_folder
\ No newline at end of file
+CAS_PATH=%%eolesso_cas_folder
+CAS_USERNAME=username
+CAS_EMAIL=email
+CAS_LASTNAME=lastname
+CAS_FIRSTNAME=firstname
+
+
+# Proxy
+%if %%activer_proxy_client == 'oui'
+PROXY_USE=true
+PROXY_HOST=%%proxy_client_adresse
+PROXY_PORT=%%proxy_client_port
+%else
+PROXY_USE=false
+PROXY_HOST=
+PROXY_PORT=
+%end if
\ No newline at end of file
diff --git a/tmpl/nineskeletor-genkey.sh b/tmpl/nineskeletor-genkey.sh
new file mode 100644
index 0000000..ff6c7ee
--- /dev/null
+++ b/tmpl/nineskeletor-genkey.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# Se positionner sur la racine du projet
+DIR="%%nineskeletor_api_key"
+
+# Génération d'une clé d'API
+if [ ! -f $DIR ]; then
+ openssl rand -hex 32 > $DIR
+fi