updater => \&update_rate_limit_rules,
},
- {name => 'log_user_requests', type => 'b', default => 0,}
+ {name => 'log_user_requests', type => 'b', default => 0},
+
+ {name => 'block_user_agent', type => 't', default => ''},
);
return @param_list;
}
use Cwd qw(realpath);
use MojoX::Log::Log4perl::Tiny;
use Bugzilla::WebService::Server::REST;
+use Try::Tiny;
has 'static' => sub { Bugzilla::Quantum::Static->new };
$self->plugin('Bugzilla::Quantum::Plugin::Helpers');
$self->plugin('Bugzilla::Quantum::Plugin::OAuth2');
+ $self->hook(
+ before_routes => sub {
+ my ($c) = @_;
+ return if $c->stash->{'mojo.static'};
+
+ # It is possible the regexp is bad.
+ # If that is the case, we just log the error and continue on.
+ try {
+ my $regexp = Bugzilla->params->{block_user_agent};
+ if ($regexp && $c->req->headers->user_agent =~ /$regexp/) {
+ my $msg = "Contact " . Bugzilla->params->{maintainer};
+ $c->respond_to(
+ json => {json => {error => $msg}, status => 400},
+ any => {text => "$msg\n", status => 400},
+ );
+ }
+ }
+ catch {
+ ERROR($_);
+ };
+ }
+ );
+
# hypnotoad is weird and doesn't look for MOJO_LISTEN itself.
$self->config(
hypnotoad => {
"So, you have to turn on this option before any such deletions " _
"will ever happen."
+ block_user_agent => "This option is a regexp. When a client's user agent matches it, $terms.Bugzilla will not serve requests to it."
+
last_visit_keep_days => "This option controls how many days $terms.Bugzilla will " _
- "remember when users visit specific ${terms.bugs}.",
+ "remember when users visit specific ${terms.bugs}.",
+
+ rate_limit_active => "Allow some types of requests to be rate limited."
- rate_limit_active => "Allow some types of requests to be rate limited."
+ rate_limit_rules => rate_limit_rules_desc
- rate_limit_rules => rate_limit_rules_desc
+ log_user_requests => "This option controls logging of authenticated requests in the user_request_log table"}
- log_user_requests => "This option controls logging of authenticated requests in the user_request_log table"}
%]