blib/lib/PAGI/Middleware/Session/State/Bearer.pm

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 78.5% 22 / 28 CC 3 SCAR 7.7
CC
3
Cov
85%
new
3.3
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« examples/endpoint-router-demo/lib/MyApp/Main.pm ↑ Summary blib/lib/PAGI/Endpoint/SSE.pm »
1 package PAGI::Middleware::Session::State::Bearer;
2 1 $PAGI::Middleware::Session::State::Bearer::VERSION = '0.002001';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use parent 'PAGI::Middleware::Session::State::Header';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 PAGI::Middleware::Session::State::Bearer - Bearer token session ID transport
10  
11 =head1 SYNOPSIS
12  
13 use PAGI::Middleware::Session::State::Bearer;
14  
15 my $state = PAGI::Middleware::Session::State::Bearer->new();
16  
17 # Extract session ID from Authorization: Bearer <token>
18 my $id = $state->extract($scope);
19  
20 =head1 DESCRIPTION
21  
22 A convenience subclass of L<PAGI::Middleware::Session::State::Header> that
23 extracts an opaque bearer token from the C<Authorization> header. This is
24 intended for opaque session tokens, not JWTs.
25  
26 Defaults to C<header_name =E<gt> 'Authorization'> and
27 C<pattern =E<gt> qr/^Bearer\s+(.+)$/i>. Both can be overridden via
28 constructor arguments.
29  
30 =cut
31  
32 sub new {
33 4 ▶ my ($class, %args) = @_;
Subroutine new: called CC=3 SCAR=12.0
Pod documented
34  
35 4 ▶ $args{header_name} //= 'Authorization';
Condition50%1/2
$args{"header_name"} //= "Authorization"
l!l
04
MC/DC0%0/1
$args{"header_name"} //= "Authorization"
$args{"header_name"}
Truth table50%1/2
A
A= $args{"header_name"}
Aresult
11
00
36 4 ▶ $args{pattern} //= qr/^Bearer\s+(.+)$/i;
Condition33%1/3
$args{"pattern"} //= qr/^Bearer\s+(.+)$/i
l!l&&r!l&&!r
040
MC/DC0%0/2
$args{"pattern"} //= qr/^Bearer\s+(.+)$/i
$args{"pattern"} qr/^Bearer\s+(.+)$/i
Truth table33%1/3
A //= B
A= $args{"pattern"}B= qr/^Bearer\s+(.+)$/i
ABresult
1X1
011
000
37  
38 4 return $class->SUPER::new(%args);
39 }
40  
41 1 1;
42  
43 __END__
« examples/endpoint-router-demo/lib/MyApp/Main.pm ↑ Summary blib/lib/PAGI/Endpoint/SSE.pm »