This commit is contained in:
root 2020-07-02 15:00:08 +02:00
parent 04273d0596
commit 38239d4b02
16 changed files with 575 additions and 242 deletions

View File

@ -16,44 +16,165 @@
<!-- template --> <!-- template -->
<file filelist='nineskeletor' name='/etc/apache2/sites-available/nineskeletor' source='nineskeletor-apache.conf' /> <file filelist='nineskeletor' name='/etc/apache2/sites-available/nineskeletor' source='nineskeletor-apache.conf' />
<file filelist='nineskeletor' name='/var/www/html/nineskeletor/.env.local' source='nineskeletor-env.local' rm='True'/> <file filelist='nineskeletor' name='/var/www/html/nineskeletor/.env.local' source='nineskeletor-env.local' rm='True'/>
<file filelist='nineskeletor' name='/var/www/html/nineskeletor/scripts/proxy.sh' source='nineskeletor-proxy.sh' rm='True'/> <file filelist='nineskeletor' name='/var/www/html/nineskeletor/scripts/proxy.sh' source='nineskeletor-proxy.sh' rm='True' mode="700" />
<file filelist='nineskeletor' name='/var/www/html/nineskeletor/scripts/genkey.sh' source='nineskeletor-genkey.sh' rm='True' mode="700" />
<file filelist='ninegate' name='/etc/cron.d/nineskeletor' source='nineskeletor.cron' rm='True'/>
</container> </container>
</containers> </containers>
<variables> <variables>
<family name='applications web'> <family name='nineskeletor'>
<variable name="ninegate_test_ninegate" type="oui/non" hidden='True' exists='False'><value>non</value></variable>
<variable name='activer_nineskeletor' type='oui/non' description='Activer nineskeletor'> <variable name='activer_nineskeletor' type='oui/non' description='Activer nineskeletor'>
<value>oui</value> <value>oui</value>
</variable> </variable>
<variable type='string' name='nineskeletor_api_key' description="Fichier déclarant la clé d'accès API" mandatory='True'><value>/var/www/html/nineskeletor/.key</value></variable>
<variable type='string' name='nineskeletor_mode_auth' description="Mode Authentification" mandatory='True'><value>CAS</value></variable>
<variable type='string' name='nineskeletor_masteridentity' description="Maître de l'Identité" mandatory='True'><value>Ninegate</value></variable>
<variable type='string' name='nineskeletor_urlidentity' description="URL complète de l'Identité" mandatory='True'><value>/ninegate</value></variable>
<variable type='string' name='nineskeletor_apikeyidentity' description="API Key de l'Identité" mandatory='True'><value>APIKeyNinegate</value></variable>
<!-- LDAP -->
<variable type='string' name='nineskeletor_ldaptemplate' description="Modèle d'annuaire"><value>scribe</value></variable>
<variable type='string' name='nineskeletor_ldapfiltergroup' description="Filtre LDAP des groupes (bien mettre votre filtre entre parenthèses)" mandatory='True'><value>(&amp;(ObjectClass=posixGroup)(cn=*))</value></variable>
<variable type='string' name='nineskeletor_ldapfilteruser' description="Filtre LDAP des utilisateurs (bien mettre votre filtre entre parenthèses)" mandatory='True'><value>(&amp;(ObjectClass=person)(uid=*))</value></variable>
<variable type='string' name='nineskeletor_ldapuid' description="Attribut LDAP uid" mandatory='True'><value>uid</value></variable>
<variable type='string' name='nineskeletor_ldapfirstname' description="Attribut LDAP firstname" mandatory='True'><value>givenname</value></variable>
<variable type='string' name='nineskeletor_ldaplastname' description="Attribut LDAP lastname" mandatory='True'><value>sn</value></variable>
<variable type='string' name='nineskeletor_ldapmail' description="Attribut LDAP email" mandatory='True'><value>mail</value></variable>
<!-- EMAIL -->
<variable type='string' name='nineskeletor_noreply' description='Adresse mail utilisé pour le noreply' mandatory='True' />
<variable type="oui/non" name='nineskeletor_activer_localmail' description="Utiliser le serveur d'envoi de mail local" mandatory='True'>
<value>oui</value>
</variable>
<variable type='string' name='nineskeletor_smtphost' description='Host du serveur SMTP' mandatory='True' />
<variable type='string' name='nineskeletor_smtpport' description='Port du serveur SMTP' mandatory='True' />
<variable type='string' name='nineskeletor_smtpuser' description='Compte du serveur SMTP' mandatory='True' />
<variable type='string' name='nineskeletor_smtppwd' description='Mot de passe associé du compte SMTP' mandatory='True' />
<variable type='string' name='nineskeletor_smtpencryption' description='Type Encryptage du serveur SMTP' mandatory='True' />
<variable type='string' name='nineskeletor_smtpauthmode' description='Mode Authentification du serveur SMTP' mandatory='True' />
<!-- BDD -->
<variable type='string' name='nineskeletor_db_mode' description='Serveur de bases de données à utiliser' mode='expert'/>
<variable type='string' name='nineskeletor_dbserver' description='Adresse du serveur de base de données' mode='expert'/>
<variable type='number' name='nineskeletor_dbport' description="Port d'écoute du serveur de base de données" mode='expert'/>
<variable type='string' name='nineskeletor_allow_hosts' description="Hôtes autorisés à utiliser la base de données" multi='True' mode='expert'/>
<variable type='string' name='nineskeletor_dbuser' description='Utilisateur du serveur de base de données' mode='expert'/>
<variable type='string' name='nineskeletor_dbpass' description='Fichier de mot de passe du serveur' mode='expert'/>
</family> </family>
<family name='nineskeletor' mode='expert'> <separators>
<variable type='string' name='nineskeletor_db_mode' description='Serveur de bases de données à utiliser'/> <separator name="nineskeletor_ldaptemplate">Paramètres associés à l'Annuaire</separator>
<variable type='string' name='nineskeletor_dbserver' description='Adresse du serveur de base de données'/> <separator name="nineskeletor_noreply">Paramètres associés aux Mails</separator>
<variable type='number' name='nineskeletor_dbport' description="Port d'écoute du serveur de base de données"/> <separator name="nineskeletor_db_mode">Paramètres associés à la Base de Données</separator>
<variable type='string' name='nineskeletor_allow_hosts' description="Hôtes authorisés à utiliser la base de données" multi='True'/> </separators>
<variable type='string' name='nineskeletor_dbuser' description='Utilisateur du serveur de base de données'/>
<variable type='string' name='nineskeletor_dbpass' description='Fichier de mot de passe du serveur'/>
<variable type='mail' name='nineskeletor_email_global_notif' description='Email pour envoie de notifications'/>
</family>
</variables> </variables>
<constraints> <constraints>
<!-- AFFICHAGE EN FONCTION DE APACHE -->
<condition name='hidden_if_in' source='activer_apache'> <condition name='hidden_if_in' source='activer_apache'>
<param>non</param> <param>non</param>
<target type='filelist'>nineskeletor</target> <target type='filelist'>nineskeletor</target>
<target type='servicelist'>nineskeletor</target> <target type='servicelist'>nineskeletor</target>
</condition> </condition>
<!-- AFFICHAGE EN FONCTION DE NINESKELETOR -->
<condition name='hidden_if_in' source='activer_nineskeletor'> <condition name='hidden_if_in' source='activer_nineskeletor'>
<param>non</param> <param>non</param>
<target type='variable'>nineskeletor_masteridentity</target>
<target type='variable'>nineskeletor_urlidentity</target>
<target type='variable'>nineskeletor_apikeyidentity</target>
<target type='variable'>nineskeletor_mode_auth</target>
<target type='variable'>nineskeletor_api_key</target>
<target type='variable'>nineskeletor_ldaptemplate</target>
<target type='variable'>nineskeletor_noreply</target>
<target type='variable'>nineskeletor_activer_localmail</target>
<target type='variable'>nineskeletor_smtphost</target>
<target type='variable'>nineskeletor_smtpport</target>
<target type='variable'>nineskeletor_smtpuser</target>
<target type='variable'>nineskeletor_smtppwd</target>
<target type='variable'>nineskeletor_smtpencryption</target>
<target type='variable'>nineskeletor_smtpauthmode</target>
<target type='variable'>nineskeletor_db_mode</target>
<target type='variable'>nineskeletor_dbserver</target>
<target type='variable'>nineskeletor_dbport</target>
<target type='variable'>nineskeletor_allow_hosts</target>
<target type='variable'>nineskeletor_dbuser</target>
<target type='variable'>nineskeletor_dbpass</target>
<target type='filelist'>nineskeletor</target> <target type='filelist'>nineskeletor</target>
<target type='servicelist'>nineskeletor</target> <target type='servicelist'>nineskeletor</target>
</condition> </condition>
<check name='valid_enum' target='nineskeletor_db_mode'>
<param>['default', 'externe', 'local']</param> <!-- AFFICHAGE EN FONCTION DE NINEGATE -->
</check> <fill name='calc_multi_condition' target='nineskeletor_masteridentity'>
<param>oui</param>
<param type='eole' name='condition_1' hidden='False'>ninegate_test_ninegate</param>
<param name='match'>Ninegate</param>
<param name='mismatch'>LDAP</param>
<param name='default_mismatch'>LDAP</param>
</fill>
<!-- AFFICHAGE EN FONCTION DU MASTERIDENTITY -->
<condition name='hidden_if_in' source='nineskeletor_masteridentity'>
<param>LDAP</param>
<target type='variable'>nineskeletor_urlidentity</target>
<target type='variable'>nineskeletor_apikeyidentity</target>
</condition>
<condition name='hidden_if_in' source='nineskeletor_masteridentity'>
<param>Ninegate</param>
<target type='variable'>nineskeletor_ldaptemplate</target>
</condition>
<!-- AFFICHAGE EN FONCTION DU LDAP -->
<condition name='hidden_if_in' source='nineskeletor_ldaptemplate'>
<param>scribe</param>
<target type='variable'>nineskeletor_ldapfiltergroup</target>
<target type='variable'>nineskeletor_ldapfilteruser</target>
<target type='variable'>nineskeletor_ldapuid</target>
<target type='variable'>nineskeletor_ldapfirstname</target>
<target type='variable'>nineskeletor_ldaplastname</target>
<target type='variable'>nineskeletor_ldapmail</target>
</condition>
<!-- AFFICHAGE EN FONCTION DU MAIL -->
<fill name='concat' target='nineskeletor_noreply'>
<param>noreply@</param>
<param type='eole'>domaine_messagerie_etab</param>
</fill>
<condition name='hidden_if_in' source='nineskeletor_activer_localmail'>
<param>oui</param>
<target type='variable'>nineskeletor_smtphost</target>
<target type='variable'>nineskeletor_smtpport</target>
<target type='variable'>nineskeletor_smtpuser</target>
<target type='variable'>nineskeletor_smtppwd</target>
<target type='variable'>nineskeletor_smtpencryption</target>
<target type='variable'>nineskeletor_smtpauthmode</target>
</condition>
<!-- AFFICHAGE EN FONCTION DU MODE DE BDD -->
<condition name='disabled_if_in' source='nineskeletor_db_mode'> <condition name='disabled_if_in' source='nineskeletor_db_mode'>
<param>local</param> <param>local</param>
<target type='variable'>nineskeletor_dbserver</target> <target type='variable'>nineskeletor_dbserver</target>
@ -69,6 +190,32 @@
<target type='variable'>nineskeletor_dbpass</target> <target type='variable'>nineskeletor_dbpass</target>
<target type='variable'>nineskeletor_allow_hosts</target> <target type='variable'>nineskeletor_allow_hosts</target>
</condition> </condition>
<!-- VALID EMUN DES DIFFRENTES COMBO -->
<check name='valid_enum' target='nineskeletor_masteridentity'>
<param>['LDAP','Ninegate']</param>
</check>
<check name='valid_enum' target='nineskeletor_mode_auth'>
<param>['CAS', 'LDAP', 'SQL']</param>
</check>
<check name='valid_enum' target='nineskeletor_ldaptemplate'>
<param>['scribe','open']</param>
</check>
<check name='valid_enum' target='nineskeletor_smtpencryption'>
<param>['tls', 'ssl', 'null']</param>
</check>
<check name='valid_enum' target='nineskeletor_smtpauthmode'>
<param>['plain', 'login', 'cram-md5', 'null']</param>
</check>
<check name='valid_enum' target='nineskeletor_db_mode'>
<param>['default', 'externe', 'local']</param>
</check>
</constraints> </constraints>
<help> <help>

