aboutsummaryrefslogtreecommitdiff
path: root/overlays/shaarli/shaarli_ldap.patch
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2021-02-08 01:27:03 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2021-02-08 01:27:03 +0100
commit5752291a58832f05ffd6c9ccfb7bfd0fe93f535a (patch)
tree3cbdfb3bd78f478877d300679882478365a72b5e /overlays/shaarli/shaarli_ldap.patch
parentc5f1602f941d34ad1f9e7bdb69678d0c844c9db6 (diff)
downloadNix-5752291a58832f05ffd6c9ccfb7bfd0fe93f535a.tar.gz
Nix-5752291a58832f05ffd6c9ccfb7bfd0fe93f535a.tar.zst
Nix-5752291a58832f05ffd6c9ccfb7bfd0fe93f535a.zip
Fix shaarli long sessions
Diffstat (limited to 'overlays/shaarli/shaarli_ldap.patch')
-rw-r--r--overlays/shaarli/shaarli_ldap.patch29
1 files changed, 17 insertions, 12 deletions
diff --git a/overlays/shaarli/shaarli_ldap.patch b/overlays/shaarli/shaarli_ldap.patch
index 9c7315a..e66a54f 100644
--- a/overlays/shaarli/shaarli_ldap.patch
+++ b/overlays/shaarli/shaarli_ldap.patch
@@ -1,4 +1,4 @@
1commit bc82ebfd779b8641dadd6787f51639ea9105c3e8 1commit a19c24edc1057bd411821f9e3e7d1d309d38b1bb
2Author: Ismaël Bouya <ismael.bouya@normalesup.org> 2Author: Ismaël Bouya <ismael.bouya@normalesup.org>
3Date: Sun Feb 3 20:58:18 2019 +0100 3Date: Sun Feb 3 20:58:18 2019 +0100
4 4
@@ -268,10 +268,10 @@ index b8b8ab8..5eb4aac 100644
268 } 268 }
269 269
270diff --git a/index.php b/index.php 270diff --git a/index.php b/index.php
271index 4b86a3e..85376e8 100644 271index 4b86a3e..58ae2dd 100644
272--- a/index.php 272--- a/index.php
273+++ b/index.php 273+++ b/index.php
274@@ -121,7 +121,27 @@ 274@@ -121,7 +121,32 @@
275 $_COOKIE['shaarli'] = session_id(); 275 $_COOKIE['shaarli'] = session_id();
276 } 276 }
277 277
@@ -292,6 +292,11 @@ index 4b86a3e..85376e8 100644
292+ exit; 292+ exit;
293+} 293+}
294+ 294+
295+if (!isset($userspace) && isset($_POST["login"])) {
296+ $userspace = preg_replace("/[^-_A-Za-z0-9]/", '', $_POST["login"]);
297+ error_log("debugImmae: setting userspace from POST: " . $userspace);
298+}
299+
295+if (isset($userspace)) { 300+if (isset($userspace)) {
296+ $conf = new ConfigManager(null, $userspace); 301+ $conf = new ConfigManager(null, $userspace);
297+} else { 302+} else {
@@ -300,7 +305,7 @@ index 4b86a3e..85376e8 100644
300 $sessionManager = new SessionManager($_SESSION, $conf); 305 $sessionManager = new SessionManager($_SESSION, $conf);
301 $loginManager = new LoginManager($GLOBALS, $conf, $sessionManager); 306 $loginManager = new LoginManager($GLOBALS, $conf, $sessionManager);
302 $loginManager->generateStaySignedInToken($_SERVER['REMOTE_ADDR']); 307 $loginManager->generateStaySignedInToken($_SERVER['REMOTE_ADDR']);
303@@ -175,7 +195,7 @@ 308@@ -175,7 +200,7 @@
304 } 309 }
305 310
306 // Display the installation form if no existing config is found 311 // Display the installation form if no existing config is found
@@ -309,7 +314,7 @@ index 4b86a3e..85376e8 100644
309 } 314 }
310 315
311 $loginManager->checkLoginState($_COOKIE, $clientIpId); 316 $loginManager->checkLoginState($_COOKIE, $clientIpId);
312@@ -205,6 +225,7 @@ function isLoggedIn() 317@@ -205,6 +230,7 @@ function isLoggedIn()
313 && $loginManager->checkCredentials($_SERVER['REMOTE_ADDR'], $clientIpId, $_POST['login'], $_POST['password']) 318 && $loginManager->checkCredentials($_SERVER['REMOTE_ADDR'], $clientIpId, $_POST['login'], $_POST['password'])
314 ) { 319 ) {
315 $loginManager->handleSuccessfulLogin($_SERVER); 320 $loginManager->handleSuccessfulLogin($_SERVER);
@@ -317,7 +322,7 @@ index 4b86a3e..85376e8 100644
317 322
318 $cookiedir = ''; 323 $cookiedir = '';
319 if (dirname($_SERVER['SCRIPT_NAME']) != '/') { 324 if (dirname($_SERVER['SCRIPT_NAME']) != '/') {
320@@ -241,25 +262,25 @@ function isLoggedIn() 325@@ -241,25 +267,25 @@ function isLoggedIn()
321 $uri .= '&'.$param.'='.urlencode($_GET[$param]); 326 $uri .= '&'.$param.'='.urlencode($_GET[$param]);
322 } 327 }
323 } 328 }
@@ -348,7 +353,7 @@ index 4b86a3e..85376e8 100644
348 $redir = '&username='. urlencode($_POST['login']); 353 $redir = '&username='. urlencode($_POST['login']);
349 if (isset($_GET['post'])) { 354 if (isset($_GET['post'])) {
350 $redir .= '&post=' . urlencode($_GET['post']); 355 $redir .= '&post=' . urlencode($_GET['post']);
351@@ -270,7 +291,7 @@ function isLoggedIn() 356@@ -270,7 +296,7 @@ function isLoggedIn()
352 } 357 }
353 } 358 }
354 // Redirect to login screen. 359 // Redirect to login screen.
@@ -357,7 +362,7 @@ index 4b86a3e..85376e8 100644
357 exit; 362 exit;
358 } 363 }
359 } 364 }
360@@ -1719,7 +1740,7 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager) 365@@ -1719,7 +1745,7 @@ function buildLinkList($PAGE, $LINKSDB, $conf, $pluginManager, $loginManager)
361 * @param SessionManager $sessionManager SessionManager instance 366 * @param SessionManager $sessionManager SessionManager instance
362 * @param LoginManager $loginManager LoginManager instance 367 * @param LoginManager $loginManager LoginManager instance
363 */ 368 */
@@ -366,7 +371,7 @@ index 4b86a3e..85376e8 100644
366 // On free.fr host, make sure the /sessions directory exists, otherwise login will not work. 371 // On free.fr host, make sure the /sessions directory exists, otherwise login will not work.
367 if (endsWith($_SERVER['HTTP_HOST'],'.free.fr') && !is_dir($_SERVER['DOCUMENT_ROOT'].'/sessions')) mkdir($_SERVER['DOCUMENT_ROOT'].'/sessions',0705); 372 if (endsWith($_SERVER['HTTP_HOST'],'.free.fr') && !is_dir($_SERVER['DOCUMENT_ROOT'].'/sessions')) mkdir($_SERVER['DOCUMENT_ROOT'].'/sessions',0705);
368 373
369@@ -1755,7 +1776,7 @@ function install($conf, $sessionManager, $loginManager) { 374@@ -1755,7 +1781,7 @@ function install($conf, $sessionManager, $loginManager) {
370 } 375 }
371 376
372 377
@@ -375,7 +380,7 @@ index 4b86a3e..85376e8 100644
375 { 380 {
376 $tz = 'UTC'; 381 $tz = 'UTC';
377 if (!empty($_POST['continent']) && !empty($_POST['city']) 382 if (!empty($_POST['continent']) && !empty($_POST['city'])
378@@ -1764,15 +1785,15 @@ function install($conf, $sessionManager, $loginManager) { 383@@ -1764,15 +1790,15 @@ function install($conf, $sessionManager, $loginManager) {
379 $tz = $_POST['continent'].'/'.$_POST['city']; 384 $tz = $_POST['continent'].'/'.$_POST['city'];
380 } 385 }
381 $conf->set('general.timezone', $tz); 386 $conf->set('general.timezone', $tz);
@@ -395,7 +400,7 @@ index 4b86a3e..85376e8 100644
395 } 400 }
396 $conf->set('translation.language', escape($_POST['language'])); 401 $conf->set('translation.language', escape($_POST['language']));
397 $conf->set('updates.check_updates', !empty($_POST['updateCheck'])); 402 $conf->set('updates.check_updates', !empty($_POST['updateCheck']));
398@@ -1841,7 +1862,12 @@ function install($conf, $sessionManager, $loginManager) { 403@@ -1841,7 +1867,12 @@ function install($conf, $sessionManager, $loginManager) {
399 $app = new \Slim\App($container); 404 $app = new \Slim\App($container);
400 405
401 // REST API routes 406 // REST API routes
@@ -409,7 +414,7 @@ index 4b86a3e..85376e8 100644
409 $this->get('/info', '\Shaarli\Api\Controllers\Info:getInfo')->setName('getInfo'); 414 $this->get('/info', '\Shaarli\Api\Controllers\Info:getInfo')->setName('getInfo');
410 $this->get('/links', '\Shaarli\Api\Controllers\Links:getLinks')->setName('getLinks'); 415 $this->get('/links', '\Shaarli\Api\Controllers\Links:getLinks')->setName('getLinks');
411 $this->get('/links/{id:[\d]+}', '\Shaarli\Api\Controllers\Links:getLink')->setName('getLink'); 416 $this->get('/links/{id:[\d]+}', '\Shaarli\Api\Controllers\Links:getLink')->setName('getLink');
412@@ -1860,7 +1886,7 @@ function install($conf, $sessionManager, $loginManager) { 417@@ -1860,7 +1891,7 @@ function install($conf, $sessionManager, $loginManager) {
413 $response = $app->run(true); 418 $response = $app->run(true);
414 // Hack to make Slim and Shaarli router work together: 419 // Hack to make Slim and Shaarli router work together:
415 // If a Slim route isn't found and NOT API call, we call renderPage(). 420 // If a Slim route isn't found and NOT API call, we call renderPage().