| 1 | package App::LDAP::Role::Bindable; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 5 | ▶ | use Modern::Perl; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 5 | ▶ | use Moose::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 5 | ▶ | use Term::ReadPassword; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 5 | with 'App::LDAP::Role'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 0 | ▶ | around prepare => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 12 | 0 | my $orig = shift; | |||||||||||||||||||
| 13 | 0 | my $self = shift; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 0 | ▶ | ($< == 0) ? bindroot() : binduser(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | $self->$orig(@_); | |||||||||||||||||||
| 18 | 5 | }; | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | ▶ | sub bindroot { | ||||||||||||||||||
|
Subroutine
bindroot: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 21 | ldap()->bind( | ||||||||||||||||||||
| 22 | config()->{rootbinddn}, | ||||||||||||||||||||
| 23 | 0 | ▶ | password => secret() // read_password("ldap admin password: "), | ||||||||||||||||||
|
Condition0%0/3
secret() // read_password("ldap admin password: ")
MC/DC0%0/2
secret() // read_password("ldap admin password: ")
secret()
read_password("ldap admin password: ")
Truth table0%0/3
A // B
A= secret()B= read_password("ldap admin password: ")
| |||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | sub binduser { | ||||||||||||||||||
|
Subroutine
binduser: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 28 | 0 | ▶ | ldap()->bind( | ||||||||||||||||||
|
Condition0%0/3
secret() // read_password("your password: ")
MC/DC0%0/2
secret() // read_password("your password: ")
secret()
read_password("your password: ")
Truth table0%0/3
A // B
A= secret()B= read_password("your password: ")
| |||||||||||||||||||||
| 29 | find_user("uidNumber", $<)->dn, | ||||||||||||||||||||
| 30 | password => secret() // read_password("your password: "), | ||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 5 | ▶ | no Moose::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 5 | 1; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =pod | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =head1 NAME | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | App::LDAP::Role::Bindable - make a command itself bindable to a LDAP server | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | =head1 SYNOPSIS | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | package App::LDAP::Command::YourCommand; | ||||||||||||||||||||
| 47 | use Moose; | ||||||||||||||||||||
| 48 | with qw( App::LDAP::Role::Command | ||||||||||||||||||||
| 49 | App::LDAP::Role::Bindable ); | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | package main; | ||||||||||||||||||||
| 52 | App::LDAP::Command::YourCommand->new_with_options()->prepare()->run(); | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =head1 DESCRIPTION | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | This role hook the prepare() method to bind the handler through $UID to the LDAP server before running. | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =cut | ||||||||||||||||||||