From babf012bb923c5b7de0aec8303db6ca77778eb4d Mon Sep 17 00:00:00 2001 From: Arnaud Fornerot Date: Tue, 7 Dec 2021 14:05:43 +0100 Subject: [PATCH] websocket server by service --- src/ninesurvey-1.0/config/services.yaml | 4 +++- src/ninesurvey-1.0/scripts/websocket.sh | 2 +- src/ninesurvey-1.0/src/Service/ldapService.php | 7 ++++++- tmpl/ninesurvey-env.local | 5 +++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ninesurvey-1.0/config/services.yaml b/src/ninesurvey-1.0/config/services.yaml index c0d9749..d741b88 100644 --- a/src/ninesurvey-1.0/config/services.yaml +++ b/src/ninesurvey-1.0/config/services.yaml @@ -28,6 +28,7 @@ parameters: ldapModel: '%env(resolve:LDAP_MODEL)%' ldapHost: '%env(resolve:LDAP_HOST)%' ldapPort: '%env(resolve:LDAP_PORT)%' + ldapTls: '%env(resolve:LDAP_TLS)%' ldapUser: '%env(resolve:LDAP_USER)%' ldapPassword: '%env(resolve:LDAP_PASSWORD)%' ldapBasedn: '%env(resolve:LDAP_BASEDN)%' @@ -66,6 +67,7 @@ services: bind: $ldapHost: '%ldapHost%' $ldapPort: '%ldapPort%' + $ldapTls: '%ldapTls%' $ldapUser: '%ldapUser%' $ldapPassword: '%ldapPassword%' $ldapBasedn: '%ldapBasedn%' @@ -105,7 +107,7 @@ services: app.ldap.service: public: true class: App\Service\ldapService - arguments: ["%ldapHost%","%ldapPort%","%ldapUser%","%ldapPassword%","%ldapBasedn%"] + arguments: ["%ldapHost%","%ldapPort%","%ldapTls%","%ldapUser%","%ldapPassword%","%ldapBasedn%"] app.upload.samename: public: true diff --git a/src/ninesurvey-1.0/scripts/websocket.sh b/src/ninesurvey-1.0/scripts/websocket.sh index 2bdd9e6..d70a5ac 100755 --- a/src/ninesurvey-1.0/scripts/websocket.sh +++ b/src/ninesurvey-1.0/scripts/websocket.sh @@ -32,6 +32,6 @@ then if [ "$restart" == "yes" ] && [ "$1" != "stop" ] ; then echo WEBSOCKET = START - bin/console app:Websocket --name $APP_ALIAS & disown + systemctl restart $APP_ALIAS fi fi \ No newline at end of file diff --git a/src/ninesurvey-1.0/src/Service/ldapService.php b/src/ninesurvey-1.0/src/Service/ldapService.php index fb093a8..461eddd 100644 --- a/src/ninesurvey-1.0/src/Service/ldapService.php +++ b/src/ninesurvey-1.0/src/Service/ldapService.php @@ -10,16 +10,18 @@ class ldapService protected $host; protected $port; + protected $tls; protected $user = null; protected $password = null; protected $basedn; private $connection = null; - public function __construct($ldapHost, $ldapPort, $ldapUser, $ldapPassword, $ldapBasedn) + public function __construct($ldapHost, $ldapPort, $ldapTls, $ldapUser, $ldapPassword, $ldapBasedn) { $this->host = $ldapHost; $this->port = $ldapPort; + $this->tls = $ldapTls; $this->user = $ldapUser; $this->password = $ldapPassword; $this->basedn = $ldapBasedn; @@ -32,6 +34,9 @@ class ldapService $ldapConn = ldap_connect($this->host, $this->port); if($ldapConn){ ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3); + ldap_set_option($ldapConn, LDAP_OPT_REFERRALS, 0); + if($this->tls) ldap_start_tls($ldapConn); + if(ldap_bind( $ldapConn, $this->user, $this->password)){ $this->connection = $ldapConn; return $this->connection; diff --git a/tmpl/ninesurvey-env.local b/tmpl/ninesurvey-env.local index 109c3f3..c7f74f2 100644 --- a/tmpl/ninesurvey-env.local +++ b/tmpl/ninesurvey-env.local @@ -63,6 +63,11 @@ LDAP_MODEL=open %end if LDAP_HOST=%%adresse_ip_ldap LDAP_PORT=%%ldap_port +%if %%getVar("ldap_tls","non") == "oui" +LDAP_TLS=1 +%else +LDAP_TLS=0 +%end if LDAP_USER=%%ldap_reader LDAP_PASSWORD=%%pwdreader("",%%ldap_reader_passfile) LDAP_BASEDN=%%ldap_base_dn