446 |
446 |
my $dbh = connect_database($r);
|
447 |
447 |
my $project_id = get_project_identifier($r);
|
448 |
448 |
|
|
449 |
# This unless is added to allow SVNListParentPath to work only for LDAP users
|
|
450 |
# The LDAP authentication code is copied from the code below
|
|
451 |
unless (defined($project_id)) {
|
|
452 |
|
|
453 |
my $ret_new;
|
|
454 |
|
|
455 |
my $sthuseronly = $dbh->prepare(
|
|
456 |
"select auth_source_id from users where login = ?;"
|
|
457 |
);
|
|
458 |
$sthuseronly->execute($redmine_user);
|
|
459 |
my @auth_source_result = $sthuseronly->fetchrow_array;
|
|
460 |
my $auth_source_id_new = $auth_source_result[0];
|
|
461 |
|
|
462 |
|
|
463 |
my $sthldap = $dbh->prepare(
|
|
464 |
"SELECT host,port,tls,account,account_password,base_dn,attr_login from auth_sources WHERE id = ?;"
|
|
465 |
);
|
|
466 |
$sthldap->execute($auth_source_id_new);
|
|
467 |
while (my @rowldap = $sthldap->fetchrow_array) {
|
|
468 |
my $bind_as = $rowldap[3] ? $rowldap[3] : "";
|
|
469 |
my $bind_pw = $rowldap[4] ? $rowldap[4] : "";
|
|
470 |
if ($bind_as =~ m/\$login/) {
|
|
471 |
# replace $login with $redmine_user and use $redmine_pass
|
|
472 |
$bind_as =~ s/\$login/$redmine_user/g;
|
|
473 |
$bind_pw = $redmine_pass
|
|
474 |
}
|
|
475 |
my $ldap_new = Authen::Simple::LDAP->new(
|
|
476 |
host => ($rowldap[2] eq "1" || $rowldap[2] eq "t") ? "ldaps://$rowldap[0]:$rowldap[1]" : $rowldap[0],
|
|
477 |
port => $rowldap[1],
|
|
478 |
basedn => $rowldap[5],
|
|
479 |
binddn => $bind_as,
|
|
480 |
bindpw => $bind_pw,
|
|
481 |
filter => "(".$rowldap[6]."=%s)"
|
|
482 |
);
|
|
483 |
if ($ldap_new->authenticate($redmine_user, $redmine_pass)) {
|
|
484 |
$ret_new = 1;
|
|
485 |
} else {
|
|
486 |
$ret_new = 0;
|
|
487 |
}
|
|
488 |
|
|
489 |
}
|
|
490 |
$sthldap->finish();
|
|
491 |
undef $sthldap;
|
|
492 |
|
|
493 |
$sthuseronly->finish();
|
|
494 |
return $ret_new;
|
|
495 |
}
|
|
496 |
|
|
497 |
|
449 |
498 |
my $pass_digest = Digest::SHA::sha1_hex($redmine_pass);
|
450 |
499 |
|
451 |
500 |
my $access_mode = request_is_read_only($r) ? "R" : "W";
|