View File

@ -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: access_control:
- { path: ^/user, roles: [ROLE_ADMIN, ROLE_MASTER, ROLE_STUDENT, ROLE_USER] } - { path: ^/user, roles: [ROLE_ADMIN, ROLE_MODO, ROLE_MASTER, ROLE_USER] }
- { path: ^/master, roles: [ROLE_ADMIN, ROLE_MASTER] } - { path: ^/master, roles: [ROLE_ADMIN, ROLE_MODO, ROLE_MASTER] }
- { path: ^/modo, roles: [ROLE_ADMIN, ROLE_MODO] }
- { path: ^/admin, roles: [ROLE_ADMIN] } - { path: ^/admin, roles: [ROLE_ADMIN] }

View File

@ -60,9 +60,12 @@ app_cron_exec:
defaults: { _controller: App\Controller\CronController:exec } defaults: { _controller: App\Controller\CronController:exec }
app_cron_log: app_cron_log:
path: /admin/cron/log/{id} path: /admin/cron/log
controller: App\Controller\Cron:log defaults: { _controller: App\Controller\CronController:log }
defaults: { id: "cron" }
app_cron_getlog:
path: /admin/cron/getlog/{id}
defaults: { _controller: App\Controller\CronController:getlog }
#== User ======================================================================================================== #== User ========================================================================================================
app_user: app_user:

