Gerrit-Client
view release on metacpan or search on metacpan
lib/Gerrit/Client.pm view on Meta::CPAN
my %attr;
while ($authenticate =~ /([a-zA-Z0-9\-]+)="([^"]+)"(,\s*)?/g) {
$attr{$1} = $2;
}
if ($attr{qop}) {
$attr{qop} = [ split(/,/, $attr{qop}) ];
}
$attr{algorithm} ||= 'MD5';
$attr{qop} ||= [];
_debug_print "digest attrs with defaults filled: " . Dumper(\%attr);
unless (grep {$_ eq 'auth'} @{$attr{qop}}) {
warn __PACKAGE__ . ": server didn't offer qop=auth for digest authentication";
return;
}
unless ($attr{algorithm} eq 'MD5') {
warn __PACKAGE__ . ": server didn't offer algorithm=MD5 for digest authentication";
}
my $nonce = $attr{nonce};
my $cnonce = $cnonce_cb->();
$noncecount{$nonce} = ($noncecount{$nonce}||0) + 1;
my $count = $noncecount{$nonce};
my $count_hex = sprintf("%08x", $count);
my $uri = URI->new($in_headers->{URL})->path;
my $method = $in_headers->{Method};
_debug_print "uri $uri method $method\n";
my $ha1 = md5_hex($username, ':', $attr{realm}, ':', $password);
my $ha2 = md5_hex($method, ':', $uri);
my $response = md5_hex($ha1, ':', $nonce, ':', $count_hex, ':', $cnonce, ':', 'auth', ':', $ha2);
my $authstr = qq(Digest username="$username", realm="$attr{realm}", nonce="$nonce", uri="$uri", )
.qq(cnonce="$cnonce", nc=$count_hex, qop="auth", response="$response");
_debug_print "digest auth: $authstr\n";
$out_headers->{Authorization} = $authstr;
return 1;
}
}
=back
=head1 VARIABLES
=over
=item B<@Gerrit::Client::SSH>
The ssh command and initial arguments used when Gerrit::Client invokes
ssh.
# force IPv6 for this connection
local @Gerrit::Client::SSH = ('ssh', '-oAddressFamily=inet6');
my $stream = Gerrit::Client::stream_events ...
The default value is C<('ssh')>.
=item B<@Gerrit::Client::GIT>
The git command and initial arguments used when Gerrit::Client invokes
git.
# use a local object cache to speed up initial clones
local @Gerrit::Client::GIT = ('env', "GIT_ALTERNATE_OBJECT_DIRECTORIES=$ENV{HOME}/gitcache", 'git');
my $guard = Gerrit::Client::for_each_patchset ...
The default value is C<('git')>.
=item B<$Gerrit::Client::MAX_CONNECTIONS>
Maximum number of simultaneous git connections Gerrit::Client may make
to a single Gerrit server. The amount of parallel git clones and
fetches should be throttled, otherwise the Gerrit server may drop
incoming connections.
The default value is C<2>.
=item B<$Gerrit::Client::MAX_FORKS>
Maximum number of processes allowed to run simultaneously for handling
of patchsets in for_each_patchset. This limit applies only to local
work processes, not git clones or fetches from gerrit.
Note that C<$AnyEvent::Util::MAX_FORKS> may also impact the maximum number
of processes. C<$AnyEvent::Util::MAX_FORKS> should be set higher than or
equal to C<$Gerrit::Client::MAX_FORKS>.
The default value is C<4>.
=item B<$Gerrit::Client::DEBUG>
If set to a true value, various debugging messages will be printed to
standard error. May be set by the GERRIT_CLIENT_DEBUG environment
variable.
=back
=head1 AUTHOR
Rohan McGovern, <rohan@mcgovern.id.au>
=head1 COMPATIBILITY
Gerrit::Client has been known to work with Gerrit 2.2.2.1, Gerrit 2.6-rc1,
and Gerrit 2.8.5 and hence could reasonably be expected to work with any
gerrit version in that range.
Please note that different Gerrit versions may represent objects in
slightly incompatible ways (e.g. "CRVW" vs "Code-Review" strings in
event objects). Gerrit::Client does not insulate the caller against
these changes.
=head1 BUGS
( run in 1.307 second using v1.01-cache-2.11-cpan-39bf76dae61 )