use SL::Auth::Constants qw(:all);
use SL::Auth::DB;
use SL::Auth::LDAP;
+use SL::Auth::Password;
use SL::SessionFile;
use SL::User;
return $result;
}
+sub store_credentials_in_session {
+ my ($self, %params) = @_;
+
+ $params{password} = SL::Auth::Password->hash_if_unhashed(login => $params{login}, password => $params{password})
+ unless $self->{authenticator}->requires_cleartext_password;
+
+ $self->set_session_value(login => $params{login}, password => $params{password});
+}
+
sub dbconnect {
$main::lxdebug->enter_sub(2);
# passwords. Hash it for easier comparison.
$stored_password = SL::Auth::Password->hash(password => $stored_password) unless $stored_password;
($algorithm, $stored_password) = SL::Auth::Password->parse($stored_password);
- ($algorithm2, $password) = SL::Auth::Password->parse(SL::Auth::Password->hash(password => $password, algorithm => $algorithm, login => $login));
+ ($algorithm2, $password) = SL::Auth::Password->parse(SL::Auth::Password->hash_if_unhashed(password => $password, algorithm => $algorithm, login => $login));
$main::lxdebug->leave_sub();
return 1;
}
+sub requires_cleartext_password {
+ return 0;
+}
+
sub change_password {
$main::lxdebug->enter_sub();
return 0;
}
+sub requires_cleartext_password {
+ return 1;
+}
+
sub change_password {
return ERR_BACKEND;
}
}
}
+sub hash_if_unhashed {
+ my ($class, %params) = @_;
+
+ my ($algorithm, $password) = $class->parse($params{password}, 'NONE');
+
+ return $algorithm eq 'NONE' ? $class->hash(%params) : $params{password};
+}
+
sub parse {
- my ($class, $password) = @_;
+ my ($class, $password, $default_algorithm) = @_;
return ($1, $2) if $password =~ m/^\{ ([^\}]+) \} (.+)/x;
- return ('CRYPT', $password);
+ return ($default_algorithm || 'CRYPT', $password);
}
1;
show_error('login/password_error', 'password') if SL::Auth::OK != $::auth->authenticate($::form->{login}, $::form->{password});
- $::auth->set_session_value('login', $::form->{login}, 'password', $::form->{password});
+ $::auth->store_credentials_in_session(login => $::form->{login}, password => $::form->{password});
$::auth->create_or_refresh_session;
$::auth->delete_session_value('FLASH');
delete $::form->{password};
$form->{error_message} = $::locale->text('Incorrect username or password!');
login_screen();
} else {
- $auth->set_session_value('login', $form->{login}, 'password', $form->{password});
+ $auth->store_credentials_in_session(login => $form->{login}, password => $form->{password});
$auth->create_or_refresh_session();
+ delete $form->{password};
$form->{titlebar} .= " - $::myconfig{name} - $::myconfig{dbname}";
call_sub($::locale->findsub($action));