| 1 | package Catalyst::Authentication::Credential::HTTP::Proxy; | ||||||||||||||
| 2 | 2 | ▶ | use base qw/Catalyst::Authentication::Credential::HTTP/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | |||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 2 | ▶ | use String::Escape (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 2 | ▶ | use URI::Escape (); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 2 | ▶ | use Catalyst::Authentication::Credential::HTTP::Proxy::User; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | 2 | our $VERSION = "0.06"; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 2 | __PACKAGE__->mk_accessors(qw/ | |||||||||||||
| 14 | url | ||||||||||||||
| 15 | /); | ||||||||||||||
| 16 | |||||||||||||||
| 17 | 4 | ▶ | sub init { | ||||||||||||
|
Subroutine
init: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 18 | 4 | my ($self) = @_; | |||||||||||||
| 19 | |||||||||||||||
| 20 | 4 | ▶ | my $type = $self->type || 'basic'; | ||||||||||||
|
Condition100%2/2
$self->type || 'basic'
MC/DC100%1/1
$self->type || 'basic'
$self->type
Truth table100%2/2
A
A= $self->type
| |||||||||||||||
| 21 | |||||||||||||||
| 22 | 4 | ▶ | if (!$self->_config->{url}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | 1 | Catalyst::Exception->throw(__PACKAGE__ . " configuration does not include a 'url' key, cannot proceed"); | |||||||||||||
| 24 | } | ||||||||||||||
| 25 | |||||||||||||||
| 26 | 3 | ▶ | if (!grep /^$type$/, ('basic')) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 27 | 1 | Catalyst::Exception->throw(__PACKAGE__ . " used with unsupported authentication type: " . $type); | |||||||||||||
| 28 | } | ||||||||||||||
| 29 | 2 | $self->type($type); | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 8 | ▶ | sub authenticate_basic { | ||||||||||||
|
Subroutine
authenticate_basic: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||
| 33 | 8 | my ( $self, $c, $realm, $auth_info ) = @_; | |||||||||||||
| 34 | |||||||||||||||
| 35 | 8 | ▶ | $c->log->debug('Checking http basic authentication.') if $c->debug; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 36 | |||||||||||||||
| 37 | 8 | my $headers = $c->req->headers; | |||||||||||||
| 38 | |||||||||||||||
| 39 | 8 | ▶ | if ( my ( $user, $password ) = $headers->authorization_basic ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 40 | 6 | my $ua = Catalyst::Authentication::Credential::HTTP::Proxy::User->new; | |||||||||||||
| 41 | 6 | $ua->credentials($user, $password); | |||||||||||||
| 42 | 6 | my $resp = $ua->get($self->url); | |||||||||||||
| 43 | 6 | ▶ | if ( $resp->is_success ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 44 | # Config username_field TODO | ||||||||||||||
| 45 | 4 | my $user_obj = $realm->find_user( { username => $user }, $c); | |||||||||||||
| 46 | 4 | ▶ | unless ($user_obj) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 47 | 2 | ▶ | $c->log->debug("User '$user' doesn't exist in the default store") | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 48 | if $c->debug; | ||||||||||||||
| 49 | 2 | return; | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | 2 | $c->set_authenticated($user_obj); | |||||||||||||
| 52 | 2 | return 1; | |||||||||||||
| 53 | } | ||||||||||||||
| 54 | else { | ||||||||||||||
| 55 | 2 | $c->log->info('Remote authentication failed:'.$resp->message); | |||||||||||||
| 56 | 2 | return 0; | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | } | ||||||||||||||
| 59 | elsif ( $c->debug ) { | ||||||||||||||
| 60 | 0 | $c->log->info('No credentials provided for basic auth'); | |||||||||||||
| 61 | 0 | return 0; | |||||||||||||
| 62 | } | ||||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | 2 | 1; | |||||||||||||
| 66 | |||||||||||||||
| 67 | __END__ | ||||||||||||||