[Catalyst-commits] r6629 - in
trunk/Catalyst-Plugin-Authentication-Store-LDAP: .
lib/Catalyst/Plugin/Authentication/Store
lib/Catalyst/Plugin/Authentication/Store/LDAP t t/lib
omega at dev.catalyst.perl.org
omega at dev.catalyst.perl.org
Thu Aug 9 08:53:21 GMT 2007
Author: omega
Date: 2007-08-09 08:53:20 +0100 (Thu, 09 Aug 2007)
New Revision: 6629
Added:
trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/entry_class.t
trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/lib/
trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/lib/EntryClass.pm
Modified:
trunk/Catalyst-Plugin-Authentication-Store-LDAP/
trunk/Catalyst-Plugin-Authentication-Store-LDAP/Changes
trunk/Catalyst-Plugin-Authentication-Store-LDAP/MANIFEST
trunk/Catalyst-Plugin-Authentication-Store-LDAP/MANIFEST.SKIP
trunk/Catalyst-Plugin-Authentication-Store-LDAP/lib/Catalyst/Plugin/Authentication/Store/LDAP.pm
trunk/Catalyst-Plugin-Authentication-Store-LDAP/lib/Catalyst/Plugin/Authentication/Store/LDAP/Backend.pm
Log:
r15920 at andreas-marienborgs-computer: andreas | 2007-08-09 09:16:49 +0200
Added entry_class support for the user entries
Property changes on: trunk/Catalyst-Plugin-Authentication-Store-LDAP
___________________________________________________________________
Name: svn:ignore
+ MANIFEST.bak
Makefile
pm_to_blib
blib
Name: svk:merge
+ ea49d7f7-7c45-40ca-be27-1349e20c1c07:/local/c-p-a-store-ldap:15920
Modified: trunk/Catalyst-Plugin-Authentication-Store-LDAP/Changes
===================================================================
--- trunk/Catalyst-Plugin-Authentication-Store-LDAP/Changes 2007-08-08 19:46:21 UTC (rev 6628)
+++ trunk/Catalyst-Plugin-Authentication-Store-LDAP/Changes 2007-08-09 07:53:20 UTC (rev 6629)
@@ -1,3 +1,9 @@
+0.06 omega Thu Aug 09 09:00:00 CET 2007
+ - Added support for entry_class in the same way that Catalyst::Model::LDAP
+ supports it, allowing one to override what class is returned from
+ $c->user->ldap_entry, and thus allowing one to add methods to the user
+ object
+
0.05
- Added support for multiple identifiers.
Modified: trunk/Catalyst-Plugin-Authentication-Store-LDAP/MANIFEST
===================================================================
--- trunk/Catalyst-Plugin-Authentication-Store-LDAP/MANIFEST 2007-08-08 19:46:21 UTC (rev 6628)
+++ trunk/Catalyst-Plugin-Authentication-Store-LDAP/MANIFEST 2007-08-09 07:53:20 UTC (rev 6629)
@@ -16,5 +16,7 @@
Makefile.PL
MANIFEST This list of files
META.yml
+t/entry_class.t
+t/lib/EntryClass.pm
t/simple.t
TODO
Modified: trunk/Catalyst-Plugin-Authentication-Store-LDAP/MANIFEST.SKIP
===================================================================
--- trunk/Catalyst-Plugin-Authentication-Store-LDAP/MANIFEST.SKIP 2007-08-08 19:46:21 UTC (rev 6628)
+++ trunk/Catalyst-Plugin-Authentication-Store-LDAP/MANIFEST.SKIP 2007-08-09 07:53:20 UTC (rev 6629)
@@ -3,3 +3,4 @@
^blib/
^.*\.swp$
^MANIFEST\.
+^pm_to_blib$
\ No newline at end of file
Modified: trunk/Catalyst-Plugin-Authentication-Store-LDAP/lib/Catalyst/Plugin/Authentication/Store/LDAP/Backend.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication-Store-LDAP/lib/Catalyst/Plugin/Authentication/Store/LDAP/Backend.pm 2007-08-08 19:46:21 UTC (rev 6628)
+++ trunk/Catalyst-Plugin-Authentication-Store-LDAP/lib/Catalyst/Plugin/Authentication/Store/LDAP/Backend.pm 2007-08-09 07:53:20 UTC (rev 6629)
@@ -35,6 +35,7 @@
'user_search_options' => {
'deref' => 'always',
},
+ 'entry_class' => 'MyApp::LDAP::Entry',
'use_roles' => 1,
'role_basedn' => 'ou=groups,dc=yourcompany,dc=com',
'role_filter' => '(&(objectClass=posixGroup)(member=%s))',
@@ -80,7 +81,7 @@
BEGIN {
__PACKAGE__->mk_accessors(
- qw/ldap_server ldap_server_options binddn bindpw user_search_options user_filter user_basedn user_scope user_attrs user_field use_roles role_basedn role_filter role_scope role_field role_value role_search_options start_tls start_tls_options/
+ qw/ldap_server ldap_server_options binddn bindpw entry_class user_search_options user_filter user_basedn user_scope user_attrs user_field use_roles role_basedn role_filter role_scope role_field role_value role_search_options start_tls start_tls_options/
);
}
@@ -110,6 +111,8 @@
$config_hash{'role_field'} ||= 'cn';
$config_hash{'use_roles'} ||= '1';
$config_hash{'start_tls'} ||= '0';
+ $config_hash{'entry_class'} ||= 'Catalyst::Model::LDAP::Entry';
+
my $self = \%config_hash;
bless($self, $class);
return $self;
@@ -276,9 +279,12 @@
$attrhash->{ lc($attr) } = \@attrvalues;
}
}
- eval {require Catalyst::Model::LDAP::Entry;};
+ my $load_class = $self->entry_class . ".pm";
+ $load_class =~ s|::|/|g;
+
+ eval { require $load_class };
if(!$@) {
- bless($userentry,'Catalyst::Model::LDAP::Entry');
+ bless($userentry,$self->entry_class);
$userentry->{_use_unicode}++;
}
my $rv = {
Modified: trunk/Catalyst-Plugin-Authentication-Store-LDAP/lib/Catalyst/Plugin/Authentication/Store/LDAP.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication-Store-LDAP/lib/Catalyst/Plugin/Authentication/Store/LDAP.pm 2007-08-08 19:46:21 UTC (rev 6628)
+++ trunk/Catalyst-Plugin-Authentication-Store-LDAP/lib/Catalyst/Plugin/Authentication/Store/LDAP.pm 2007-08-09 07:53:20 UTC (rev 6629)
@@ -5,7 +5,7 @@
use strict;
use warnings;
-our $VERSION = '0.05';
+our $VERSION = '0.06';
use Catalyst::Plugin::Authentication::Store::LDAP::Backend;
Added: trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/entry_class.t
===================================================================
--- trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/entry_class.t (rev 0)
+++ trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/entry_class.t 2007-08-09 07:53:20 UTC (rev 6629)
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Catalyst::Exception;
+
+use Test::More tests => 6;
+use lib 't/lib';
+
+BEGIN { use_ok("Catalyst::Plugin::Authentication::Store::LDAP::Backend") }
+
+my $back = Catalyst::Plugin::Authentication::Store::LDAP::Backend->new({
+ 'ldap_server' => 'ldap.openldap.org',
+ 'binddn' => 'anonymous',
+ 'bindpw' => 'dontcarehow',
+ 'start_tls' => 0,
+ 'user_basedn' => 'ou=People,dc=OpenLDAP,dc=Org',
+ 'user_filter' => '(&(objectClass=person)(uid=%s))',
+ 'user_scope' => 'one',
+ 'user_field' => 'uid',
+ 'use_roles' => 0,
+ 'entry_class' => 'EntryClass',
+ });
+isa_ok($back, "Catalyst::Plugin::Authentication::Store::LDAP::Backend");
+my $user = $back->get_user('kurt');
+isa_ok($user, "Catalyst::Plugin::Authentication::Store::LDAP::User");
+my $displayname = $user->displayname;
+cmp_ok($displayname, 'eq', 'Kurt Zeilenga', 'Should be Kurt Zeilenga');
+
+isa_ok($user->ldap_entry, "EntryClass", "entry_class works");
+is($user->ldap_entry->my_method, 1001, "methods on entry_class works");
Added: trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/lib/EntryClass.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/lib/EntryClass.pm (rev 0)
+++ trunk/Catalyst-Plugin-Authentication-Store-LDAP/t/lib/EntryClass.pm 2007-08-09 07:53:20 UTC (rev 6629)
@@ -0,0 +1,8 @@
+package EntryClass;
+
+use base qw/Catalyst::Model::LDAP::Entry/;
+
+sub my_method {
+ return 1001;
+}
+1;
\ No newline at end of file
More information about the Catalyst-commits
mailing list