line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Helper::Model::LDAP; |
2
|
|
|
|
|
|
|
# ABSTRACT: Helper for LDAP models |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1020
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
159
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub mk_compclass { |
9
|
0
|
|
|
0
|
1
|
|
my ( $self, $helper, $host, $base, $dn, $password, $start_tls ) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
0
|
|
|
|
$helper->{host} = $host || ''; |
12
|
0
|
|
0
|
|
|
|
$helper->{base} = $base || ''; |
13
|
0
|
|
0
|
|
|
|
$helper->{dn} = $dn || ''; |
14
|
0
|
|
0
|
|
|
|
$helper->{password} = $password || ''; |
15
|
0
|
0
|
|
|
|
|
$helper->{start_tls} = $start_tls ? 1 : 0; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
$helper->render_file( 'modelclass', $helper->{file} ); |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
return 1; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub mk_comptest { |
24
|
0
|
|
|
0
|
1
|
|
my ( $self, $helper ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$helper->render_file( 'modeltest', $helper->{test} ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding UTF-8 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Catalyst::Helper::Model::LDAP - Helper for LDAP models |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 VERSION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
version 0.19 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
script/myapp_create.pl model Person LDAP ldap.ufl.edu ou=People,dc=ufl,dc=edu dn=admin,dc=ufl,dc=edu mypass 1 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Helper for the L<Catalyst> LDAP model. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 USAGE |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
When creating a new LDAP model class using this helper, you can |
55
|
|
|
|
|
|
|
specify much of the configuration and have it filled automatically. |
56
|
|
|
|
|
|
|
Using the example from the L</SYNOPSIS> section: |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=over |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item * C<Person> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The name of the model. This is also used to determine the filename, |
63
|
|
|
|
|
|
|
e.g. C<lib/MyApp/Model/Person.pm>. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item * C<LDAP> |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The helper to use, i.e. this one. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * C<ldap.ufl.edu> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The LDAP server's fully qualified domain name (FQDN). Can also be an |
72
|
|
|
|
|
|
|
IP address, e.g. C<127.0.0.1>. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * C<ou=People,dc=ufl,dc=edu> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The base distinguished name (DN) for searching the directory. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * C<dn=admin,dc=ufl,dc=edu> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The bind DN for connecting to the directory. This can be anyone that |
81
|
|
|
|
|
|
|
has permission to search under the base DN, as per your LDAP server's |
82
|
|
|
|
|
|
|
access control lists. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * C<mypass> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The password for the specified bind DN. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * C<1> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Optionally uses TLS when binding to the LDAP server, for secure |
91
|
|
|
|
|
|
|
connections. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=back |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 mk_compclass |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Makes the LDAP model class. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 mk_comptest |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Makes tests for the LDAP model. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=over 4 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * L<Catalyst::Manual> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * L<Catalyst::Test> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * L<Catalyst::Helper> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHORS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * Daniel Westermann-Clark E<lt>danieltwc@cpan.orgE<gt> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * Gavin Henry E<lt>ghenry@cpan.orgE<gt> (TLS Helper option and documentation) |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
130
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Gavin Henry <ghenry@surevoip.co.uk> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gavin Henry. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
141
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__DATA__ |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=begin pod_to_ignore |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__modelclass__ |
150
|
|
|
|
|
|
|
package [% class %]; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
use strict; |
153
|
|
|
|
|
|
|
use warnings; |
154
|
|
|
|
|
|
|
use base qw/Catalyst::Model::LDAP/; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
__PACKAGE__->config( |
157
|
|
|
|
|
|
|
host => '[% host %]', |
158
|
|
|
|
|
|
|
base => '[% base %]', |
159
|
|
|
|
|
|
|
dn => '[% dn %]', |
160
|
|
|
|
|
|
|
password => '[% password %]', |
161
|
|
|
|
|
|
|
start_tls => [% start_tls %], |
162
|
|
|
|
|
|
|
start_tls_options => { verify => 'require' }, |
163
|
|
|
|
|
|
|
options => {}, # Options passed to search |
164
|
|
|
|
|
|
|
); |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 NAME |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
[% class %] - LDAP Catalyst model component |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 SYNOPSIS |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
See L<[% app %]>. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 DESCRIPTION |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
LDAP Catalyst model component. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 AUTHOR |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
[% author %] |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 LICENSE |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
185
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
1; |
190
|
|
|
|
|
|
|
__modeltest__ |
191
|
|
|
|
|
|
|
use strict; |
192
|
|
|
|
|
|
|
use warnings; |
193
|
|
|
|
|
|
|
use Test::More tests => 2; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
use_ok('Catalyst::Test', '[% app %]'); |
196
|
|
|
|
|
|
|
use_ok('[% class %]'); |