View File

@ -4,13 +4,27 @@
# Put parameters here that don't need to change on each machine where the app is deployed # 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 # https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters: parameters:
appAlias: '%env(resolve:APP_ALIAS)%'
appAuth: '%env(resolve:APP_AUTH)%'
appName: '%env(resolve:APP_NAME)%'
appEnv: '%env(resolve:APP_ENV)%' 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)%' 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)%' appMailmethod: '%env(resolve:MAILER_METHOD)%'
appMailurl: '%env(resolve:MAILER_URL)%'
appMailnoreply: '%env(resolve:MAILER_NOREPLY)%' appMailnoreply: '%env(resolve:MAILER_NOREPLY)%'
ldapModel: '%env(resolve:LDAP_MODEL)%'
ldapHost: '%env(resolve:LDAP_HOST)%' ldapHost: '%env(resolve:LDAP_HOST)%'
ldapPort: '%env(resolve:LDAP_PORT)%' ldapPort: '%env(resolve:LDAP_PORT)%'
ldapUser: '%env(resolve:LDAP_USER)%' ldapUser: '%env(resolve:LDAP_USER)%'
@ -20,7 +34,10 @@ parameters:
ldapFirstname: '%env(resolve:LDAP_FIRSTNAME)%' ldapFirstname: '%env(resolve:LDAP_FIRSTNAME)%'
ldapLastname: '%env(resolve:LDAP_LASTNAME)%' ldapLastname: '%env(resolve:LDAP_LASTNAME)%'
ldapEmail: '%env(resolve:LDAP_EMAIL)%' ldapEmail: '%env(resolve:LDAP_EMAIL)%'
ldapFiltergroup: '%env(resolve:LDAP_FILTERGROUP)%'
ldapFilteruser: '%env(resolve:LDAP_FILTERUSER)%'
ldapAdmins: '%env(json:LDAP_ADMINS)%' ldapAdmins: '%env(json:LDAP_ADMINS)%'
casHost: '%env(resolve:CAS_HOST)%' casHost: '%env(resolve:CAS_HOST)%'
casPort: '%env(resolve:CAS_PORT)%' casPort: '%env(resolve:CAS_PORT)%'
casPath: '%env(resolve:CAS_PATH)%' casPath: '%env(resolve:CAS_PATH)%'
@ -29,6 +46,10 @@ parameters:
casLastname: '%env(resolve:CAS_LASTNAME)%' casLastname: '%env(resolve:CAS_LASTNAME)%'
casFirstname: '%env(resolve:CAS_FIRSTNAME)%' casFirstname: '%env(resolve:CAS_FIRSTNAME)%'
proxyUser: '%env(resolve:PROXY_USE)%'
proxyHost: '%env(resolve:PROXY_HOST)%'
proxyPort: '%env(resolve:PROXY_PORT)%'
services: services:
# default configuration for services in *this* file # default configuration for services in *this* file
_defaults: _defaults:

