Merge branch 'fix_auth_timeouts' of github.com:connortechnology/ZoneMinder into fix_auth_timeouts

pull/2867/head
Isaac Connor 2020-03-02 12:04:45 -05:00
commit d0e70fc501
3 changed files with 20 additions and 18 deletions

View File

@ -1,8 +1,11 @@
<?php
if ($_REQUEST['entity'] == 'navBar') {
if ( $_REQUEST['entity'] == 'navBar' ) {
$data = array();
if ( ZM_OPT_USE_AUTH && ZM_AUTH_RELAY == 'hashed' ) {
$data['auth'] = generateAuthHash( ZM_AUTH_HASH_IPS );
if ( ZM_OPT_USE_AUTH && (ZM_AUTH_RELAY == 'hashed') ) {
$auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS);
if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) {
$data['auth'] = $auth_hash;
}
}
$data['message'] = getNavBarHtml('reload');
ajaxResponse($data);

View File

@ -86,10 +86,8 @@ if ( sem_acquire($semaphore,1) !== false ) {
$numSockets = socket_select($rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000);
if ( $numSockets === false ) {
ZM\Error('socket_select failed: ' . socket_strerror(socket_last_error()));
ajaxError('socket_select failed: '.socket_strerror(socket_last_error()));
} else if ( $numSockets < 0 ) {
ZM\Error("Socket closed $remSockFile");
ajaxError("Socket closed $remSockFile");
} else if ( $numSockets == 0 ) {
ZM\Error("Timed out waiting for msg $remSockFile");
@ -97,7 +95,6 @@ if ( sem_acquire($semaphore,1) !== false ) {
#ajaxError("Timed out waiting for msg $remSockFile");
} else if ( $numSockets > 0 ) {
if ( count($rSockets) != 1 ) {
ZM\Error('Bogus return from select, '.count($rSockets).' sockets available');
ajaxError('Bogus return from select, '.count($rSockets).' sockets available');
}
}
@ -124,10 +121,12 @@ if ( sem_acquire($semaphore,1) !== false ) {
$data['delay'] = round( $data['delay'], 2 );
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
if ( ZM_OPT_USE_AUTH && (ZM_AUTH_RELAY == 'hashed') ) {
$time = time();
// Regenerate auth hash after half the lifetime of the hash
if ( (!isset($_SESSION['AuthHashGeneratedAt'])) or ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) ) {
$data['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS);
$auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS);
if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) {
$data['auth'] = $auth_hash;
ZM\Logger::Debug("including nw auth hash " . $data['auth']);
} else {
ZM\Logger::Debug('Not including nw auth hash becase it hashn\'t changed '.$auth_hash);
}
}
ajaxResponse(array('status'=>$data));
@ -141,12 +140,11 @@ if ( sem_acquire($semaphore,1) !== false ) {
$data = unpack('ltype/Qevent/iprogress/irate/izoom/Cpaused', $msg);
}
$data['rate'] /= RATE_BASE;
$data['zoom'] = round( $data['zoom']/SCALE_BASE, 1 );
$data['zoom'] = round($data['zoom']/SCALE_BASE, 1);
if ( ZM_OPT_USE_AUTH && (ZM_AUTH_RELAY == 'hashed') ) {
$time = time();
// Regenerate auth hash after half the lifetime of the hash
if ( (!isset($_SESSION['AuthHashGeneratedAt'])) or ( $_SESSION['AuthHashGeneratedAt'] < $time - (ZM_AUTH_HASH_TTL * 1800) ) ) {
$data['auth'] = generateAuthHash(ZM_AUTH_HASH_IPS);
$auth_hash = generateAuthHash(ZM_AUTH_HASH_IPS);
if ( isset($_REQUEST['auth']) and ($_REQUEST['auth'] != $auth_hash) ) {
$data['auth'] = $auth_hash;
}
}
ajaxResponse(array('status'=>$data));

View File

@ -263,8 +263,6 @@ if ( ZM_OPT_USE_AUTH ) {
} else {
// Non token based auth
$user = userFromSession();
if ( ZM_AUTH_HASH_LOGINS && empty($user) && !empty($_REQUEST['auth']) ) {
$user = getAuthUser($_REQUEST['auth']);
} else if (
@ -280,6 +278,9 @@ if ( ZM_OPT_USE_AUTH ) {
return;
}
$user = $ret[0];
} else {
$user = userFromSession();
}
if ( !empty($user) ) {