mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
auth modules! please test http-auth again, i haven't, but i think i got it right...
git-svn-id: http://www.observium.org/svn/observer/trunk@973 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
function authenticate($username,$password)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if(isset($_SERVER['REMOTE_USER']))
|
||||
{
|
||||
$_SESSION['username'] = mres($_SERVER['REMOTE_USER']);
|
||||
|
||||
$sql = "SELECT username FROM `users` WHERE `username`='".$_SESSION['username'] . "'";;
|
||||
$query = mysql_query($sql);
|
||||
$row = @mysql_fetch_array($query);
|
||||
if($row['username'] && $row['username'] == $_SESSION['username'])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['username'] = $config['http_auth_guest'];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
function authenticate($username,$password)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$ds=@ldap_connect($config['auth_ldap_server'],$config['auth_ldap_port']);
|
||||
if ($ds)
|
||||
{
|
||||
if (ldap_bind($ds, $config['auth_ldap_prefix'] . $username . $config['auth_ldap_suffix'], $password))
|
||||
{
|
||||
if (!$config['auth_ldap_group'])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ldap_compare($ds,$config['auth_ldap_group'],'memberUid',$username))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# FIXME return a warning that LDAP couldn't connect?
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
function authenticate($username,$password)
|
||||
{
|
||||
$encrypted = md5($password);
|
||||
$sql = "SELECT username FROM `users` WHERE `username`='".$_SESSION['username']."' AND `password`='".$encrypted."'";
|
||||
$query = mysql_query($sql);
|
||||
$row = @mysql_fetch_array($query);
|
||||
if($row['username'] && $row['username'] == $username)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user