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

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 84.6% 22 / 26 CC 3 SCAR 7.3
CC
3
Cov
89%
new
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« examples/endpoint-router-demo/lib/MyApp/API.pm ↑ Summary lib/PAGI/Middleware/Runtime.pm »
1 package PAGI::Middleware::Session::State::Bearer;
2 1 $PAGI::Middleware::Session::State::Bearer::VERSION = '0.002002';
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 4 ▶sub new {
Subroutine new: called CC=3 SCAR=11.4
Pod documented
33 4 my ($class, %args) = @_;
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;
Condition50%1/2
$args{"pattern"} //= qr/^Bearer\s+(.+)$/i
l!l
04
MC/DC0%0/1
$args{"pattern"} //= qr/^Bearer\s+(.+)$/i
$args{"pattern"}
Truth table50%1/2
A
A= $args{"pattern"}
Aresult
11
00
37  
38 4 return $class->SUPER::new(%args);
39 }
40  
41 1 1;
42  
43 __END__
« examples/endpoint-router-demo/lib/MyApp/API.pm ↑ Summary lib/PAGI/Middleware/Runtime.pm »