@@ -49,7 +49,7 Authen::Simple::LDAP (and IO::Socket::SSL if LDAPS is used): | |||||
49 |
|
49 | |||
50 | PerlAccessHandler Apache::Authn::Redmine::access_handler |
|
50 | PerlAccessHandler Apache::Authn::Redmine::access_handler | |
51 | PerlAuthenHandler Apache::Authn::Redmine::authen_handler |
|
51 | PerlAuthenHandler Apache::Authn::Redmine::authen_handler | |
52 |
|
52 | |||
53 | ## for mysql |
|
53 | ## for mysql | |
54 | RedmineDSN "DBI:mysql:database=databasename;host=my.db.server" |
|
54 | RedmineDSN "DBI:mysql:database=databasename;host=my.db.server" | |
55 | ## for postgres |
|
55 | ## for postgres | |
@@ -144,7 +144,7 my @directives = ( | |||||
144 | }, |
|
144 | }, | |
145 | ); |
|
145 | ); | |
146 |
|
146 | |||
147 |
sub RedmineDSN { |
|
147 | sub RedmineDSN { | |
148 | my ($self, $parms, $arg) = @_; |
|
148 | my ($self, $parms, $arg) = @_; | |
149 | $self->{RedmineDSN} = $arg; |
|
149 | $self->{RedmineDSN} = $arg; | |
150 | my $query = "SELECT |
|
150 | my $query = "SELECT | |
@@ -164,12 +164,12 sub RedmineDSN { | |||||
164 |
|
164 | |||
165 | sub RedmineDbUser { set_val('RedmineDbUser', @_); } |
|
165 | sub RedmineDbUser { set_val('RedmineDbUser', @_); } | |
166 | sub RedmineDbPass { set_val('RedmineDbPass', @_); } |
|
166 | sub RedmineDbPass { set_val('RedmineDbPass', @_); } | |
167 |
sub RedmineDbWhereClause { |
|
167 | sub RedmineDbWhereClause { | |
168 | my ($self, $parms, $arg) = @_; |
|
168 | my ($self, $parms, $arg) = @_; | |
169 | $self->{RedmineQuery} = trim($self->{RedmineQuery}.($arg ? $arg : "")." "); |
|
169 | $self->{RedmineQuery} = trim($self->{RedmineQuery}.($arg ? $arg : "")." "); | |
170 | } |
|
170 | } | |
171 |
|
171 | |||
172 |
sub RedmineCacheCredsMax { |
|
172 | sub RedmineCacheCredsMax { | |
173 | my ($self, $parms, $arg) = @_; |
|
173 | my ($self, $parms, $arg) = @_; | |
174 | if ($arg) { |
|
174 | if ($arg) { | |
175 | $self->{RedmineCachePool} = APR::Pool->new; |
|
175 | $self->{RedmineCachePool} = APR::Pool->new; | |
@@ -216,10 +216,10 sub access_handler { | |||||
216 |
|
216 | |||
217 | sub authen_handler { |
|
217 | sub authen_handler { | |
218 | my $r = shift; |
|
218 | my $r = shift; | |
219 |
|
219 | |||
220 | my ($res, $redmine_pass) = $r->get_basic_auth_pw(); |
|
220 | my ($res, $redmine_pass) = $r->get_basic_auth_pw(); | |
221 | return $res unless $res == OK; |
|
221 | return $res unless $res == OK; | |
222 |
|
222 | |||
223 | if (is_member($r->user, $redmine_pass, $r)) { |
|
223 | if (is_member($r->user, $redmine_pass, $r)) { | |
224 | return OK; |
|
224 | return OK; | |
225 | } else { |
|
225 | } else { | |
@@ -246,7 +246,7 sub is_authentication_forced { | |||||
246 | } |
|
246 | } | |
247 | $sth->finish(); |
|
247 | $sth->finish(); | |
248 | undef $sth; |
|
248 | undef $sth; | |
249 |
|
249 | |||
250 | $dbh->disconnect(); |
|
250 | $dbh->disconnect(); | |
251 | undef $dbh; |
|
251 | undef $dbh; | |
252 |
|
252 | |||
@@ -256,7 +256,7 sub is_authentication_forced { | |||||
256 | sub is_public_project { |
|
256 | sub is_public_project { | |
257 | my $project_id = shift; |
|
257 | my $project_id = shift; | |
258 | my $r = shift; |
|
258 | my $r = shift; | |
259 |
|
259 | |||
260 | if (is_authentication_forced($r)) { |
|
260 | if (is_authentication_forced($r)) { | |
261 | return 0; |
|
261 | return 0; | |
262 | } |
|
262 | } | |
@@ -283,12 +283,12 sub is_public_project { | |||||
283 |
|
283 | |||
284 | sub anonymous_role_allows_browse_repository { |
|
284 | sub anonymous_role_allows_browse_repository { | |
285 | my $r = shift; |
|
285 | my $r = shift; | |
286 |
|
286 | |||
287 | my $dbh = connect_database($r); |
|
287 | my $dbh = connect_database($r); | |
288 | my $sth = $dbh->prepare( |
|
288 | my $sth = $dbh->prepare( | |
289 | "SELECT permissions FROM roles WHERE builtin = 2;" |
|
289 | "SELECT permissions FROM roles WHERE builtin = 2;" | |
290 | ); |
|
290 | ); | |
291 |
|
291 | |||
292 | $sth->execute(); |
|
292 | $sth->execute(); | |
293 | my $ret = 0; |
|
293 | my $ret = 0; | |
294 | if (my @row = $sth->fetchrow_array) { |
|
294 | if (my @row = $sth->fetchrow_array) { | |
@@ -300,7 +300,7 sub anonymous_role_allows_browse_repository { | |||||
300 | undef $sth; |
|
300 | undef $sth; | |
301 | $dbh->disconnect(); |
|
301 | $dbh->disconnect(); | |
302 | undef $dbh; |
|
302 | undef $dbh; | |
303 |
|
303 | |||
304 | $ret; |
|
304 | $ret; | |
305 | } |
|
305 | } | |
306 |
|
306 | |||
@@ -328,7 +328,7 sub is_member { | |||||
328 | my $project_id = get_project_identifier($r); |
|
328 | my $project_id = get_project_identifier($r); | |
329 |
|
329 | |||
330 | my $pass_digest = Digest::SHA1::sha1_hex($redmine_pass); |
|
330 | my $pass_digest = Digest::SHA1::sha1_hex($redmine_pass); | |
331 |
|
331 | |||
332 | my $access_mode = defined $read_only_methods{$r->method} ? "R" : "W"; |
|
332 | my $access_mode = defined $read_only_methods{$r->method} ? "R" : "W"; | |
333 |
|
333 | |||
334 | my $cfg = Apache2::Module::get_config(__PACKAGE__, $r->server, $r->per_dir_config); |
|
334 | my $cfg = Apache2::Module::get_config(__PACKAGE__, $r->server, $r->per_dir_config); | |
@@ -397,7 +397,7 sub is_member { | |||||
397 |
|
397 | |||
398 | sub get_project_identifier { |
|
398 | sub get_project_identifier { | |
399 | my $r = shift; |
|
399 | my $r = shift; | |
400 |
|
400 | |||
401 | my $location = $r->location; |
|
401 | my $location = $r->location; | |
402 | my ($identifier) = $r->uri =~ m{$location/*([^/]+)}; |
|
402 | my ($identifier) = $r->uri =~ m{$location/*([^/]+)}; | |
403 | $identifier; |
|
403 | $identifier; | |
@@ -405,7 +405,7 sub get_project_identifier { | |||||
405 |
|
405 | |||
406 | sub connect_database { |
|
406 | sub connect_database { | |
407 | my $r = shift; |
|
407 | my $r = shift; | |
408 |
|
408 | |||
409 | my $cfg = Apache2::Module::get_config(__PACKAGE__, $r->server, $r->per_dir_config); |
|
409 | my $cfg = Apache2::Module::get_config(__PACKAGE__, $r->server, $r->per_dir_config); | |
410 | return DBI->connect($cfg->{RedmineDSN}, $cfg->{RedmineDbUser}, $cfg->{RedmineDbPass}); |
|
410 | return DBI->connect($cfg->{RedmineDSN}, $cfg->{RedmineDbUser}, $cfg->{RedmineDbPass}); | |
411 | } |
|
411 | } |
General Comments 0
You need to be logged in to leave comments.
Login now