View File

@ -1,36 +1,19 @@
# In all environments, the following files are loaded if they exist, # Symfony
# the latter taking precedence over the former: APP_ENV=PROD
# APP_SECRET=changemeinenvlocal
# * .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
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 #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)$' #TRUSTED_HOSTS='^(localhost|example\.com)$'
###< symfony/framework-bundle ###
###> symfony/mailer ###
# MAILER_DSN=smtp://localhost
###< symfony/mailer ###
###< doctrine/doctrine-bundle ###
# Basic # Basic
APP_WEBURL=
APP_MASTERIDENTITY=LDAP
APP_AUTH=MYSQL
APP_ALIAS= APP_ALIAS=
APP_NAME= APP_NAME=
APP_AUTH=MYSQL
APP_ENV=PROD
APP_CRON=true APP_CRON=true
APP_MASTERURL=
APP_MASTERKEY=
# BDD # BDD
DATABASE_NAME= DATABASE_NAME=
@ -38,6 +21,27 @@ DATABASE_USER=
DATABASE_PASSWORD= DATABASE_PASSWORD=
DATABASE_HOST= 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 # If APP_AUTH = CAS
CAS_HOST= CAS_HOST=
CAS_PORT= CAS_PORT=
@ -46,3 +50,9 @@ CAS_USERNAME=username
CAS_EMAIL=email CAS_EMAIL=email
CAS_LASTNAME=lastname CAS_LASTNAME=lastname
CAS_FIRSTNAME=firstname CAS_FIRSTNAME=firstname
# Proxy
PROXY_USE=false
PROXY_HOST=
PROXY_PORT=

