| 1 | package WebService::Zaqar::Middleware::Auth::DynamicHeader; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: middleware for adding a dynamic authentication header value | ||||||||||
| 4 | |||||||||||
| 5 | 3 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 3 | extends 'Net::HTTP::Spore::Middleware::Auth'; | |||||||||
| 7 | |||||||||||
| 8 | 3 | has header_name => (isa => 'Str', is => 'ro', required => 1); | |||||||||
| 9 | 3 | has header_value_callback => (isa => 'Code', is => 'ro', required => 1); | |||||||||
| 10 | |||||||||||
| 11 | 5 | ▶ | sub call { | ||||||||
|
Subroutine
call: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 12 | 5 | my ($self, $req) = @_; | |||||||||
| 13 | 5 | ▶ | return unless $self->should_authenticate($req); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 5 | my $value = $self->header_value_callback->($req); | |||||||||
| 15 | 5 | ▶ | if (defined $value) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 3 | $req->header($self->header_name => $value); | |||||||||
| 17 | } | ||||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | 3 | 1; | |||||||||