validate persist_in_session on store creation
Alexander Hartmaier [Tue, 24 Nov 2015 14:53:17 +0000 (15:53 +0100)]
to prevent typos from changing expected behaviour

lib/Catalyst/Authentication/Store/LDAP/Backend.pm

index 90b170e..605561d 100644 (file)
@@ -127,6 +127,8 @@ sub new {
         ||= 'Catalyst::Authentication::Store::LDAP::User';
     $config_hash{'role_search_as_user'} ||= 0;
     $config_hash{'persist_in_session'}  ||= 'username';
+    Catalyst::Exception->throw('persist_in_session must be either username or all')
+        unless $config_hash{'persist_in_session'} =~ /\A(?:username|all)\z/;
 
     Catalyst::Utils::ensure_class_loaded( $config_hash{'user_class'} );
     my $self = \%config_hash;