View File

@ -1,12 +1,9 @@
#!/bin/bash #!/bin/bash
# Se positionner sur la racine du projet # Se positionner sur la racine du projet
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR="/var/www/html/nineskeletor/.key"
cd ${DIR}
cd ..
DIR=$(pwd)
# Génération d'une clé d'API # Génération d'une clé d'API
if [ ! -f $DIR/.key ]; then if [ ! -f $DIR ]; then
openssl rand -hex 32 > $DIR/.key openssl rand -hex 32 > $DIR
fi fi

View File

@ -23,6 +23,8 @@ class AppInitCommand extends Command
private $output; private $output;
private $filesystem; private $filesystem;
private $rootlog; private $rootlog;
private $appname;
private $appmailnoreply;
public function __construct(ContainerInterface $container,EntityManagerInterface $em) public function __construct(ContainerInterface $container,EntityManagerInterface $em)
{ {
@ -46,6 +48,8 @@ class AppInitCommand extends Command
$this->output = $output; $this->output = $output;
$this->filesystem = new Filesystem(); $this->filesystem = new Filesystem();
$this->rootlog = $this->container->get('kernel')->getProjectDir()."/../var/log/"; $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'); $output->writeln('APP = Default Data');
@ -73,10 +77,10 @@ class AppInitCommand extends Command
$entity->setId(0); $entity->setId(0);
$entity->setUsername("admin"); $entity->setUsername("admin");
$entity->setPassword("admin"); $entity->setPassword("admin");
$entity->setFirstname("schedule"); $entity->setFirstname($this->appname);
$entity->setLastname("admin"); $entity->setLastname("Admin");
$entity->setEmail("admin@noreply@com"); $entity->setEmail($this->appmailnoreply);
$entity->setRoles(["ROLE_ADMIN","ROLE_USER"]); $entity->setRoles(["ROLE_ADMIN"]);
$entity->setAvatar("admin.jpg"); $entity->setAvatar("admin.jpg");
$this->em->persist($entity); $this->em->persist($entity);
} }

