Adding pluggable authentication
This commit is contained in:
parent
d843d50c5f
commit
7af36f0c03
8 changed files with 421 additions and 186 deletions
85
lib/WebGUI/Authentication/WebGUI.pm
Normal file
85
lib/WebGUI/Authentication/WebGUI.pm
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
package WebGUI::Authentication::WebGUI;
|
||||
|
||||
use strict;
|
||||
use WebGUI;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Authentication;
|
||||
use WebGUI::HTMLForm;
|
||||
use Digest::MD5;
|
||||
|
||||
sub formAddUser {
|
||||
my $f;
|
||||
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->readOnly("<b>WebGUI Authentication options</b>");
|
||||
$f->password("identifier",WebGUI::International::get(51));
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
||||
sub saveAddUser {
|
||||
my $encryptedPassword;
|
||||
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
WebGUI::Authentication::saveParams($session{form}{uid},'WebGUI',{identifier => $encryptedPassword});
|
||||
}
|
||||
|
||||
sub formEditUser {
|
||||
my $f;
|
||||
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->readOnly('<b>WebGUI Authentication Options</b>');
|
||||
$f->password("identifier",WebGUI::International::get(51),"password");
|
||||
}
|
||||
|
||||
sub saveEditUser {
|
||||
my ($encryptedPassword);
|
||||
|
||||
if ($session{form}{identifier} ne "password") {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
WebGUI::Authentication::saveParams($session{form}{uid}, 'WebGUI', {identifier => $encryptedPassword});
|
||||
}
|
||||
}
|
||||
|
||||
sub formEditUserSettings {
|
||||
return '';
|
||||
}
|
||||
|
||||
sub saveEditUserSettings {
|
||||
}
|
||||
|
||||
sub formCreateAccount {
|
||||
my $f;
|
||||
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->password("identifier1",WebGUI::International::get(51));
|
||||
$f->password("identifier2",WebGUI::International::get(55));
|
||||
return $f->printRowsOnly;
|
||||
}
|
||||
|
||||
sub saveCreateAccount {
|
||||
my ($encryptedPassword, $uid);
|
||||
|
||||
$uid = shift;
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier1});
|
||||
WebGUI::Authentication::saveParams($uid, 'WebGUI', {identifier => $encryptedPassword});
|
||||
}
|
||||
|
||||
sub hasBadUserData {
|
||||
return WebGUI::Operation::Account::_hasBadPassword($session{form}{identifier1},$session{form}{identifier2});
|
||||
}
|
||||
|
||||
sub validateUser {
|
||||
my ($userId, $identifier, $userData, $success);
|
||||
($userId, $identifier) = @_;
|
||||
|
||||
$userData = WebGUI::Authentication::getParams($userId, 'WebGUI');
|
||||
if ((Digest::MD5::md5_base64($identifier) eq $$userData{identifier}) && ($identifier ne "")) {
|
||||
$success = 1;
|
||||
} else {
|
||||
$success = WebGUI::International::get(68);
|
||||
WebGUI::ErrorHandler::security("login to account ".$session{form}{username}." with invalid information.");
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue