| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package DBIx::Class::InflateColumn::Authen::Passphrase; # git description: v0.02-2-gdc402d1 | ||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Inflate/deflate columns to Authen::Passphrase instances | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Authen::Passphrase; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use parent 'DBIx::Class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | #pod =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 13 | #pod | ||||||||||||||||||||||||||||
| 14 | #pod __PACKAGE__->load_components(qw(InflateColumn::Authen::Passphrase)); | ||||||||||||||||||||||||||||
| 15 | #pod | ||||||||||||||||||||||||||||
| 16 | #pod __PACKAGE__->add_columns( | ||||||||||||||||||||||||||||
| 17 | #pod id => { | ||||||||||||||||||||||||||||
| 18 | #pod data_type => 'integer', | ||||||||||||||||||||||||||||
| 19 | #pod is_auto_increment => 1, | ||||||||||||||||||||||||||||
| 20 | #pod }, | ||||||||||||||||||||||||||||
| 21 | #pod passphrase_rfc2307 => { | ||||||||||||||||||||||||||||
| 22 | #pod data_type => 'text', | ||||||||||||||||||||||||||||
| 23 | #pod inflate_passphrase => 'rfc2307', | ||||||||||||||||||||||||||||
| 24 | #pod }, | ||||||||||||||||||||||||||||
| 25 | #pod passphrase_crypt => { | ||||||||||||||||||||||||||||
| 26 | #pod data_type => 'text', | ||||||||||||||||||||||||||||
| 27 | #pod inflate_passphrase => 'crypt', | ||||||||||||||||||||||||||||
| 28 | #pod }, | ||||||||||||||||||||||||||||
| 29 | #pod ); | ||||||||||||||||||||||||||||
| 30 | #pod | ||||||||||||||||||||||||||||
| 31 | #pod __PACKAGE__->set_primary_key('id'); | ||||||||||||||||||||||||||||
| 32 | #pod | ||||||||||||||||||||||||||||
| 33 | #pod | ||||||||||||||||||||||||||||
| 34 | #pod # in application code | ||||||||||||||||||||||||||||
| 35 | #pod $rs->create({ passphrase_rfc2307 => Authen::Passphrase::RejectAll->new }); | ||||||||||||||||||||||||||||
| 36 | #pod | ||||||||||||||||||||||||||||
| 37 | #pod my $row = $rs->find({ id => $id }); | ||||||||||||||||||||||||||||
| 38 | #pod if ($row->passphrase_rfc2307->match($input)) { ... | ||||||||||||||||||||||||||||
| 39 | #pod | ||||||||||||||||||||||||||||
| 40 | #pod =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 41 | #pod | ||||||||||||||||||||||||||||
| 42 | #pod Provides inflation and deflation for Authen::Passphrase instances from and to | ||||||||||||||||||||||||||||
| 43 | #pod either RFC 2307 or crypt encoding. | ||||||||||||||||||||||||||||
| 44 | #pod | ||||||||||||||||||||||||||||
| 45 | #pod To enable both inflating and deflating, C<inflate_passphrase> must be set to a | ||||||||||||||||||||||||||||
| 46 | #pod valid passphrase encoding. Currently the only supported encodings are C<rfc2307> | ||||||||||||||||||||||||||||
| 47 | #pod and C<crypt>. The specified encoding will be used both when storing | ||||||||||||||||||||||||||||
| 48 | #pod C<Authen::Passphrase> instances in columns, and when creating | ||||||||||||||||||||||||||||
| 49 | #pod C<Authen::Passphrase> instances from columns. See L<Authen::Passphrase> for | ||||||||||||||||||||||||||||
| 50 | #pod details on passphrase encodings. | ||||||||||||||||||||||||||||
| 51 | #pod | ||||||||||||||||||||||||||||
| 52 | #pod Note that not all passphrase schemes supported by C<Authen::Passphrase> can be | ||||||||||||||||||||||||||||
| 53 | #pod represented in either RFC 2307 or crypt encoding. Chose the kind of passphrase | ||||||||||||||||||||||||||||
| 54 | #pod encoding you're using based on the encoding supported by the passphrase algorithms | ||||||||||||||||||||||||||||
| 55 | #pod you're using. | ||||||||||||||||||||||||||||
| 56 | #pod | ||||||||||||||||||||||||||||
| 57 | #pod When trying to encode a passphrase instance with an encoding that doesn't | ||||||||||||||||||||||||||||
| 58 | #pod support it, an exception will be thrown. Similarly, when trying to load a | ||||||||||||||||||||||||||||
| 59 | #pod passphrase instance from a faulty or unknown encoded representation, an | ||||||||||||||||||||||||||||
| 60 | #pod exception will be thrown. | ||||||||||||||||||||||||||||
| 61 | #pod | ||||||||||||||||||||||||||||
| 62 | #pod =method register_column | ||||||||||||||||||||||||||||
| 63 | #pod | ||||||||||||||||||||||||||||
| 64 | #pod Chains with the C<register_column> method in C<DBIx::Class::Row>, and sets up | ||||||||||||||||||||||||||||
| 65 | #pod passphrase columns appropriately. This would not normally be directly called by | ||||||||||||||||||||||||||||
| 66 | #pod end users. | ||||||||||||||||||||||||||||
| 67 | #pod | ||||||||||||||||||||||||||||
| 68 | #pod =cut | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 3 | ▶ | sub register_column { | ||||||||||||||||||||||||||
|
Subroutine
register_column: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 3 | my ($self, $column, $info, @rest) = @_; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 3 | $self->next::method($column, $info, @rest); | |||||||||||||||||||||||||||
| 74 | 3 | ▶ | return unless my $encoding = $info->{inflate_passphrase}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 2 | ▶ | $self->throw_exception(q['rfc2307' and 'crypt' are the only supported types of passphrase columns]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$encoding eq "rfc2307" or $encoding eq "crypt"
MC/DC0%0/2
$encoding eq "rfc2307" or $encoding eq "crypt"
$encoding eq "rfc2307"
$encoding eq "crypt"
Truth table66%2/3
A or B
A= $encoding eq "rfc2307"B= $encoding eq "crypt"
| |||||||||||||||||||||||||||||
| 77 | unless $encoding eq 'rfc2307' || $encoding eq 'crypt'; | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | $self->inflate_column( | ||||||||||||||||||||||||||||
| 80 | $column => { | ||||||||||||||||||||||||||||
| 81 | 2 | ▶ | inflate => sub { Authen::Passphrase->${\"from_${encoding}"}(shift) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 82 | 2 | ▶ | deflate => sub { shift->${\"as_${encoding}"} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||
| 84 | 2 | ); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 1 | 1; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | __END__ | ||||||||||||||||||||||||||||