View File

@ -105,7 +105,7 @@ class CronInitCommand extends Command
$nextdate=$entity->getSubmitdate(); $nextdate=$entity->getSubmitdate();
$nextdate->setTime(3,0); $nextdate->setTime(3,0);
$entity->setCommand("app:synchroUsers"); $entity->setCommand("app:synchroUsers");
$entity->setDescription("Synchronisation des Comptes Utilisateurs"); $entity->setDescription("Synchronisation des comptes utilisateurs");
$entity->setId(100); $entity->setId(100);
$entity->setStatut(2); $entity->setStatut(2);
$entity->setRepeatcall(0); $entity->setRepeatcall(0);
@ -116,52 +116,16 @@ class CronInitCommand extends Command
$this->em->persist($entity); $this->em->persist($entity);
} }
// Job Dump
/* // Toute les 24h à 2h00
$entity = $this->em->getRepository('App:Cron')->find(220);
// 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);
if(!$entity) { if(!$entity) {
$entity = new Cron; $entity = new Cron;
$nextdate=$entity->getSubmitdate(); $nextdate=$entity->getSubmitdate();
$nextdate->setTime(3,0); $nextdate->setTime(2,0);
$entity->setCommand("app:dumpBdd");
$entity->setId(1000); $entity->setDescription("Sauvegarde de la BDD");
$entity->setCommand("app:CodeArticle"); $entity->setId(220);
$entity->setDescription("Récupératoin la table de référence des articles");
$entity->setStatut(2); $entity->setStatut(2);
$entity->setRepeatcall(0); $entity->setRepeatcall(0);
$entity->setRepeatexec(0); $entity->setRepeatexec(0);
@ -170,45 +134,6 @@ class CronInitCommand extends Command
$this->em->persist($entity); $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");
$entity->setStatut(2);
$entity->setRepeatcall(0);
$entity->setRepeatexec(0);
$entity->setRepeatinterval(86400);
$entity->setNextexecdate($nextdate);
$this->em->persist($entity);
}
*/
// On flush // On flush
$this->em->flush(); $this->em->flush();

View File

