Changeset 2071


Ignore:
Timestamp:
08/25/17 08:21:05 (7 years ago)
Author:
nanardon
Message:

Allow to use a specific cracklib dictionnary

Location:
trunk/LATMOS-Accounts
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/Changes

    r2062 r2071  
     15.2.19 
     2    - Allow to use a specific cracklib dictionnary  
     3 
    145.2.16 
    25    - Allow to choose crypt() algorythm using crypt_method setting in 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm

    r2041 r2071  
    561561sub check_password { 
    562562    my ( $self, $password ) = @_; 
    563     my $dictionary; 
     563    my $dictionary = $self->base->config('cracklib_dictionnary') 
    564564 
    565565    if ($password !~ /^[[:ascii:]]*$/) { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Utils.pm

    r2047 r2071  
    324324Use a set of syllables instead letter 
    325325 
     326=item checkpassword 
     327 
     328A sub reference to check if generated password is valid 
     329 
    326330=back 
    327331 
     
    330334sub genpassword { 
    331335    my (%options) = @_; 
     336 
     337    $options{checkpassword} ||= sub { 
     338        my ($cpass) = @_; 
     339        return fascist_check($pass) eq 'ok'; 
     340    }; 
     341 
    332342    my @non_alpha = (qw$; : / ! ( ) [ ] { } + = @ - " ' % * & . ? < >$, ',', '$'); 
    333343    my @letters = ('a' .. 'z', 'A' .. 'Z', 0 .. 9); 
     
    366376 
    367377        my $pass = join('', sort { rand() <=> rand() } @chars); 
    368         if (length($pass) >= 6 && fascist_check($pass) eq 'ok') { 
     378        if (length($pass) >= 6 && $options{checkpassword}->($pass)) { 
    369379            return $pass; 
    370380        } 
  • trunk/LATMOS-Accounts/man/man5/latmos-accounts.ini.pod

    r2041 r2071  
    5757 
    5858Can be specified per base. 
     59 
     60=head3 cracklib_dictionnary 
     61 
     62The path to a specific dictionnary formated for cracklib library 
    5963 
    6064=head2 [_defattr_] SECTION 
  • trunk/LATMOS-Accounts/t/05_utils.t

    r2041 r2071  
    11use strict; 
    22use warnings; 
    3 use Test::More tests => 44; 
     3use Test::More tests => 46; 
    44use File::Temp qw(mkstemp); 
    55 
     
    7777is(LATMOS::Accounts::Utils::buildLogin(sub { length($_[0]) > 9 }, 'TotoTataTiti'), 'tototatati', "buildLogin return 8 byte length login"); 
    7878 
     79ok(LATMOS::Accounts::Utils::genpassword(), "can generate a password"); 
     80ok(LATMOS::Accounts::Utils::genpassword( 
     81        checkpassword => sub { 1 }, 
     82    ), "can generate a password"); 
     83 
    7984my $clearpass = 'passwd'; 
    8085my $password = ''; 
Note: See TracChangeset for help on using the changeset viewer.