Throwable/Role/Status/Unauthorized.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 94.4% 34 / 36 SCAR 6.9
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Throwable/Role/Status/ProxyAuthenticationRequired.pm ↑ Summary Throwable/Role/Generic.pm »
1 package HTTP::Throwable::Role::Status::Unauthorized;
2 1 our $AUTHORITY = 'cpan:STEVAN';
3 1 $HTTP::Throwable::Role::Status::Unauthorized::VERSION = '0.027';
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 around 'build_headers' => sub {
23 4 ▶ my $next = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
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.027
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 ATTRIBUTES
64  
65 =head2 www_authenticate
66  
67 This is a required string or array of string that will be used to populate
68 the 'WWW-Authenticate' header(s) when creating a PSGI response.
69  
70 =head1 SEE ALSO
71  
72 HTTP Authentication: Basic and Digest Access Authentication - L<http://www.apps.ietf.org/rfc/rfc2617.html>
73  
74 WWW-Authenticate Header - L<http://www.apps.ietf.org/rfc/rfc2617.html#sec-3.2.1>
75  
76 =head1 AUTHORS
77  
78 =over 4
79  
80 =item *
81  
82 Stevan Little <stevan.little@iinteractive.com>
83  
84 =item *
85  
86 Ricardo Signes <rjbs@cpan.org>
87  
88 =back
89  
90 =head1 COPYRIGHT AND LICENSE
91  
92 This software is copyright (c) 2011 by Infinity Interactive, Inc.
93  
94 This is free software; you can redistribute it and/or modify it under
95 the same terms as the Perl 5 programming language system itself.
96  
97 =cut
98  
99 __END__
« Throwable/Role/Status/ProxyAuthenticationRequired.pm ↑ Summary Throwable/Role/Generic.pm »