| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- perl -*- |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Authen::PAAS::LoginModule by Daniel Berrange |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Copyright (C) 2004-2006 Dan Berrange |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
8
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
9
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
10
|
|
|
|
|
|
|
# (at your option) any later version. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
18
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
|
19
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20
|
|
|
|
|
|
|
# |
|
21
|
|
|
|
|
|
|
# $Id: LoginModule.pm,v 1.1 2005/08/21 07:39:37 dan Exp $ |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=pod |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Authen::PAAS::LoginModule - a pluggable authentication module |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Authen::PAAS::LoginModule; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $result = $module->login($subject, \%callbacks); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This module provides the API for authenticating a subject |
|
38
|
|
|
|
|
|
|
for the purposes of session login. It will be subclassed |
|
39
|
|
|
|
|
|
|
to provide the implementations of different authentication |
|
40
|
|
|
|
|
|
|
schemes. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 METHODS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over 4 |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
package Authen::PAAS::LoginModule; |
|
49
|
|
|
|
|
|
|
|
|
50
|
2
|
|
|
2
|
|
4577
|
use warnings; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
66
|
|
|
51
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
685
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
our $VERSION = '1.0.0'; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item my $module = Authen::PAAS::LoginModule->new(flags => $flags, options => \%options); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Creates a new login modules. The C parameter should be one of the |
|
59
|
|
|
|
|
|
|
keywords C, C, C and C. The |
|
60
|
|
|
|
|
|
|
C parameter is a hash reference containing sub-class specific |
|
61
|
|
|
|
|
|
|
configuration options. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub new { |
|
66
|
15
|
|
|
15
|
1
|
129
|
my $proto = shift; |
|
67
|
15
|
|
33
|
|
|
77
|
my $class = ref($proto) || $proto; |
|
68
|
15
|
|
|
|
|
32
|
my $self = {}; |
|
69
|
15
|
|
|
|
|
52
|
my %params = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
15
|
50
|
|
|
|
63
|
$self->{flags} = exists $params{flags} ? $params{flags} : die "flags parameter is required"; |
|
72
|
15
|
50
|
|
|
|
46
|
$self->{options} = exists $params{options} ? $params{options} : {}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
15
|
|
|
|
|
35
|
bless $self, $class; |
|
75
|
|
|
|
|
|
|
|
|
76
|
15
|
|
|
|
|
51
|
return $self; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item $module->option($name, $default); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Retrieves the value of the configuration option identified by |
|
83
|
|
|
|
|
|
|
the C<$name> parameter. If the named configuration option is |
|
84
|
|
|
|
|
|
|
not set, then the C<$default> value is returned. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub option { |
|
89
|
26
|
|
|
26
|
1
|
13916
|
my $self = shift; |
|
90
|
26
|
|
|
|
|
34
|
my $name = shift; |
|
91
|
26
|
50
|
|
|
|
203
|
return exists $self->{options}->{$name} ? $self->{options}->{$name} : shift; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item my $flags = $module->flags; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Retrieves the flags for the module, one of the keywords C, |
|
98
|
|
|
|
|
|
|
C, C and C. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub flags { |
|
103
|
27
|
|
|
27
|
1
|
38
|
my $self = shift; |
|
104
|
27
|
|
|
|
|
324
|
return $self->{flags}; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item my $res = $module->login($subject, $callbacks); |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Attempt to login using authentication data obtained |
|
111
|
|
|
|
|
|
|
from the callbacks, if successful, adding principals |
|
112
|
|
|
|
|
|
|
and credentials to the subject. The C<$callbacks> |
|
113
|
|
|
|
|
|
|
parameter is a hash reference, whose keys are the |
|
114
|
|
|
|
|
|
|
names of authentication tokes, and values are instances |
|
115
|
|
|
|
|
|
|
of th L class. If successful, |
|
116
|
|
|
|
|
|
|
this method must return a true value, otherwise a false |
|
117
|
|
|
|
|
|
|
value. This method must be implemented by subclasses. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub login { |
|
122
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
123
|
0
|
|
|
|
|
|
die "module " . ref($self) . " forgot to implement login"; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item $module->logout($subject); |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Attempt to logout a subject, by removing any principals |
|
130
|
|
|
|
|
|
|
anc credentials added during the C method. |
|
131
|
|
|
|
|
|
|
This method must be implemented by subclasses. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub logout { |
|
137
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
138
|
0
|
|
|
|
|
|
die "module " . ref($self) . " forgot to implement logout"; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1 # So that the require or use succeeds. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__END__ |