grashoper has asked for the wisdom of the Perl Monks concerning the following question:
sub Auth { #uses arsperl #unsets usrVariables #selects auth info, compares md5 hashes, sets usrVariables if succ +essful #reloads current page use Digest::MD5 qw(md5 md5_hex md5_base64); use ARS; use OLE; $response->write("This is $md5H"); my ($Site, $User, $md5H) = @_; if ($Session->{'trackActivity'}){lg("ACTIVITY","Clear Session User + Info (Auth($Site, $User, $md5H))");} $Session->{'authenticationMessage'} = ""; $Session->{'isAuthenticated'} = 0; $Session->{'usrID'} = undef; $Session->{'usrPassword'} = undef; $Session->{'usrName'} = undef; $Session->{'usrEmail'} = undef; $Session->{'usrSystem'} = undef; $Session->{'usrAccount'} = undef; $Session->{'usrLevel'} = undef; $Session->{'usrType'} = undef; $Session->{'usrClass'} = "0"; $Session->{'trainingDelegate'} = 0; $Session->{'usrDayContact'} = undef; $Session->{'usrEveningContact'} = undef; $Session->{'statsRights'} = 0; $Session->{'adminRights'} = 0; if ($User) { # if (!$Site && uc($User) eq "super") # { # $Site = "sitecode"; # } if (!$Site && uc($User) eq "000") { $Site = "SEF"; } if ($Site) { my $sql = "SELECT Name1, Name2, Name3, Email, SystemID, AccountID, AccessLvl, MLXChange, PhoneNum, AltNum, Password, ContactEmail, ContactNum FROM ARAdmin.MLSUser WHERE Username = '$User' AND SystemID = '$Site'"; my $MLSUser = ARSselect($sql); if($MLSUser) { if ($MLSUser->{numMatches} == 1) + #One User Found { my $aHash = md5_hex(lc($Session->SessionID(). $User. @{@{$MLSUser->{rows}}[0]}[10]. $Request->ServerVariables("REMOTE_A +DDR")->item())); if ($aHash eq $md5H) + #hashes match { if ($Session->{'trackActivity'}){lg("ACTIVITY","Set Athe +nticated User Info Variables (Auth())");} $Session->{'isAuthenticated'} = 1; $Session->{'usrID'} = $User; $Session->{'usrName'} = @{@{$MLSUser->{rows}}[0] +}[0]." ".@{@{$MLSUser->{rows}}[0]}[2]; if (@{@{$MLSUser->{rows}}[0]}[11]) { $Session->{'usrEmail'} = @{@{$MLSUser->{rows}} +[0]}[11]; } else { $Session->{'usrEmail'} = @{@{$MLSUser->{rows}} +[0]}[3]; } $Session->{'usrSystem'} = @{@{$MLSUser->{rows}}[0]}[ +4]; $Session->{'usrAccount'} = @{@{$MLSUser->{rows}}[0]} +[5]; $Session->{'usrPassword'} = @{@{$MLSUser->{rows}}[0] +}[10]; $Session->{'usrLevel'} = @{@{$MLSUser->{rows}}[0 +]}[6]; if (@{@{$MLSUser->{rows}}[0]}[7] == 2) + #UserClass { $Session->{'usrType'} = "Pro"; } else { $Session->{'usrType'} = "Std"; } if (uc($User) eq "NAT") + #Permissions Admin,Support,Staff, SysDelegate,AcctDelegate +,User { $Session->{'usrClass'} = "8"; } else { $Session->{'usrClass'} = "0"; } Super($Session->{'usrSystem'}, $Session->{'usrID'}); if (@{@{$MLSUser->{rows}}[0]}[12]) { $Session->{'usrDayContact'} = @{@{$MLSUser->{r +ows}}[0]}[12]; } else { $Session->{'usrDayContact'} = @{@{$MLSUser->{r +ows}}[0]}[8]; } $Session->{'usrEveningContact'} = @{@{$MLSUser->{row +s}}[0]}[9]; } else { + $Session->{'authenticationMessage'} = "Bad UserID/Passwo +rd"; #hashes dont match } } else { $Session->{'authenticationMessage'} = "Unable to Authenti +cate"; #more than one user,. rare but has happened before } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MD5 and passwords
by jwkrahn (Abbot) on Apr 09, 2008 at 19:23 UTC | |
|
Re: MD5 and passwords
by mr_mischief (Monsignor) on Apr 09, 2008 at 19:34 UTC | |
|
Re: MD5 and passwords
by samtregar (Abbot) on Apr 09, 2008 at 18:42 UTC |