line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nitesi::Account::Password; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
23949
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
77
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
73
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
3682
|
use Crypt::Password 0.23 (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Data::SimplePassword; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Moo; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Nitesi::Account::Password - Password class for Nitesi Shop Machine |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Allows to create random passwords, password hashes from cleartext |
18
|
|
|
|
|
|
|
passwords and password checks. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 check |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Checks password retrieved from user against the password hash. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$crypt->check($hash_from_database, $user_input); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub check { |
31
|
|
|
|
|
|
|
my ($self, $hash, $password) = @_; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Crypt::Password::check_password($hash, $password); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 password |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Creates password hash from plain text password. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$crypt->password('nevairbe'); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Use specific algorithm (default is sha512): |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$crypt->password('nevairbe', 'md5'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub password { |
49
|
|
|
|
|
|
|
my ($self, $password, $algorithm, $salt); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self = shift; |
52
|
|
|
|
|
|
|
$password = shift; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
if (@_) { |
55
|
|
|
|
|
|
|
# got algorithm |
56
|
|
|
|
|
|
|
$algorithm = shift; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
|
|
|
|
|
|
$algorithm = 'sha512'; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$password = Crypt::Password::password($password, undef, $algorithm); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return $password; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 make_password |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Creates random password. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
B |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$crypt->make_password(); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub make_password { |
79
|
|
|
|
|
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$self->{generator} ||= Data::SimplePassword->new; |
82
|
|
|
|
|
|
|
$self->{generator}->make_password; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Stefan Hornburg (Racke), |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Copyright 2011-2013 Stefan Hornburg (Racke) . |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
94
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
95
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |