Project

General

Profile

« Previous | Next » 

Revision 990c00c4

Added by Renato Botelho over 8 years ago

Revert "Use cached groups in get_user_privileges"

This reverts commit 855826896509a1a0bec77a51535a8f004b4ca570.

View differences:

src/etc/inc/auth.inc
318 318
}
319 319

  
320 320
function get_user_privileges(& $user) {
321
	global $config, $_SESSION;
321
	global $config;
322 322

  
323 323
	$authcfg = auth_get_authserver($config['system']['webgui']['authmode']);
324
	$allowed_groups = array();
324
	$names = array();
325 325

  
326 326
	$privs = $user['priv'];
327 327
	if (!is_array($privs)) {
328 328
		$privs = array();
329 329
	}
330 330

  
331
	// cache auth results for a short time to ease load on auth services & logs
332
	if (isset($config['system']['webgui']['auth_refresh_time'])) {
333
		$recheck_time = $config['system']['webgui']['auth_refresh_time'];
334
	} else {
335
		$recheck_time = 30;
336
	}
337

  
338 331
	if ($authcfg['type'] == "ldap") {
339
		if (isset($_SESSION["ldap_allowed_groups"]) &&
340
		    (time() <= $_SESSION["auth_check_time"] + $recheck_time)) {
341
			$allowed_groups = $_SESSION["ldap_allowed_groups"];
342
		} else {
343
			$allowed_groups = @ldap_get_groups($user['name'], $authcfg);
344
			$_SESSION["ldap_allowed_groups"] = $allowed_groups;
345
			$_SESSION["auth_check_time"] = time();
346
		}
332
		$names = @ldap_get_groups($user['name'], $authcfg);
347 333
	} elseif ($authcfg['type'] == "radius") {
348
		if (isset($_SESSION["radius_allowed_groups"]) &&
349
		    (time() <= $_SESSION["auth_check_time"] + $recheck_time)) {
350
			$allowed_groups = $_SESSION["radius_allowed_groups"];
351
		} else {
352
			$allowed_groups = @radius_get_groups($_SESSION['user_radius_attributes']);
353
			$_SESSION["radius_allowed_groups"] = $allowed_groups;
354
			$_SESSION["auth_check_time"] = time();
355
		}
334
		$names = @radius_get_groups($_SESSION['user_radius_attributes']);
356 335
	}
357 336

  
358
	if (empty($allowed_groups)) {
359
		$allowed_groups = local_user_get_groups($user, true);
337
	if (empty($names)) {
338
		$names = local_user_get_groups($user, true);
360 339
	}
361 340

  
362
	if (is_array($allowed_groups)) {
363
		foreach ($allowed_groups as $name) {
364
			$group = getGroupEntry($name);
365
			if (is_array($group['priv'])) {
366
				$privs = array_merge($privs, $group['priv']);
367
			}
341
	foreach ($names as $name) {
342
		$group = getGroupEntry($name);
343
		if (is_array($group['priv'])) {
344
			$privs = array_merge($privs, $group['priv']);
368 345
		}
369 346
	}
370 347

  

Also available in: Unified diff