fix: Improve authentication load time and security (#6615)

* fix: minimize session open time
page/graphs speedup part 2

Write close the session as soon as we no longer need to write to it. Prevents the session from blocking other requests.
Do not run through full authentication functions if the session is already authenticated.
Removes password from the session as well as some items to prevent session fixation from #4608.

WARNING: This will cause issues for ad/ldap users who do not have a bind user configured!

* Do no erase username when using cookie auth.
Properly close the session in ajax_setresolution.php

* write close the session as soon as possible in ajax_setresolution.php

* Remove session regeneration. It is not compatible with the current code and would require more changes.

* Totally refactor authentication.  Extract code to functions for re-use and improved readability

* Use exceptions for authentication and error logging
Tested: mysql, ad_auth with and without bind user

* fix a couple scrutinizer issues

* fix reauthenticate in radius
This commit is contained in:
Tony Murray
2017-05-15 22:18:23 -05:00
committed by GitHub
parent ebdfbd00d8
commit 683a10e723
13 changed files with 382 additions and 187 deletions

View File

@@ -1,9 +1,13 @@
<?php
session_start();
if (isset($_REQUEST['width']) and isset($_REQUEST['height'])) {
if (isset($_REQUEST['width'], $_REQUEST['height'])) {
$_SESSION['screen_width'] = $_REQUEST['width'];
$_SESSION['screen_height'] = $_REQUEST['height'];
}
session_write_close();
header('Content-type: text/plain');
echo $_SESSION['screen_width'];
echo $_SESSION['screen_height'];
echo $_SESSION['screen_width'] . 'x' . $_SESSION['screen_height'];