1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-18 13:51:16 +02:00

fix merge conflicts with master

This commit is contained in:
Marco Dickert
2017-06-13 11:18:08 +02:00
parent 72c5586136
commit 7f1d14bd21
3 changed files with 74 additions and 16 deletions

31
ifm.php
View File

@@ -51,9 +51,17 @@ class IFMConfig {
format:
<username>:<passwordhash>
LDAP auth syntax
const auth_source = 'ldap;<ldap_sever_host>:<rootdn>';
The script will add "uid=<username>," to the rootdn for binding. If your ldap server
does not use uid for usernames you can change it in the function checkCredentials.
examples:
const auth_source = 'inline;admin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC';
const auth_source = 'file;/path/to/file';
const auth_source = 'ldap;<ldap_sever_host>:<rootdn>';
*/
const auth = 0;
const auth_source = 'inline;admin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC';
@@ -1835,16 +1843,37 @@ ifm.init();
switch( $src ) {
case "inline":
list( $uname, $hash ) = explode( ":", $srcopt );
return password_verify( $pass, trim( $hash ) ) ? ( $uname == $user ) : false;
break;
case "file":
if( @file_exists( $srcopt ) && @is_readable( $srcopt ) ) {
list( $uname, $hash ) = explode( ":", fgets( fopen( $srcopt, 'r' ) ) );
return password_verify( $pass, trim( $hash ) ) ? ( $uname == $user ) : false;
} else {
return false;
}
break;
case "ldap":
$authenticated = false;
list( $ldap_server, $rootdn ) = explode( ":", $srcopt );
$u = "uid=" . $user . "," . $rootdn;
$ds = ldap_connect( $ldap_server ) or ( trigger_error( "Could not reach the ldap server.", E_USER_ERROR ); return false; );
ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
if( $ds ) {
$ldbind = @ldap_bind( $ds, $u, $pass );
if( $ldbind ) {
$authenticated = true;
} else {
$authenticated = false;
}
return password_verify($pass, trim($hash))?($uname == $user):false;
ldap_unbind( $ds );
} else {
$authenticated = false;
}
return $authenticated;
break;
}
return false;
}
private function loginForm($loginFailed=false) {

View File

@@ -51,9 +51,17 @@ class IFMConfig {
format:
<username>:<passwordhash>
LDAP auth syntax
const auth_source = 'ldap;<ldap_sever_host>:<rootdn>';
The script will add "uid=<username>," to the rootdn for binding. If your ldap server
does not use uid for usernames you can change it in the function checkCredentials.
examples:
const auth_source = 'inline;admin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC';
const auth_source = 'file;/path/to/file';
const auth_source = 'ldap;<ldap_sever_host>:<rootdn>';
*/
const auth = 0;
const auth_source = 'inline;admin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC';

View File

@@ -621,16 +621,37 @@ class IFM {
switch( $src ) {
case "inline":
list( $uname, $hash ) = explode( ":", $srcopt );
return password_verify( $pass, trim( $hash ) ) ? ( $uname == $user ) : false;
break;
case "file":
if( @file_exists( $srcopt ) && @is_readable( $srcopt ) ) {
list( $uname, $hash ) = explode( ":", fgets( fopen( $srcopt, 'r' ) ) );
return password_verify( $pass, trim( $hash ) ) ? ( $uname == $user ) : false;
} else {
return false;
}
break;
case "ldap":
$authenticated = false;
list( $ldap_server, $rootdn ) = explode( ":", $srcopt );
$u = "uid=" . $user . "," . $rootdn;
$ds = ldap_connect( $ldap_server ) or ( trigger_error( "Could not reach the ldap server.", E_USER_ERROR ); return false; );
ldap_set_option( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
if( $ds ) {
$ldbind = @ldap_bind( $ds, $u, $pass );
if( $ldbind ) {
$authenticated = true;
} else {
$authenticated = false;
}
return password_verify($pass, trim($hash))?($uname == $user):false;
ldap_unbind( $ds );
} else {
$authenticated = false;
}
return $authenticated;
break;
}
return false;
}
private function loginForm($loginFailed=false) {