| 1 | package CatalystX::OAuth2::Controller::Role::Provider; | ||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use MooseX::SetOnce; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use Moose::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use Class::Load; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # ABSTRACT: A role for writing oauth2 provider controllers | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 9 | with 'CatalystX::OAuth2::Controller::Role::WithStore'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | has $_ => ( | ||||||||||||||||||||||||||||
| 12 | isa => 'Catalyst::Action', | ||||||||||||||||||||||||||||
| 13 | is => 'rw', | ||||||||||||||||||||||||||||
| 14 | traits => [qw(SetOnce)], | ||||||||||||||||||||||||||||
| 15 | predicate => "_has_$_" | ||||||||||||||||||||||||||||
| 16 | 9 | ) for qw(_request_auth_action _get_auth_token_via_auth_grant_action); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | around create_action => sub { | ||||||||||||||||||||||||||||
| 19 | 325 | ▶ | my $orig = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 20 | 325 | my $self = shift; | |||||||||||||||||||||||||||
| 21 | 325 | my $action = $self->$orig(@_); | |||||||||||||||||||||||||||
| 22 | 325 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 23 | Moose::Util::does_role( | ||||||||||||||||||||||||||||
| 24 | $action, 'Catalyst::ActionRole::OAuth2::RequestAuth' | ||||||||||||||||||||||||||||
| 25 | ) | ||||||||||||||||||||||||||||
| 26 | ) | ||||||||||||||||||||||||||||
| 27 | { | ||||||||||||||||||||||||||||
| 28 | 32 | $self->_request_auth_action($action); | |||||||||||||||||||||||||||
| 29 | } elsif ( | ||||||||||||||||||||||||||||
| 30 | Moose::Util::does_role( | ||||||||||||||||||||||||||||
| 31 | $action, 'Catalyst::ActionRole::OAuth2::GrantAuth' | ||||||||||||||||||||||||||||
| 32 | ) | ||||||||||||||||||||||||||||
| 33 | ) | ||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||
| 35 | 32 | $self->_get_auth_token_via_auth_grant_action($action); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 325 | return $action; | |||||||||||||||||||||||||||
| 39 | 9 | }; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub check_provider_actions { | ||||||||||||||||||||||||||||
| 42 | 33 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
check_provider_actions: called CC=3 SCAR=13.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | 33 | ▶ | die | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_has__request_auth_action and $self->_has__get_auth_token_via_auth_grant_action
MC/DC0%0/2
$self->_has__request_auth_action and $self->_has__get_auth_token_via_auth_grant_action
$self->_has__request_auth_action
$self->_has__get_auth_token_via_auth_grant_action
Truth table33%1/3
A and B
A= $self->_has__request_auth_actionB= $self->_has__get_auth_token_via_auth_grant_action
| |||||||||||||||||||||||||||||
| 44 | q{You need at least an auth action and a grant action for this controller to work} | ||||||||||||||||||||||||||||
| 45 | unless $self->_has__request_auth_action | ||||||||||||||||||||||||||||
| 46 | && $self->_has__get_auth_token_via_auth_grant_action; | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | after register_actions => sub { | ||||||||||||||||||||||||||||
| 50 | 33 | ▶ | shift->check_provider_actions; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | 9 | }; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 9 | 1; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =pod | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 NAME | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | CatalystX::OAuth2::Controller::Role::Provider - A role for writing oauth2 provider controllers | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 VERSION | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | version 0.001006 | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | Eden Cardim <edencardim@gmail.com> | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | This software is copyright (c) 2017 by Suretec Systems Ltd. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 76 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =cut | ||||||||||||||||||||||||||||