File Coverage

blib/lib/PAGI/Middleware/Session/State/Bearer.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition 2 5 40.0
subroutine 4 4 100.0
pod 1 1 100.0
total 20 23 86.9


line stmt bran cond sub pod time code
1             package PAGI::Middleware::Session::State::Bearer;
2              
3 1     1   607 use strict;
  1         3  
  1         42  
4 1     1   9 use warnings;
  1         2  
  1         88  
5 1     1   10 use parent 'PAGI::Middleware::Session::State::Header';
  1         2  
  1         6  
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
18             my $id = $state->extract($scope);
19              
20             =head1 DESCRIPTION
21              
22             A convenience subclass of L that
23             extracts an opaque bearer token from the C header. This is
24             intended for opaque session tokens, not JWTs.
25              
26             Defaults to C 'Authorization'> and
27             C qr/^Bearer\s+(.+)$/i>. Both can be overridden via
28             constructor arguments.
29              
30             =cut
31              
32             sub new {
33 4     4 1 5694 my ($class, %args) = @_;
34              
35 4   50     21 $args{header_name} //= 'Authorization';
36 4   33     17 $args{pattern} //= qr/^Bearer\s+(.+)$/i;
37              
38 4         16 return $class->SUPER::new(%args);
39             }
40              
41             1;
42              
43             __END__