| 1 | package Plack::Middleware::DoormanAuthentication; | ||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 2 | our $VERSION = "0.06"; | |||||||||||||||||||||||||||||||
| 6 | 2 | our $AUTHORITY = "http://gugod.org"; | |||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use parent 'Doorman::PlackMiddleware'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Plack::Util::Accessor qw(authenticator); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Plack::Session; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | sub is_sign_in { | ||||||||||||||||||||||||||||||
|
Subroutine
is_sign_in: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 14 | 6 | $_[0]->session_get("authenticated"); | |||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 6 | ▶ | sub call { | ||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 18 | 6 | my ($self, $env) = @_; | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 6 | $self->prepare_call($env); | |||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 6 | $env->{ $self->fq } = $self; | |||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 6 | my $request = Plack::Request->new($env); | |||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | 6 | ▶ | if ($request->method eq 'POST' and $request->path eq $self->sign_in_path) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$request->method eq "POST" and $request->path eq $self->sign_in_path
MC/DC50%1/2
$request->method eq "POST" and $request->path eq $self->sign_in_path
$request->method eq "POST"
$request->path eq $self->sign_in_path
Truth table66%2/3
A and B
A= $request->method eq "POST"B= $request->path eq $self->sign_in_path
| |||||||||||||||||||||||||||||||||
| 27 | 2 | my ($success, $error_message) = $self->authenticator->($self, $self->{env}); | |||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | if ($success) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 29 | 1 | $self->session_set("authenticated" => $success); | |||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||||||
| 32 | 1 | $self->env_set("error" => $error_message); | |||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | ▶ | elsif ($request->method eq 'GET' and $request->path eq $self->sign_out_path) { | |||||||||||||||||||||||||||||||
|
Condition66%2/3
$request->method eq "GET" and $request->path eq $self->sign_out_path
MC/DC50%1/2
$request->method eq "GET" and $request->path eq $self->sign_out_path
$request->method eq "GET"
$request->path eq $self->sign_out_path
Truth table66%2/3
A and B
A= $request->method eq "GET"B= $request->path eq $self->sign_out_path
| |||||||||||||||||||||||||||||||||
| 36 | 1 | $self->session_remove("authenticated"); | |||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 6 | return $self->app->($env); | |||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 2 | 1; | |||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | __END__ | ||||||||||||||||||||||||||||||||