Ignore:
Timestamp:
01/17/17 17:38:36 (7 years ago)
Author:
nanardon
Message:

Add a way to inject UNIX password into base supporting it

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ldap/User.pm

    r1865 r1935  
    101101        }, 
    102102        homeDirectory => { }, 
    103         userPassword => { }, 
    104103        loginShell => { }, 
    105104        gecos => { }, 
     
    298297} 
    299298 
     299=head2 _InjectCryptPasswd($cryptpasswd) 
     300 
     301Inject a password encrypted using standard UNIX method. 
     302 
     303Works only for unix authentification method inside LDAP 
     304 
     305=cut 
     306 
     307sub _InjectCryptPasswd { 
     308    my ($self, $cryptpasswd) = @_; 
     309 
     310    my $res = $self->set_fields( 
     311        userPassword => '{CRYPT}' . $cryptpasswd, 
     312    ); 
     313 
     314    if ($res) { 
     315        $self->base->log(LA_NOTICE, 'Crypted password injected for %s', $self->id); 
     316        return 1; 
     317    } else { 
     318        $self->base->log(LA_ERR, 'Cannot inject crypted password for %s', $self->id); 
     319        return 0; 
     320    } 
     321} 
     322 
    3003231; 
    301324 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm

    r1865 r1935  
    551551 
    552552    return fascist_check($password, $dictionary); 
     553} 
     554 
     555=head2 InjectCryptPasswd($cryptpasswd) 
     556 
     557Inject a password encrypted using standard UNIX method. 
     558 
     559=cut 
     560 
     561sub InjectCryptPasswd { 
     562    my ($self, $cryptpasswd) = @_; 
     563 
     564    if ($self->can('_InjectCryptPasswd')) { 
     565        return $self->_InjectCryptPasswd($cryptpasswd); 
     566    } else { 
     567        $self->base->log('Injecting unix crypt password is not supported'); 
     568        return; 
     569    } 
    553570} 
    554571 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1922 r1935  
    18691869} 
    18701870 
     1871=head2 _InjectCryptPasswd($cryptpasswd) 
     1872 
     1873Inject a password encrypted using standard UNIX method. 
     1874 
     1875The passwrod will be used to authenticate user inside the application but it 
     1876will not be transmit to any other database. 
     1877 
     1878=cut 
     1879 
     1880sub _InjectCryptPasswd { 
     1881    my ($self, $cryptpasswd) = @_; 
     1882 
     1883    if (my $current = $self->get_field('userPassword')) { 
     1884        if ($cryptpasswd eq $current) { 
     1885            return 1; 
     1886        } 
     1887    } 
     1888    my $res = $self->set_fields('userPassword', $cryptpasswd); 
     1889 
     1890    if ($res) { 
     1891        $self->base->log(LA_NOTICE, 'Crypted password injected for %s', $self->id); 
     1892        return 1; 
     1893    } else { 
     1894        $self->base->log(LA_ERR, 'Cannot inject crypted password for %s', $self->id); 
     1895        return 0; 
     1896    } 
     1897} 
    18711898 
    18721899=head2 GenPasswordResetId 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Unix/User.pm

    r1931 r1935  
    138138} 
    139139 
     140=head2 _InjectCryptPasswd($cryptpasswd) 
     141 
     142Inject a password encrypted using standard UNIX method. 
     143 
     144=cut 
     145 
     146sub _InjectCryptPasswd { 
     147    my ($self, $cryptpasswd) = @_; 
     148 
     149    my $res = $self->set_c_fields( 
     150        userPassword => $cryptpasswd, 
     151    ); 
     152 
     153    if ($res) { 
     154        $self->base->log(LA_NOTICE, 'Crypted password injected for %s', $self->id); 
     155        return 1; 
     156    } else { 
     157        $self->base->log(LA_ERR, 'Cannot inject crypted password for %s', $self->id); 
     158        return 0; 
     159    } 
     160} 
     161 
    1401621; 
    141163 
Note: See TracChangeset for help on using the changeset viewer.