| 1 | package WWW::Authentik::API; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: authentik REST API v3 with idempotent ensure methods | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | with 'WWW::Authentik::Role::HTTP'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Types::Standard qw( InstanceOf Int Str ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use URI::Escape qw( uri_escape_utf8 ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use WWW::Authentik::Diff; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use WWW::Authentik::Error; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use WWW::Authentik::Error::Validation; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 7 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | has base_url => ( | |||||||||||||||||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | has token => ( | |||||||||||||||||||||||||||||||||||||||||
| 26 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 27 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 7 | has ua => ( | |||||||||||||||||||||||||||||||||||||||||
| 33 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => InstanceOf['LWP::UserAgent'], | ||||||||||||||||||||||||||||||||||||||||||
| 35 | required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 7 | has page_size => ( | |||||||||||||||||||||||||||||||||||||||||
| 40 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | default => 100 | ||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # what counts as an identifier rather than a readable name, per field; see | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # resolvable_fields below. Named methods, not lexicals, so that | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # Net::Async::Authentik asks the same two questions instead of writing the | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # patterns out a second time. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 7 | my $UUID = qr{\A[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\z}; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 7 | my $INTEGER = qr{\A[0-9]+\z}; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | sub uuid_pattern { $UUID } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uuid_pattern: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | ▶ | sub integer_pattern { $INTEGER } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
integer_pattern: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 22 | ▶ | sub diff_class { 'WWW::Authentik::Diff' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diff_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | #### transport | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 250 | ▶ | sub api_url { $_[0]->base_url.'/api/v3' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 249 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 249 | my ( $self, $method, $path, $body ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 249 | ▶ | $path = '/'.$path unless $path =~ m{\A/}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 249 | ▶ | my %arg = defined $body ? ( json => $body ) : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 249 | return $self->send_request( $method, $self->api_url.$path, %arg, bearer => $self->token ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 221 | ▶ | sub _data { $_[0]->call( @_[ 1 .. $#_ ] )->{data} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_data: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 23 | ▶ | sub _done { $_[0]->call( @_[ 1 .. $#_ ] ); 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_done: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 678 | ▶ | sub _esc { uri_escape_utf8( $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_esc: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 100 | ▶ | sub _query { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_query: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 100 | my ( $self, %query ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 100 | ▶ | return '' unless %query; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 289 | return '?'.join '&', map { $self->_esc($_).'='.$self->_esc( $query{$_} ) } | |||||||||||||||||||||||||||||||||||||||||
| 81 | 99 | grep { defined $query{$_} } sort keys %query; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 95 | ▶ | sub _paged { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_paged: called CC=8 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 95 | my ( $self, $path, %query ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 95 | ▶ | my $page_size = delete $query{page_size} // $self->page_size; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $query{"page_size"} // $self->page_size
MC/DC0%0/2
delete $query{"page_size"} // $self->page_size
delete $query{"page_size"}
$self->page_size
Truth table33%1/3
A // B
A= delete $query{"page_size"}B= $self->page_size
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 95 | my ( @all, %seen ); | |||||||||||||||||||||||||||||||||||||||||
| 88 | 95 | my $page = 1; | |||||||||||||||||||||||||||||||||||||||||
| 89 | # a broken answer whose next points at a page already fetched would loop | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # for ever; %seen is the floor under that | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 95 | ▶ | while ( defined $page && $page > 0 && !$seen{$page}++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $page and $page > 0 and not $seen{$page}++
defined $page and $page > 0
MC/DC66%2/3
defined $page and $page > 0 and not $seen{$page}++
defined $page
$page > 0
not $seen{$page}++
Truth table75%3/4
A and B and not(C)
A= defined $pageB= $page > 0C= not $seen{$page}++
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 97 | my $data = $self->_data( GET => $path.$self->_query( %query, page => $page, page_size => $page_size ) ); | |||||||||||||||||||||||||||||||||||||||||
| 93 | 97 | ▶ | last unless ref $data eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 97 | ▶ | push @all, @{ $data->{results} || [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$data->{'results'} || []
MC/DC0%0/1
$data->{'results'} || []
$data->{'results'}
Truth table50%1/2
A
A= $data->{'results'}
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 97 | ▶ | $page = ref $data->{pagination} eq 'HASH' ? $data->{pagination}{next} : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 95 | return \@all; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 10 | ▶ | sub _missing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_missing: called CC=4 SCAR=18.9
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 10 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 10 | ▶ | return 1 if blessed $error && $error->isa('WWW::Authentik::Error::API') && $error->is_not_found; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
builtin::blessed($error) and $error->isa("WWW::Authentik::Error::API") and $error->is_not_found
builtin::blessed($error) and $error->isa("WWW::Authentik::Error::API")
MC/DC0%0/3
builtin::blessed($error) and $error->isa("WWW::Authentik::Error::API") and $error->is_not_found
builtin::blessed($error)
$error->isa("WWW::Authentik::Error::API")
$error->is_not_found
Truth table25%1/4
A and B and C
A= builtin::blessed($error)B= $error->isa("WWW::Authentik::Error::API")C= $error->is_not_found
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | die $error; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 66 | ▶ | sub _find_one { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_one: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 66 | my ( $self, $list, $key, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 66 | ▶ | my ( $found ) = grep { defined $_->{$key} && $_->{$key} eq $value } @$list; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $_->{$key} && $_->{$key} eq $value
MC/DC0%0/2
defined $_->{$key} && $_->{$key} eq $value
defined $_->{$key}
$_->{$key} eq $value
Truth table33%1/3
A && B
A= defined $_->{$key}B= $_->{$key} eq $value
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 66 | return $found; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | # a finder called with nothing would otherwise fetch every object and compare | ||||||||||||||||||||||||||||||||||||||||||
| 113 | # each one against undef, warning once per row and finding nothing | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 119 | ▶ | sub _need { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_need: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 119 | my ( $self, $what, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 119 | ▶ | WWW::Authentik::Error::Validation->throw( message => $what.' is needed' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $value and length $value
MC/DC100%2/2
defined $value and length $value
defined $value
length $value
Truth table100%3/3
A and B
A= defined $valueB= length $value
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | unless defined $value && length $value; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 101 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 38 | ▶ | sub _detail { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_detail: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 38 | my ( $self, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 38 | my $object = eval { $self->_data( GET => $path ) }; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 38 | ▶ | return $object if $object; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 9 | $self->_missing($@); | |||||||||||||||||||||||||||||||||||||||||
| 126 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | #### instance | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | ▶ | sub version { $_[0]->_data( GET => '/admin/version/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | sub config { $_[0]->_data( GET => '/root/config/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | sub settings { $_[0]->_data( GET => '/admin/settings/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
settings: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | sub me { $_[0]->_data( GET => '/core/users/me/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
me: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | #### users | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 17 | ▶ | sub list_users { my ( $self, %q ) = @_; $self->_paged( '/core/users/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_users: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 3 | ▶ | sub get_user { $_[0]->_data( GET => '/core/users/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 9 | ▶ | sub create_user { $_[0]->_data( POST => '/core/users/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | ▶ | sub update_user { $_[0]->_data( PATCH => '/core/users/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | sub delete_user { $_[0]->_done( DELETE => '/core/users/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 15 | ▶ | sub find_user { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 15 | my ( $self, $username ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 15 | $self->_need( 'find_user: a username', $username ); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 13 | return $self->_find_one( $self->list_users( username => $username ), 'username', $username ); | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | ▶ | sub set_password { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_password: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | my ( $self, $pk, $password ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | return $self->_done( POST => '/core/users/'.$self->_esc($pk).'/set_password/', { password => $password } ); | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | ▶ | sub create_service_account { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_service_account: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | my ( $self, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'create_service_account needs a name' ) unless defined $arg{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | return $self->_data( POST => '/core/users/service_account/', | ||||||||||||||||||||||||||||||||||||||||||
| 160 | { name => $arg{name}, create_group => $arg{create_group} ? \1 : \0, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | exists $arg{expiring} ? ( expiring => $arg{expiring} ) : () } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | ▶ | sub list_authenticators { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_authenticators: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | my ( $self, $pk ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | return $self->_data( GET => '/authenticators/admin/all/'.$self->_query( user => $pk ) ); | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | #### groups | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 14 | ▶ | sub list_groups { my ( $self, %q ) = @_; $self->_paged( '/core/groups/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_groups: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | ▶ | sub get_group { $_[0]->_data( GET => '/core/groups/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | ▶ | sub create_group { $_[0]->_data( POST => '/core/groups/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | ▶ | sub update_group { $_[0]->_data( PATCH => '/core/groups/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | sub delete_group { $_[0]->_done( DELETE => '/core/groups/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 16 | ▶ | sub find_group { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 16 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 16 | $self->_need( 'find_group: a name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 181 | 14 | return $self->_find_one( $self->list_groups( name => $name ), 'name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | sub add_user_to_group { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_user_to_group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | my ( $self, $uuid, $pk ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | return $self->_done( POST => '/core/groups/'.$self->_esc($uuid).'/add_user/', { pk => $pk } ); | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | ▶ | sub remove_user_from_group { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_user_from_group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | my ( $self, $uuid, $pk ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | return $self->_done( POST => '/core/groups/'.$self->_esc($uuid).'/remove_user/', { pk => $pk } ); | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | #### tokens | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub list_tokens { my ( $self, %q ) = @_; $self->_paged( '/core/tokens/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_tokens: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | sub get_token { $_[0]->_data( GET => '/core/tokens/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_token: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 4 | ▶ | sub create_token { $_[0]->_data( POST => '/core/tokens/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_token: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | sub update_token { $_[0]->_data( PATCH => '/core/tokens/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_token: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | sub delete_token { $_[0]->_done( DELETE => '/core/tokens/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_token: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 8 | ▶ | sub find_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_token: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 8 | my ( $self, $identifier ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 8 | $self->_need( 'find_token: an identifier', $identifier ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 6 | return $self->_detail( '/core/tokens/'.$self->_esc($identifier).'/' ); | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | ▶ | sub view_token_key { $_[0]->_data( GET => '/core/tokens/'.$_[0]->_esc( $_[1] ).'/view_key/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
view_token_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | sub set_token_key { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_token_key: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | my ( $self, $identifier, $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | return $self->_done( POST => '/core/tokens/'.$self->_esc($identifier).'/set_key/', { key => $key } ); | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | #### applications | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub list_applications { my ( $self, %q ) = @_; $self->_paged( '/core/applications/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_applications: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | ▶ | sub create_application { $_[0]->_data( POST => '/core/applications/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_application: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | ▶ | sub update_application { $_[0]->_data( PATCH => '/core/applications/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_application: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | sub delete_application { $_[0]->_done( DELETE => '/core/applications/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_application: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 8 | ▶ | sub find_application { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_application: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 8 | my ( $self, $slug ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 8 | $self->_need( 'find_application: a slug', $slug ); | |||||||||||||||||||||||||||||||||||||||||
| 227 | 6 | return $self->_detail( '/core/applications/'.$self->_esc($slug).'/' ); | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | sub check_access { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_access: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | my ( $self, $slug, %opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 232 | return $self->_data( GET => '/core/applications/'.$self->_esc($slug).'/check_access/' | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | ▶ | .$self->_query( defined $opt{for_user} ? ( for_user => $opt{for_user} ) : () ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | #### oauth2 providers | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 12 | ▶ | sub list_oauth2_providers { my ( $self, %q ) = @_; $self->_paged( '/providers/oauth2/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_oauth2_providers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | ▶ | sub get_oauth2_provider { $_[0]->_data( GET => '/providers/oauth2/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_oauth2_provider: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 3 | ▶ | sub create_oauth2_provider { $_[0]->_data( POST => '/providers/oauth2/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_oauth2_provider: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 4 | ▶ | sub update_oauth2_provider { $_[0]->_data( PATCH => '/providers/oauth2/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_oauth2_provider: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | ▶ | sub delete_oauth2_provider { $_[0]->_done( DELETE => '/providers/oauth2/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_oauth2_provider: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 14 | ▶ | sub find_oauth2_provider { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_oauth2_provider: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 14 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 14 | $self->_need( 'find_oauth2_provider: a name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 248 | 12 | return $self->_find_one( $self->list_oauth2_providers( name => $name ), 'name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | ▶ | sub provider_setup_urls { $_[0]->_data( GET => '/providers/oauth2/'.$_[0]->_esc( $_[1] ).'/setup_urls/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
provider_setup_urls: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | sub preview_user { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preview_user: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | my ( $self, $pk, $user_pk ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | ▶ | return $self->_data( GET => '/providers/oauth2/'.$self->_esc($pk).'/preview_user/' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | .$self->_query( defined $user_pk ? ( for_user => $user_pk ) : () ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | #### scope mappings | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 22 | ▶ | sub list_scope_mappings { my ( $self, %q ) = @_; $self->_paged( '/propertymappings/provider/scope/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_scope_mappings: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub get_scope_mapping { $_[0]->_data( GET => '/propertymappings/provider/scope/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_scope_mapping: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | ▶ | sub create_scope_mapping { $_[0]->_data( POST => '/propertymappings/provider/scope/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_scope_mapping: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | ▶ | sub update_scope_mapping { $_[0]->_data( PATCH => '/propertymappings/provider/scope/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_scope_mapping: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | ▶ | sub delete_scope_mapping { $_[0]->_done( DELETE => '/propertymappings/provider/scope/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_scope_mapping: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 5 | ▶ | sub find_scope_mapping { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_scope_mapping: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | $self->_need( 'find_scope_mapping: a name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | return $self->_find_one( $self->list_scope_mappings( name => $name ), 'name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 11 | ▶ | sub find_scope_mappings_by_scope { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_scope_mappings_by_scope: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 11 | my ( $self, @scopes ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 11 | my @found; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 11 | for my $scope (@scopes) { | |||||||||||||||||||||||||||||||||||||||||
| 278 | 18 | my ( $mapping ) = @{ $self->list_scope_mappings( scope_name => $scope ) }; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 18 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'no scope mapping for the scope "'.$scope.'"' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | unless $mapping; | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 16 | push @found, $mapping; | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 9 | return \@found; | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | ▶ | sub test_property_mapping { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_property_mapping: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | my ( $self, $uuid, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | return $self->_data( POST => '/propertymappings/all/'.$self->_esc($uuid).'/test/', { %arg } ); | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | #### flows | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub list_flows { my ( $self, %q ) = @_; $self->_paged( '/flows/instances/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_flows: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 3 | ▶ | sub create_flow { $_[0]->_data( POST => '/flows/instances/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_flow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | ▶ | sub update_flow { $_[0]->_data( PATCH => '/flows/instances/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_flow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | ▶ | sub delete_flow { $_[0]->_done( DELETE => '/flows/instances/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_flow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 28 | ▶ | sub find_flow { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_flow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 28 | my ( $self, $slug ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 28 | $self->_need( 'find_flow: a slug', $slug ); | |||||||||||||||||||||||||||||||||||||||||
| 302 | 26 | return $self->_detail( '/flows/instances/'.$self->_esc($slug).'/' ); | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | ▶ | sub export_flow { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export_flow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | my ( $self, $slug ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | return $self->call( GET => '/flows/instances/'.$self->_esc($slug).'/export/' )->{content}; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | #### stages | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | sub stage_types { $_[0]->_data( GET => '/stages/all/types/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stage_types: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 14 | ▶ | sub list_stages { my ( $self, %q ) = @_; $self->_paged( '/stages/all/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_stages: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 16 | ▶ | sub find_stage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_stage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 16 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 16 | $self->_need( 'find_stage: a name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 319 | 14 | return $self->_find_one( $self->list_stages( name => $name ), 'name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 23 | ▶ | sub _stage_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stage_path: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 23 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 23 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'a stage type is needed, for example password or authenticator/validate' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $type and length $type
MC/DC50%1/2
defined $type and length $type
defined $type
length $type
Truth table66%2/3
A and B
A= defined $typeB= length $type
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | unless defined $type && length $type; | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 22 | ▶ | WWW::Authentik::Error::Validation->throw( message => '/stages/all/ can only be read: name the stage type, for example password' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | if $type eq 'all'; | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 20 | $type =~ s{\A/}{}; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 20 | $type =~ s{/\z}{}; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 20 | return '/stages/'.$type.'/'; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 5 | ▶ | sub get_stage { my ( $self, $type, $uuid ) = @_; $self->_data( GET => $self->_stage_path($type).$self->_esc($uuid).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_stage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 6 | ▶ | sub create_stage { my ( $self, $type, $rep ) = @_; $self->_data( POST => $self->_stage_path($type), $rep ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_stage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | ▶ | sub update_stage { my ( $self, $type, $uuid, $rep ) = @_; $self->_data( PATCH => $self->_stage_path($type).$self->_esc($uuid).'/', $rep ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_stage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | ▶ | sub delete_stage { my ( $self, $type, $uuid ) = @_; $self->_done( DELETE => $self->_stage_path($type).$self->_esc($uuid).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_stage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | #### flow stage bindings | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 8 | ▶ | sub list_bindings { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_bindings: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 8 | my ( $self, %q ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 343 | # authentik wants the flow's UUID in target and answers a slug with a field | ||||||||||||||||||||||||||||||||||||||||||
| 344 | # error, so flow => $slug is the readable way in | ||||||||||||||||||||||||||||||||||||||||||
| 345 | 8 | ▶ | $q{target} = $self->_flow_pk( delete $q{flow} ) if defined $q{flow}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 7 | return $self->_paged( '/flows/bindings/', %q ); | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 8 | ▶ | sub _flow_pk { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flow_pk: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 8 | my ( $self, $flow ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 8 | ▶ | return $flow if $flow =~ $UUID; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 7 | ▶ | my $found = $self->find_flow($flow) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | or WWW::Authentik::Error::Validation->throw( message => 'no flow "'.$flow.'"' ); | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 5 | return $found->{pk}; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub get_binding { $_[0]->_data( GET => '/flows/bindings/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_binding: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | ▶ | sub create_binding { $_[0]->_data( POST => '/flows/bindings/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_binding: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | ▶ | sub update_binding { $_[0]->_data( PATCH => '/flows/bindings/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_binding: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | ▶ | sub delete_binding { $_[0]->_done( DELETE => '/flows/bindings/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_binding: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | #### brands, certificates, blueprints | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 2 | ▶ | sub list_brands { my ( $self, %q ) = @_; $self->_paged( '/core/brands/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_brands: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | sub current_brand { $_[0]->_data( GET => '/core/brands/current/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_brand: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | ▶ | sub update_brand { $_[0]->_data( PATCH => '/core/brands/'.$_[0]->_esc( $_[1] ).'/', $_[2] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_brand: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 7 | ▶ | sub list_certificates { my ( $self, %q ) = @_; $self->_paged( '/crypto/certificatekeypairs/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_certificates: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 9 | ▶ | sub find_certificate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_certificate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 9 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 372 | 9 | $self->_need( 'find_certificate: a name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 373 | 7 | return $self->_find_one( $self->list_certificates( name => $name ), 'name', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | sub list_blueprints { my ( $self, %q ) = @_; $self->_paged( '/managed/blueprints/', %q ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_blueprints: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | ▶ | sub get_blueprint { $_[0]->_data( GET => '/managed/blueprints/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_blueprint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | ▶ | sub create_blueprint { $_[0]->_data( POST => '/managed/blueprints/', $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_blueprint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | ▶ | sub apply_blueprint { $_[0]->_data( POST => '/managed/blueprints/'.$_[0]->_esc( $_[1] ).'/apply/', {} ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_blueprint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | ▶ | sub delete_blueprint { $_[0]->_done( DELETE => '/managed/blueprints/'.$_[0]->_esc( $_[1] ).'/' ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_blueprint: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | #### resolve | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 70 | ▶ | sub resolvable_fields { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolvable_fields: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 70 | provider => { force => 'provider_name', raw => $INTEGER, find => 'find_oauth2_provider', what => 'oauth2 provider' }, | |||||||||||||||||||||||||||||||||||||||||
| 388 | authorization_flow => { force => 'authorization_flow_slug', raw => $UUID, find => 'find_flow', what => 'flow' }, | ||||||||||||||||||||||||||||||||||||||||||
| 389 | invalidation_flow => { force => 'invalidation_flow_slug', raw => $UUID, find => 'find_flow', what => 'flow' }, | ||||||||||||||||||||||||||||||||||||||||||
| 390 | authentication_flow => { force => 'authentication_flow_slug', raw => $UUID, find => 'find_flow', what => 'flow' }, | ||||||||||||||||||||||||||||||||||||||||||
| 391 | configure_flow => { force => 'configure_flow_slug', raw => $UUID, find => 'find_flow', what => 'flow' }, | ||||||||||||||||||||||||||||||||||||||||||
| 392 | flow_device_code => { force => 'flow_device_code_slug', raw => $UUID, find => 'find_flow', what => 'flow' }, | ||||||||||||||||||||||||||||||||||||||||||
| 393 | signing_key => { force => 'signing_key_name', raw => $UUID, find => 'find_certificate', what => 'certificate' }, | ||||||||||||||||||||||||||||||||||||||||||
| 394 | encryption_key => { force => 'encryption_key_name', raw => $UUID, find => 'find_certificate', what => 'certificate' }, | ||||||||||||||||||||||||||||||||||||||||||
| 395 | user => { force => 'user_name', raw => $INTEGER, find => 'find_user', what => 'user' }, | ||||||||||||||||||||||||||||||||||||||||||
| 396 | groups => { force => 'group_names', raw => $UUID, find => 'find_group', what => 'group', list => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 397 | property_mappings => { force => 'property_mapping_names', raw => $UUID, find => 'find_scope_mapping', what => 'scope mapping', list => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 398 | configuration_stages => { force => 'configuration_stage_names', raw => $UUID, find => 'find_stage', what => 'stage', list => 1 } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 68 | ▶ | sub resolve { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve: called CC=17 SCAR=28.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 68 | my ( $self, $rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 68 | my %out = %$rep; | |||||||||||||||||||||||||||||||||||||||||
| 405 | 68 | my $fields = $self->resolvable_fields; | |||||||||||||||||||||||||||||||||||||||||
| 406 | 68 | ▶ | if ( exists $out{scopes} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | WWW::Authentik::Error::Validation->throw( message => 'give either scopes or property_mappings, not both' ) | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 10 | ▶ | if exists $out{property_mappings} || exists $out{property_mapping_names}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $out{"property_mappings"} or exists $out{"property_mapping_names"}
MC/DC50%1/2
exists $out{"property_mappings"} or exists $out{"property_mapping_names"}
exists $out{"property_mappings"}
exists $out{"property_mapping_names"}
Truth table66%2/3
A or B
A= exists $out{"property_mappings"}B= exists $out{"property_mapping_names"}
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 9 | my $scopes = delete $out{scopes}; | |||||||||||||||||||||||||||||||||||||||||
| 410 | # an undef here is a mistake in the caller, and a costly one: taking it | ||||||||||||||||||||||||||||||||||||||||||
| 411 | # for an empty list would strip every mapping off the provider | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 9 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'scopes is undef: give a list of scope names, ' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | .'or an empty list to take every mapping away' ) | ||||||||||||||||||||||||||||||||||||||||||
| 414 | unless defined $scopes; | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 8 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'scopes takes a list of scope names' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | unless ref $scopes eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 7 | $out{property_mappings} = [ map { $_->{pk} } @{ $self->find_scope_mappings_by_scope(@$scopes) } ]; | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 64 | for my $field ( sort keys %$fields ) { | |||||||||||||||||||||||||||||||||||||||||
| 420 | 749 | my $spec = $fields->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 749 | my $forced = exists $out{ $spec->{force} }; | |||||||||||||||||||||||||||||||||||||||||
| 422 | WWW::Authentik::Error::Validation->throw( message => 'give either '.$field.' or '.$spec->{force}.', not both' ) | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 749 | ▶ | if $forced && exists $out{$field}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$forced and exists $out{$field}
MC/DC100%2/2
$forced and exists $out{$field}
$forced
exists $out{$field}
Truth table100%3/3
A and B
A= $forcedB= exists $out{$field}
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 748 | ▶ | next unless $forced || exists $out{$field}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$forced or exists $out{$field}
MC/DC100%2/2
$forced or exists $out{$field}
$forced
exists $out{$field}
Truth table100%3/3
A or B
A= $forcedB= exists $out{$field}
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 47 | ▶ | my $value = $forced ? delete $out{ $spec->{force} } : $out{$field}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | # the forced form says "look this name up", so an undef there is a | ||||||||||||||||||||||||||||||||||||||||||
| 427 | # mistake, not a wish to leave the field alone | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 47 | ▶ | WWW::Authentik::Error::Validation->throw( message => $spec->{force}.' is undef: give a name to look up, ' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$forced and not defined $value
MC/DC100%2/2
$forced and not defined $value
$forced
not defined $value
Truth table100%3/3
A and not(B)
A= $forcedB= not defined $value
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | .'or '.$field.' to set the identifier itself' ) | ||||||||||||||||||||||||||||||||||||||||||
| 430 | if $forced && !defined $value; | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 46 | ▶ | next unless defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | $out{$field} = $spec->{list} | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 44 | ▶ | ? [ map { $self->_resolve_one( $field, $spec, $_, $forced ) } @{ ref $value eq 'ARRAY' ? $value : [$value] } ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | : $self->_resolve_one( $field, $spec, $value, $forced ); | ||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | 58 | return \%out; | |||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 50 | ▶ | sub _resolve_one { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_one: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 50 | my ( $self, $field, $spec, $value, $forced ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 441 | WWW::Authentik::Error::Validation->throw( message => 'cannot set '.$field.': expected '.$spec->{what} | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 50 | ▶ | .' as a name or an identifier, got a '.lc( ref $value ).' reference' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | if ref $value; | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 49 | ▶ | return $value if !$forced && $value =~ $spec->{raw}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $forced and $value =~ /$spec->{"raw"}/
MC/DC100%2/2
not $forced and $value =~ /$spec->{"raw"}/
not $forced
$value =~ /$spec->{"raw"}/
Truth table100%3/3
not(A) and B
A= not $forcedB= $value =~ /$spec->{"raw"}/
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 29 | my $find = $spec->{find}; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 29 | my $found = $self->$find($value); | |||||||||||||||||||||||||||||||||||||||||
| 447 | 29 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'cannot set '.$field.': no '.$spec->{what}.' named "'.$value.'"' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | unless $found; | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 26 | return $found->{pk}; | |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | #### ensure | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 38 | ▶ | sub _ensure { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ensure: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 38 | my ( $self, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 38 | my $current = $arg{find}->(); | |||||||||||||||||||||||||||||||||||||||||
| 458 | 37 | ▶ | unless ($current) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 15 | my $object = $arg{create}->(); | |||||||||||||||||||||||||||||||||||||||||
| 460 | 13 | ▶ | $arg{after_create}->($object) if $arg{after_create}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 13 | return { object => $object, changed => 'created' }; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 22 | my $changes = $self->diff_class->changes( $current, $arg{wanted} ); | |||||||||||||||||||||||||||||||||||||||||
| 464 | 22 | ▶ | return { object => $current, changed => '' } unless %$changes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | 8 | return { object => $arg{update}->( $current, $changes ), changed => 'updated' }; | |||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 7 | ▶ | sub ensure_user { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_user: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 7 | my ( $self, %rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 7 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_user needs a username' ) unless defined $rep{username}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 6 | my $wanted = $self->resolve( \%rep ); | |||||||||||||||||||||||||||||||||||||||||
| 472 | 6 | my $password = delete $wanted->{password}; | |||||||||||||||||||||||||||||||||||||||||
| 473 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 474 | wanted => $wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 6 | ▶ | find => sub { $self->find_user( $rep{username} ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 2 | ▶ | create => sub { $self->create_user($wanted) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | # a password is set when the user is created and never again, so running a | ||||||||||||||||||||||||||||||||||||||||||
| 478 | # setup twice does not reset it; call set_password to change one | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 2 | ▶ | after_create => sub { $self->set_password( $_[0]{pk}, $password ) if defined $password }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 1 | ▶ | update => sub { $self->update_user( $_[0]{pk}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 6 | ▶ | sub ensure_group { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_group: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 6 | my ( $self, %rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 6 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_group needs a name' ) unless defined $rep{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 5 | my $wanted = $self->resolve( \%rep ); | |||||||||||||||||||||||||||||||||||||||||
| 488 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 489 | wanted => $wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 5 | ▶ | find => sub { $self->find_group( $rep{name} ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | ▶ | create => sub { $self->create_group($wanted) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | ▶ | update => sub { $self->update_group( $_[0]{pk}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | 6 | ▶ | sub ensure_token { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_token: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 6 | my ( $self, %rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 6 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_token needs an identifier' ) unless defined $rep{identifier}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | # authentik ignores expires and sets it from default_token_duration, so a | ||||||||||||||||||||||||||||||||||||||||||
| 500 | # wanted value could never be reached and would report updated for ever | ||||||||||||||||||||||||||||||||||||||||||
| 501 | WWW::Authentik::Error::Validation->throw( message => 'ensure_token cannot set expires: authentik ignores it and ' | ||||||||||||||||||||||||||||||||||||||||||
| 502 | .'sets the expiry from the instance setting default_token_duration. Use expiring to say whether it expires at all.' ) | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 5 | ▶ | if exists $rep{expires}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 4 | my $wanted = $self->resolve( \%rep ); | |||||||||||||||||||||||||||||||||||||||||
| 505 | 4 | my $key = delete $wanted->{key}; | |||||||||||||||||||||||||||||||||||||||||
| 506 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 507 | wanted => $wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 508 | 4 | ▶ | find => sub { $self->find_token( $rep{identifier} ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 2 | ▶ | create => sub { $self->create_token($wanted) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | # like a password: the key is put on the token when it is created, never after | ||||||||||||||||||||||||||||||||||||||||||
| 511 | 2 | ▶ | after_create => sub { $self->set_token_key( $rep{identifier}, $key ) if defined $key }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | update => sub { $self->update_token( $rep{identifier}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 4 | ▶ | sub ensure_application { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_application: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 4 | my ( $self, %rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 518 | 4 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_application needs a slug' ) unless defined $rep{slug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | my $wanted = $self->resolve( \%rep ); | |||||||||||||||||||||||||||||||||||||||||
| 520 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 521 | wanted => $wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 522 | 3 | ▶ | find => sub { $self->find_application( $rep{slug} ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 1 | ▶ | create => sub { $self->create_application($wanted) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 1 | ▶ | update => sub { $self->update_application( $rep{slug}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | 5 | ▶ | sub ensure_oauth2_provider { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_oauth2_provider: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | 5 | my ( $self, %rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 5 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_oauth2_provider needs a name' ) unless defined $rep{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 5 | my $wanted = $self->resolve( \%rep ); | |||||||||||||||||||||||||||||||||||||||||
| 532 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 533 | wanted => $wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 5 | ▶ | find => sub { $self->find_oauth2_provider( $rep{name} ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 2 | ▶ | create => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | # authentik defaults grant_types to an empty list, and a provider with | ||||||||||||||||||||||||||||||||||||||||||
| 537 | # an empty list answers every token request with invalid_grant. Which | ||||||||||||||||||||||||||||||||||||||||||
| 538 | # grants were meant is not something this client guesses. | ||||||||||||||||||||||||||||||||||||||||||
| 539 | WWW::Authentik::Error::Validation->throw( message => 'ensure_oauth2_provider needs grant_types to create a provider: ' | ||||||||||||||||||||||||||||||||||||||||||
| 540 | .'authentik would store an empty list, and such a provider answers every token request with invalid_grant' ) | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 2 | ▶ | unless ref $wanted->{grant_types} eq 'ARRAY' && @{ $wanted->{grant_types} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $wanted->{"grant_types"} eq "ARRAY" and @{$wanted->{"grant_types"};}
MC/DC50%1/2
ref $wanted->{"grant_types"} eq "ARRAY" and @{$wanted->{"grant_types"};}
ref $wanted->{"grant_types"} eq "ARRAY"
@{$wanted->{"grant_types"};}
Truth table66%2/3
A and B
A= ref $wanted->{"grant_types"} eq "ARRAY"B= @{$wanted->{"grant_types"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | 1 | $self->create_oauth2_provider($wanted); | |||||||||||||||||||||||||||||||||||||||||
| 543 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 2 | ▶ | update => sub { $self->update_oauth2_provider( $_[0]{pk}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | ▶ | sub ensure_scope_mapping { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_scope_mapping: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | my ( $self, %rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 550 | 2 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_scope_mapping needs a name' ) unless defined $rep{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 2 | my $wanted = $self->resolve( \%rep ); | |||||||||||||||||||||||||||||||||||||||||
| 552 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 553 | wanted => $wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 2 | ▶ | find => sub { $self->find_scope_mapping( $rep{name} ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | ▶ | create => sub { $self->create_scope_mapping($wanted) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | update => sub { $self->update_scope_mapping( $_[0]{pk}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 3 | ▶ | sub ensure_flow { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_flow: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 3 | my ( $self, %rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 562 | 3 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_flow needs a slug' ) unless defined $rep{slug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 3 | my $wanted = $self->resolve( \%rep ); | |||||||||||||||||||||||||||||||||||||||||
| 564 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 565 | wanted => $wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 566 | 3 | ▶ | find => sub { $self->find_flow( $rep{slug} ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 1 | ▶ | create => sub { $self->create_flow($wanted) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | ▶ | update => sub { $self->update_flow( $rep{slug}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 9 | ▶ | sub ensure_stage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_stage: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | 9 | my ( $self, $type, %rep ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 9 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_stage needs a name' ) unless defined $rep{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | 8 | $self->_stage_path($type); # refuses 'all' and a missing type | |||||||||||||||||||||||||||||||||||||||||
| 576 | 7 | my $wanted = $self->resolve( \%rep ); | |||||||||||||||||||||||||||||||||||||||||
| 577 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 578 | wanted => $wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 579 | 7 | ▶ | find => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 580 | 7 | ▶ | my $stage = $self->find_stage( $rep{name} ) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | # a stage name is unique across all types, so a name that belongs to | ||||||||||||||||||||||||||||||||||||||||||
| 582 | # another type is a clash, not something to create or update | ||||||||||||||||||||||||||||||||||||||||||
| 583 | 3 | my $whole = eval { $self->get_stage( $type, $stage->{pk} ) }; | |||||||||||||||||||||||||||||||||||||||||
| 584 | 3 | ▶ | return $whole if $whole; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | $self->_missing($@); | |||||||||||||||||||||||||||||||||||||||||
| 586 | WWW::Authentik::Error::Validation->throw( message => 'ensure_stage: there already is a stage named "' | ||||||||||||||||||||||||||||||||||||||||||
| 587 | 1 | ▶ | .$rep{name}.'", but not of the type '.$type.' ('.( $stage->{component} // 'unknown component' ).'). ' | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$stage->{"component"} // "unknown component"
MC/DC0%0/1
$stage->{"component"} // "unknown component"
$stage->{"component"}
Truth table50%1/2
A
A= $stage->{"component"}
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | .'Stage names are unique across all types in authentik.' ); | ||||||||||||||||||||||||||||||||||||||||||
| 589 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 4 | ▶ | create => sub { $self->create_stage( $type, $wanted ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 1 | ▶ | update => sub { $self->update_stage( $type, $_[0]{pk}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 7 | ); | |||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 6 | ▶ | sub ensure_binding { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ensure_binding: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 6 | my ( $self, %arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 597 | 6 | for (qw( flow stage order )) { | |||||||||||||||||||||||||||||||||||||||||
| 598 | 18 | ▶ | WWW::Authentik::Error::Validation->throw( message => 'ensure_binding needs '.$_ ) unless defined $arg{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 5 | my %wanted = %arg; | |||||||||||||||||||||||||||||||||||||||||
| 601 | 5 | my $flow = eval { $self->_flow_pk( delete $wanted{flow} ) } | |||||||||||||||||||||||||||||||||||||||||
| 602 | 5 | ▶ | or WWW::Authentik::Error::Validation->throw( message => 'ensure_binding: no flow "'.$arg{flow}.'"' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 4 | my $stage = $wanted{stage}; | |||||||||||||||||||||||||||||||||||||||||
| 604 | 4 | ▶ | unless ( $stage =~ $UUID ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | 4 | ▶ | my $found = $self->find_stage($stage) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | or WWW::Authentik::Error::Validation->throw( message => 'ensure_binding: no stage "'.$stage.'"' ); | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 3 | $stage = $found->{pk}; | |||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | 3 | @wanted{qw( target stage )} = ( $flow, $stage ); | |||||||||||||||||||||||||||||||||||||||||
| 610 | return $self->_ensure( | ||||||||||||||||||||||||||||||||||||||||||
| 611 | wanted => \%wanted, | ||||||||||||||||||||||||||||||||||||||||||
| 612 | # a flow binds a stage at most once here; the order is what ensure moves | ||||||||||||||||||||||||||||||||||||||||||
| 613 | 3 | ▶ | find => sub { $self->_find_one( $self->list_bindings( target => $flow, stage => $stage ), 'stage', $stage ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | 1 | ▶ | create => sub { $self->create_binding( \%wanted ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | 1 | ▶ | update => sub { $self->update_binding( $_[0]{pk}, $_[1] ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | __END__ | ||||||||||||||||||||||||||||||||||||||||||