diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-10-04 21:47:55 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-10-04 21:47:55 +0000 |
commit | 1de0714fdac868276bfc0374ad86b214b18f91bb (patch) | |
tree | ed581cd2a8b53a6a23048452b60bd91cc1b8d07f /extra | |
parent | 1a23663176fa4b7b5f9ff8f9e46b261400c952a1 (diff) | |
download | redmine-1de0714fdac868276bfc0374ad86b214b18f91bb.tar.gz redmine-1de0714fdac868276bfc0374ad86b214b18f91bb.zip |
Restrict anonymous read access with Redmine.pm
Redmine.pm now also checks for public projects whether the anonymous
user has the browse_repository right for a read operation.
Contributed by Holger Just.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7579 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'extra')
-rw-r--r-- | extra/svn/Redmine.pm | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/extra/svn/Redmine.pm b/extra/svn/Redmine.pm index c0320f13e..8fbd229ff 100644 --- a/extra/svn/Redmine.pm +++ b/extra/svn/Redmine.pm @@ -208,7 +208,7 @@ sub access_handler { my $project_id = get_project_identifier($r); $r->set_handlers(PerlAuthenHandler => [\&OK]) - if is_public_project($project_id, $r); + if is_public_project($project_id, $r) && anonymous_role_allows_browse_repository($r); return OK } @@ -280,6 +280,29 @@ sub is_public_project { $ret; } +sub anonymous_role_allows_browse_repository { + my $r = shift; + + my $dbh = connect_database($r); + my $sth = $dbh->prepare( + "SELECT permissions FROM roles WHERE builtin = 2;" + ); + + $sth->execute(); + my $ret = 0; + if (my @row = $sth->fetchrow_array) { + if ($row[0] =~ /:browse_repository/) { + $ret = 1; + } + } + $sth->finish(); + undef $sth; + $dbh->disconnect(); + undef $dbh; + + $ret; +} + # perhaps we should use repository right (other read right) to check public access. # it could be faster BUT it doesn't work for the moment. # sub is_public_project_by_file { |