| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# vim: set ts=3 sw=3 tw=0: |
|
5
|
|
|
|
|
|
|
# vim: set expandtab: |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Rex::JobControl::Mojolicious::Plugin::User; |
|
8
|
|
|
|
|
|
|
$Rex::JobControl::Mojolicious::Plugin::User::VERSION = '0.7.0'; |
|
9
|
1
|
|
|
1
|
|
1559
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
27
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
7
|
use Mojolicious::Plugin; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
7
|
|
|
13
|
1
|
|
|
1
|
|
25
|
use Rex::JobControl::Helper::Project; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
23
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use Digest::Bcrypt; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
6
|
use base 'Mojolicious::Plugin'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
678
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub register { |
|
19
|
1
|
|
|
1
|
1
|
44
|
my ( $plugin, $app ) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$app->helper( |
|
22
|
|
|
|
|
|
|
get_user => sub { |
|
23
|
0
|
|
|
0
|
|
0
|
my ( $self, $uid ) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my @lines = |
|
26
|
0
|
|
|
|
|
0
|
eval { local (@ARGV) = ( $self->app->config->{auth}->{passwd} ); <>; }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
27
|
0
|
|
|
|
|
0
|
chomp @lines; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
for my $l (@lines) { |
|
30
|
0
|
|
|
|
|
0
|
my ( $name, $pass ) = split( /:/, $l ); |
|
31
|
0
|
0
|
|
|
|
0
|
if ( $name eq $uid ) { |
|
32
|
0
|
|
|
|
|
0
|
return { name => $name, password => $pass }; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
return undef; |
|
37
|
|
|
|
|
|
|
}, |
|
38
|
1
|
|
|
|
|
11
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$app->helper( |
|
41
|
|
|
|
|
|
|
check_password => sub { |
|
42
|
0
|
|
|
0
|
|
|
my ( $self, $uid, $pass ) = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $user = $app->get_user($uid); |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $salt = $app->config->{auth}->{salt}; |
|
47
|
0
|
|
|
|
|
|
my $cost = $app->config->{auth}->{cost}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $bcrypt = Digest::Bcrypt->new; |
|
50
|
0
|
|
|
|
|
|
$bcrypt->salt($salt); |
|
51
|
0
|
|
|
|
|
|
$bcrypt->cost($cost); |
|
52
|
0
|
|
|
|
|
|
$bcrypt->add($pass); |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $pw = $bcrypt->hexdigest; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
0
|
0
|
|
|
|
if ( $user && $user->{password} eq $pw ) { |
|
57
|
0
|
|
|
|
|
|
return $user->{name}; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return undef; |
|
61
|
|
|
|
|
|
|
}, |
|
62
|
1
|
|
|
|
|
106
|
); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |