Throwable/Role/Status/Unauthorized.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 94.2% 33 / 35 CC 2 SCAR 2.5
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Throwable/Role/Status/ProxyAuthenticationRequired.pm ↑ Summary Throwable/Role/NoBody.pm »
1 package HTTP::Throwable::Role::Status::Unauthorized 0.028;
2 1 our $AUTHORITY = 'cpan:STEVAN';
3  
4 1 ▶use Types::Standard qw(Str ArrayRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 with(
9 'HTTP::Throwable',
10 'HTTP::Throwable::Role::BoringText',
11 );
12  
13 4 ▶sub default_status_code { 401 }
Subroutine default_status_code: called CC=1 SCAR=0.0
Pod undocumented
14 4 ▶sub default_reason { 'Unauthorized' }
Subroutine default_reason: called CC=1 SCAR=0.0
Pod undocumented
15  
16 1 has 'www_authenticate' => (
17 is => 'ro',
18 isa => Str | ArrayRef[Str],
19 required => 1,
20 );
21  
22 4 ▶around 'build_headers' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
23 4 my $next = shift;
24 4 my $self = shift;
25 4 my $headers = $self->$next( @_ );
26 4 my $www_auth = $self->www_authenticate;
27 4 ▶ if ( ref $www_auth ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $www_auth) { } 2 2 4
28 2 push @$headers => (map { ('WWW-Authenticate' => $_) } @$www_auth);
29 }
30 else {
31 2 push @$headers => ('WWW-Authenticate' => $www_auth );
32 }
33 4 $headers;
34 1 };
35  
36 1 ▶no Moo::Role; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 =pod
39  
40 =encoding UTF-8
41  
42 =head1 NAME
43  
44 HTTP::Throwable::Role::Status::Unauthorized - 401 Unauthorized
45  
46 =head1 VERSION
47  
48 version 0.028
49  
50 =head1 DESCRIPTION
51  
52 The request requires user authentication. The response MUST include a
53 WWW-Authenticate header field containing a challenge applicable to the
54 requested resource. The client MAY repeat the request with a suitable
55 Authorization header field. If the request already included Authorization
56 credentials, then the 401 response indicates that authorization has been
57 refused for those credentials. If the 401 response contains the same
58 challenge as the prior response, and the user agent has already attempted
59 authentication at least once, then the user SHOULD be presented the entity
60 that was given in the response, since that entity might include relevant
61 diagnostic information.
62  
63 =head1 PERL VERSION
64  
65 This library should run on perls released even a long time ago. It should work
66 on any version of perl released in the last five years.
67  
68 Although it may work on older versions of perl, no guarantee is made that the
69 minimum required version will not be increased. The version may be increased
70 for any reason, and there is no promise that patches will be accepted to lower
71 the minimum required perl.
72  
73 =head1 ATTRIBUTES
74  
75 =head2 www_authenticate
76  
77 This is a required string or array of string that will be used to populate
78 the 'WWW-Authenticate' header(s) when creating a PSGI response.
79  
80 =head1 SEE ALSO
81  
82 HTTP Authentication: Basic and Digest Access Authentication - L<http://www.apps.ietf.org/rfc/rfc2617.html>
83  
84 WWW-Authenticate Header - L<http://www.apps.ietf.org/rfc/rfc2617.html#sec-3.2.1>
85  
86 =head1 AUTHORS
87  
88 =over 4
89  
90 =item *
91  
92 Stevan Little <stevan.little@iinteractive.com>
93  
94 =item *
95  
96 Ricardo Signes <cpan@semiotic.systems>
97  
98 =back
99  
100 =head1 COPYRIGHT AND LICENSE
101  
102 This software is copyright (c) 2011 by Infinity Interactive, Inc.
103  
104 This is free software; you can redistribute it and/or modify it under
105 the same terms as the Perl 5 programming language system itself.
106  
107 =cut
108  
109 __END__
« Throwable/Role/Status/ProxyAuthenticationRequired.pm ↑ Summary Throwable/Role/NoBody.pm »