[Catalyst-commits] r12302 - in Catalyst-Authentication-Store-LDAP/trunk: . lib/Catalyst/Authentication/Store/LDAP

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Thu Dec 10 17:25:49 GMT 2009


Author: t0m
Date: 2009-12-10 17:25:49 +0000 (Thu, 10 Dec 2009)
New Revision: 12302

Modified:
   Catalyst-Authentication-Store-LDAP/trunk/
   Catalyst-Authentication-Store-LDAP/trunk/lib/Catalyst/Authentication/Store/LDAP/User.pm
Log:
 r27890 at omni (orig r10888):  t0m | 2009-07-15 11:16:11 +0100
 Brush up this patch to something more sensible and documented



Property changes on: Catalyst-Authentication-Store-LDAP/trunk
___________________________________________________________________
Name: svk:merge
   - 4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Authentication-Store-LDAP/branches/better_model_integration:10887
   + 4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Authentication-Store-LDAP/branches/better_model_integration:10888

Modified: Catalyst-Authentication-Store-LDAP/trunk/lib/Catalyst/Authentication/Store/LDAP/User.pm
===================================================================
--- Catalyst-Authentication-Store-LDAP/trunk/lib/Catalyst/Authentication/Store/LDAP/User.pm	2009-12-10 17:25:47 UTC (rev 12301)
+++ Catalyst-Authentication-Store-LDAP/trunk/lib/Catalyst/Authentication/Store/LDAP/User.pm	2009-12-10 17:25:49 UTC (rev 12302)
@@ -51,7 +51,7 @@
 
 our $VERSION = '0.1005';
 
-BEGIN { __PACKAGE__->mk_accessors(qw/user store _ldap_connection/) }
+BEGIN { __PACKAGE__->mk_accessors(qw/user store _ldap_connection_password/) }
 
 use overload '""' => sub { shift->stringify }, fallback => 1;
 
@@ -147,9 +147,9 @@
             $self->roles($ldap);
         }
         # Stash a closure which can be used to retrieve the connection in the users context later.
-        $self->_ldap_connection( sub {
-            $self->store->ldap_bind( undef, $self->ldap_entry->dn, $password )
-        });
+        $self->_ldap_connection_password( sub { $password } ); # Close over
+            # password to try to ensure it doesn't come out in debug dumps
+            # or get serialized into sessions etc..
         return 1;
     }
     else {
@@ -234,6 +234,22 @@
     }
 }
 
+=head2 ldap_connection
+
+Re-binds to the auth store with the credentials of the user you logged in
+as, and returns a L<Net::LDAP> object which you can use to do further queries.
+
+=cut
+
+sub ldap_connection {
+    my $self = shift;
+    my $msg = $self->store->ldap_bind( undef, $self->ldap_entry->dn,
+        $self->_ldap_connection_password->() );
+    $msg->code && die("Error whilst re-binding as " . $self->ldap_entry->dn
+        . " after auth: " . $msg->error . " (" . $msg->code . ")");
+    return $self->store;
+}
+
 =head2 AUTOLOADed methods
 
 We automatically map the attributes of the underlying L<Net::LDAP::Entry>




More information about the Catalyst-commits mailing list