line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::CryptColumn; |
2
|
|
|
|
|
|
|
$DBIx::Class::CryptColumn::VERSION = '0.005'; |
3
|
1
|
|
|
1
|
|
219494
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
71
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use Sub::Util 1.40 'set_subname'; |
|
1
|
|
|
|
|
30
|
|
|
1
|
|
|
|
|
56
|
|
7
|
1
|
|
|
1
|
|
6
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
224
|
use parent 'DBIx::Class'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->load_components(qw(InflateColumn::Crypt::Passphrase)); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
1
|
|
|
1
|
1
|
119227
|
my ($self, $attr, @rest) = @_; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
3
|
for my $col (grep { !/^-/ } keys %{ $attr }) { |
|
2
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
4
|
|
17
|
1
|
50
|
|
|
|
67
|
next unless my $inflate = $self->column_info($col)->{inflate_passphrase}; |
18
|
1
|
|
|
|
|
85
|
$attr->{$col} = $inflate->hash_password($attr->{$col}); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
152
|
return $self->next::method($attr, @rest); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _export_sub { |
25
|
2
|
|
|
2
|
|
7
|
my ($self, $name, $sub) = @_; |
26
|
2
|
|
|
|
|
62
|
my $full_name = $self->result_class . "::$name"; |
27
|
1
|
|
|
1
|
|
256
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
348
|
|
28
|
2
|
|
|
|
|
786
|
*$full_name = set_subname $full_name => $sub; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub register_column { |
32
|
2
|
|
|
2
|
1
|
1929
|
my ($self, $column, $info, @rest) = @_; |
33
|
|
|
|
|
|
|
|
34
|
2
|
100
|
|
|
|
8
|
if (my $args = $info->{inflate_passphrase}) { |
35
|
1
|
50
|
|
|
|
4
|
$self->throw_exception(q['inflate_passphrase' must be a hash reference]) unless ref $args eq 'HASH'; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
2
|
my $crypt_passphrase = Crypt::Passphrase->new(%{$args}); |
|
1
|
|
|
|
|
5
|
|
38
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
8019
|
if (defined(my $name = $args->{verify_method})) { |
40
|
|
|
|
|
|
|
$self->_export_sub($name, sub { |
41
|
6
|
|
|
6
|
|
9787
|
my ($row, $password) = @_; |
|
|
|
|
6
|
|
|
|
42
|
6
|
|
|
|
|
22
|
return $crypt_passphrase->verify_password($password, $row->get_column($column)); |
43
|
1
|
|
|
|
|
13
|
}); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
1
|
50
|
|
|
|
6
|
if (defined(my $name = $args->{rehash_method})) { |
47
|
|
|
|
|
|
|
$self->_export_sub($name, sub { |
48
|
2
|
|
|
2
|
|
1674
|
my $row = shift; |
|
|
|
|
2
|
|
|
|
49
|
2
|
|
|
|
|
8
|
return $crypt_passphrase->needs_rehash($row->get_column($column)); |
50
|
1
|
|
|
|
|
8
|
}); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
3
|
$info->{inflate_passphrase} = $crypt_passphrase; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
9
|
$self->next::method($column, $info, @rest); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub set_column { |
60
|
1
|
|
|
1
|
1
|
2170
|
my ($self, $col, $val, @rest) = @_; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
28
|
my $inflate = $self->column_info($col)->{inflate_passphrase}; |
63
|
1
|
50
|
|
|
|
81
|
$val = $inflate->hash_password($val) if $inflate; |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
81
|
return $self->next::method($col, $val, @rest); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# ABSTRACT: Automatically hash password/passphrase columns |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |