##// END OF EJS Templates
Fixed: Redmine.pm potential security issue with cache credential enabled and subversion (#9567)....
Jean-Philippe Lang -
r7689:38089d9a5606
parent child
Show More
@@ -344,11 +344,13 sub is_member {
344 my $project_id = get_project_identifier($r);
344 my $project_id = get_project_identifier($r);
345
345
346 my $pass_digest = Digest::SHA1::sha1_hex($redmine_pass);
346 my $pass_digest = Digest::SHA1::sha1_hex($redmine_pass);
347
348 my $access_mode = defined $read_only_methods{$r->method} ? "R" : "W";
347
349
348 my $cfg = Apache2::Module::get_config(__PACKAGE__, $r->server, $r->per_dir_config);
350 my $cfg = Apache2::Module::get_config(__PACKAGE__, $r->server, $r->per_dir_config);
349 my $usrprojpass;
351 my $usrprojpass;
350 if ($cfg->{RedmineCacheCredsMax}) {
352 if ($cfg->{RedmineCacheCredsMax}) {
351 $usrprojpass = $cfg->{RedmineCacheCreds}->get($redmine_user.":".$project_id);
353 $usrprojpass = $cfg->{RedmineCacheCreds}->get($redmine_user.":".$project_id.":".$access_mode);
352 return 1 if (defined $usrprojpass and ($usrprojpass eq $pass_digest));
354 return 1 if (defined $usrprojpass and ($usrprojpass eq $pass_digest));
353 }
355 }
354 my $query = $cfg->{RedmineQuery};
356 my $query = $cfg->{RedmineQuery};
@@ -361,7 +363,7 sub is_member {
361 unless ($auth_source_id) {
363 unless ($auth_source_id) {
362 my $method = $r->method;
364 my $method = $r->method;
363 my $salted_password = Digest::SHA1::sha1_hex($salt.$pass_digest);
365 my $salted_password = Digest::SHA1::sha1_hex($salt.$pass_digest);
364 if ($hashed_password eq $salted_password && ((defined $read_only_methods{$method} && $permissions =~ /:browse_repository/) || $permissions =~ /:commit_access/) ) {
366 if ($hashed_password eq $salted_password && (($access_mode eq "R" && $permissions =~ /:browse_repository/) || $permissions =~ /:commit_access/) ) {
365 $ret = 1;
367 $ret = 1;
366 last;
368 last;
367 }
369 }
@@ -380,7 +382,7 sub is_member {
380 filter => "(".$rowldap[6]."=%s)"
382 filter => "(".$rowldap[6]."=%s)"
381 );
383 );
382 my $method = $r->method;
384 my $method = $r->method;
383 $ret = 1 if ($ldap->authenticate($redmine_user, $redmine_pass) && ((defined $read_only_methods{$method} && $permissions =~ /:browse_repository/) || $permissions =~ /:commit_access/));
385 $ret = 1 if ($ldap->authenticate($redmine_user, $redmine_pass) && (($access_mode eq "R" && $permissions =~ /:browse_repository/) || $permissions =~ /:commit_access/));
384
386
385 }
387 }
386 $sthldap->finish();
388 $sthldap->finish();
@@ -394,10 +396,10 sub is_member {
394
396
395 if ($cfg->{RedmineCacheCredsMax} and $ret) {
397 if ($cfg->{RedmineCacheCredsMax} and $ret) {
396 if (defined $usrprojpass) {
398 if (defined $usrprojpass) {
397 $cfg->{RedmineCacheCreds}->set($redmine_user.":".$project_id, $pass_digest);
399 $cfg->{RedmineCacheCreds}->set($redmine_user.":".$project_id.":".$access_mode, $pass_digest);
398 } else {
400 } else {
399 if ($cfg->{RedmineCacheCredsCount} < $cfg->{RedmineCacheCredsMax}) {
401 if ($cfg->{RedmineCacheCredsCount} < $cfg->{RedmineCacheCredsMax}) {
400 $cfg->{RedmineCacheCreds}->set($redmine_user.":".$project_id, $pass_digest);
402 $cfg->{RedmineCacheCreds}->set($redmine_user.":".$project_id.":".$access_mode, $pass_digest);
401 $cfg->{RedmineCacheCredsCount}++;
403 $cfg->{RedmineCacheCredsCount}++;
402 } else {
404 } else {
403 $cfg->{RedmineCacheCreds}->clear();
405 $cfg->{RedmineCacheCreds}->clear();
General Comments 0
You need to be logged in to leave comments. Login now