@ -0,0 +1,92 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
use Symfony\Component\Finder\Finder;
class DumpBddCommand extends Command
{
private $container;
private $em;
private $output;
private $filesystem;
private $rootlog;
private $byexec;
public function __construct(ContainerInterface $container,EntityManagerInterface $em)
{
parent::__construct();
$this->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('<fg=red>'.$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");
}
}

View File

@ -43,7 +43,7 @@ class PurgeFileCommand extends Command
{ {
$this->output = $output; $this->output = $output;
$this->filesystem = new Filesystem(); $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'); $alias = $this->container->getParameter('appAlias');
$this->writelnred(''); $this->writelnred('');

View File

@ -44,7 +44,7 @@ class SendMailCommand extends Command
{ {
$this->output = $output; $this->output = $output;
$this->filesystem = new Filesystem(); $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('');
$this->writelnred('== app:sendMail'); $this->writelnred('== app:sendMail');

View File

@ -23,6 +23,7 @@ class SynchroUsersCommand extends Command
private $rootlog; private $rootlog;
private $ldap; private $ldap;
private $ldap_basedn; private $ldap_basedn;
private $ldapgroups=[];
public function __construct(ContainerInterface $container,EntityManagerInterface $em) public function __construct(ContainerInterface $container,EntityManagerInterface $em)
{ {
@ -47,7 +48,7 @@ class SynchroUsersCommand extends Command
{ {
$this->output = $output; $this->output = $output;
$this->filesystem = new Filesystem(); $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('');
$this->writelnred('== app:synchroUsers'); $this->writelnred('== app:synchroUsers');
@ -66,6 +67,16 @@ class SynchroUsersCommand extends Command
if($simulate) $this->writeln('** SIMULATION'); if($simulate) $this->writeln('** SIMULATION');
else $this->writeln('** REEL'); 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('====================================================='); $this->writeln('=====================================================');
$this->writeln('== SYNCHONISATION ANNUAIRE =========================='); $this->writeln('== SYNCHONISATION ANNUAIRE ==========================');
@ -85,10 +96,16 @@ class SynchroUsersCommand extends Command
$ldap_lastname = $this->container->getParameter('ldapLastname'); $ldap_lastname = $this->container->getParameter('ldapLastname');
$ldap_email = $this->container->getParameter('ldapEmail'); $ldap_email = $this->container->getParameter('ldapEmail');
$ldap_admins = $this->container->getParameter('ldapAdmins'); $ldap_admins = $this->container->getParameter('ldapAdmins');
$ldap_model = $this->container->getParameter('ldapModel');
$fieldstoread = array($ldap_username,$ldap_firstname,$ldap_lastname,$ldap_email); $fieldstoread = array($ldap_username,$ldap_firstname,$ldap_lastname,$ldap_email);
$ldapusers = array(); $ldapusers = array();
$ldapmails = array(); $ldapmails = array();
if($ldap_model=="scribe") {
$this->writeln('');
$this->writeln('== SCRIBE ===========================================');
// Classes // Classes
$this->writeln(''); $this->writeln('');
$this->writeln('== CLASSES =========================================='); $this->writeln('== CLASSES ==========================================');
@ -115,13 +132,21 @@ class SynchroUsersCommand extends Command
if(!$simulate) $this->addmodGroup($label,$ldapfilter,true); if(!$simulate) $this->addmodGroup($label,$ldapfilter,true);
} }
$ldap_filtergroup="(type=Groupe)";
$ldap_filteruser="(&(uid=*)(objectclass=inetOrgPerson)(!(description=Computer)))";
}
else {
$ldap_filtergroup=$this->container->getParameter('ldapFiltergroup');
$ldap_filteruser=$this->container->getParameter('ldapFilteruser');
}
// Groupes // Groupes
$this->writeln(''); $this->writeln('');
$this->writeln('== GROUPES =========================================='); $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) { foreach($results as $result) {
$cn=$result["cn"]; $cn=$result["cn"];
$ldapfilter="(&(type=Groupe)(cn=$cn))"; $ldapfilter="(&(&".$ldap_filtergroup.")(cn=$cn))";
$label="GROUPE = ".$result["cn"]; $label="GROUPE = ".$result["cn"];
$this->writeln(" - $label"); $this->writeln(" - $label");
@ -141,11 +166,12 @@ class SynchroUsersCommand extends Command
// Sur l'ensemble des utilisateurs de l'anuaire // Sur l'ensemble des utilisateurs de l'anuaire
$this->writeln("== Récupération des utilisateurs de l'annuaire"); $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); $nbuserstotal=count($results);
$nbusers=0; $nbusers=0;
$tberrors=[]; $tberrors=[];
// Pour chaque utilisateur ldap // Pour chaque utilisateur ldap
$this->writeln('== Traitement des utilisateurs'); $this->writeln('== Traitement des utilisateurs');
foreach($results as $result) { foreach($results as $result) {
@ -224,6 +250,8 @@ class SynchroUsersCommand extends Command
$groups=$this->em->getRepository('App:Group')->findAll(); $groups=$this->em->getRepository('App:Group')->findAll();
foreach($groups as $group) { foreach($groups as $group) {
if(!$group->getldapfilter()) continue;
$ldapusersgroup=array(); $ldapusersgroup=array();
$ldapfilter=$group->getLdapfilter(); $ldapfilter=$group->getLdapfilter();
@ -325,7 +353,61 @@ class SynchroUsersCommand extends Command
} }
$this->writeln(''); $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) { private function writelnred($string) {
@ -348,6 +430,8 @@ class SynchroUsersCommand extends Command
$this->em->persist($group); $this->em->persist($group);
$this->em->flush(); $this->em->flush();
array_push($this->ldapgroups,$group->getId());
} }
protected function addtoGroup($user,$group) { 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)))"; $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); $results = $this->ldap->search($ldapfilter, ['uid'], $this->ldap_basedn);
if($results) $user->setRoles(["ROLE_MASTER"]); if($results) $user->setRoles(["ROLE_MASTER"]);
else $user->setRoles(["ROLE_STUDENT"]); else $user->setRoles(["ROLE_USER"]);
} }
$this->em->persist($user); $this->em->persist($user);

View File

@ -11,6 +11,8 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use App\Entity\Cron as Entity; use App\Entity\Cron as Entity;
use App\Form\CronType as Form; use App\Form\CronType as Form;
@ -70,52 +72,26 @@ class CronController extends AbstractController
]); ]);
} }
public function execAction(Request $request, $id) public function log()
{ {
set_time_limit(0); return $this->render($this->render.'logs.html.twig', [
$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, 'useheader' => true,
'usemenu' => false,
'usesidebar' => true, 'usesidebar' => true,
"title" => $entity->getDescription(),
"return_path" =>"cadoles_cron_config",
"content" =>$content
]); ]);
} }
public function logAction(Request $request, $id) public function getlog(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', [ $path = $this->getParameter('kernel.project_dir');
'useheader' => true, if($id=="dump")
'usemenu' => false, $file = $path . '/var/log/' . $this->getParameter("appAlias") . '.sql';
'usesidebar' => true, else
"title" => "LOG = ".$id, $file = $path . '/var/log/'.$id.'.log';
"content" => $content
]); $response = new BinaryFileResponse($file);
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);
return $response;
} }

View File

@ -56,8 +56,8 @@ class UserType extends AbstractType
if($options["mode"]!="profil") { if($options["mode"]!="profil") {
$choices=[]; $choices=[];
$choices['Administrateur']='ROLE_ADMIN'; $choices['Administrateur']='ROLE_ADMIN';
$choices['Professeur']='ROLE_MASTER'; $choices['Modérateur']='ROLE_MODO';
$choices['Elève']='ROLE_STUDENT'; $choices['Master']='ROLE_MASTER';
$choices['Utilisateur']='ROLE_USER'; $choices['Utilisateur']='ROLE_USER';
$builder->add('roles', $builder->add('roles',

View File

@ -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_ALIAS=nineskeletor
APP_NAME=Nineskeletor APP_NAME=Nineskeletor
APP_ENV=prod APP_CRON=true
APP_SECRET=%%pwdreader("","/var/www/html/nineskeletor/.key") APP_MASTERIDENTITY=%%nineskeletor_masteridentity
APP_AUTH=CAS %if %%getVar("nineskeletor_masteridentity", 'LDAP') == "LDAP"
APP_MASTERURL=
APP_MASTERKEY=
%else
APP_MASTERURL=%%nineskeletor_urlidentity
APP_MASTERKEY=%%nineskeletor_apikeyidentity
%end if
# MAIL sendmail / smtp # BDD
MAILER_METHOD=sendmail
MAILER_URL=
MAILER_NOREPLY=noreply@noreply.fr
# Bdd = Redefine local
DATABASE_NAME=nineskeletor DATABASE_NAME=nineskeletor
DATABASE_USER=nineskeletor DATABASE_USER=nineskeletor
DATABASE_PASSWORD=tochange DATABASE_PASSWORD=tochange
%if %%getVar("ninegate_db_mode", 'non') == "externe" %if %%getVar("nineskeletor_db_mode", 'non') == "externe"
DATABASE_HOST=%%ninegate_dbserver DATABASE_HOST=%%nineskeletor_dbserver
%else if %%getVar("ninegate_db_mode", 'non') == "default" %else if %%getVar("nineskeletor_db_mode", 'non') == "default"
%set dbhost = %%getVar('edb_host', 'non') %set dbhost = %%getVar('edb_host', 'non')
%if %%dbhost == 'non' and %%mode_conteneur_actif == 'oui': %if %%dbhost == 'non' and %%mode_conteneur_actif == 'oui':
DATABASE_HOST=%%adresse_ip_mysql DATABASE_HOST=%%adresse_ip_mysql
@ -34,7 +43,67 @@ DATABASE_HOST=%%adresse_ip_mysql
%end if %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_HOST=%%eolesso_adresse
CAS_PORT=%%eolesso_port CAS_PORT=%%eolesso_port
CAS_PATH=%%eolesso_cas_folder 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

View File

@ -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