]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Implemented authentication.
authorMetabox <redacted>
Sun, 21 Apr 2019 20:37:38 +0000 (06:37 +1000)
committerMetabox <redacted>
Sun, 21 Apr 2019 20:37:38 +0000 (06:37 +1000)
htdocs/cgi-bin/login_ctr.cgi
htdocs/cgi-bin/main.cgi

index 620f013a52857e240b1ffc6ca8250442702c7f41..80ac675b4d5df15749b889b83d5728a373e56f7b 100755 (executable)
@@ -15,15 +15,14 @@ use DateTime;
 use DateTime::Format::SQLite;
 use DateTime::Duration;
 use Text::CSV;
-use Crypt::CBC;
-use Crypt::IDEA;
+
 
 #DEFAULT SETTINGS HERE!
 our $REC_LIMIT   = 25;
 our $TIME_ZONE   = 'Australia/Sydney';
 our $PRC_WIDTH   = '60';
 our $LOG_PATH    = '../../dbLifeLog/';
-our $SESSN_EXPR  = '+2m';
+our $SESSN_EXPR  = '+12m';
 our $RELEASE_VER = '1.3';
 #END OF SETTINGS
 
@@ -40,10 +39,9 @@ my $passw = $cgi->param('passw');
 my $frm;
 
 
-#This is the OS developer release key and cipher, replace on istallation. As it is not secure.
-my $cipher_key = '95d7a85ba891da896d0d87aca6d742d5';
-my $cipher = new Crypt::CBC({key => $cipher_key, cipher => 'IDEA'});
+#This is the OS developer release key, replace on istallation. As it is not secure.
+my $cipher_key = '95d7a85ba891da';
+
 if(&processSubmit==0){
 
   print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie);  
@@ -88,14 +86,13 @@ sub processSubmit{
 try{
        if($alias&&$passw){
                        
-                       $passw = $cipher->encrypt_hex($passw);
+                       $passw = uc crypt $passw, hex $cipher_key;
                        &checkCreateTables;
                        #ssion = CGI::Session->load();
                        $session->param('alias', $alias);
                        $session->param('passw', $passw);
                        $session->param('database', 'data_'.$alias.'_log.db');  
-                       $session->flush();                      
-                       #print $cgi->redirect('main.cgi'."?CGISESSID=$sid");    
+                       $session->flush();                                              
                        print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie, -location=>"main.cgi");  
                        return 1;
        }
index 62b7b963b7b1007f1e5232285b783b430c1436cd..98a080780102b4719567965e75f72e53fa20ecca 100755 (executable)
@@ -502,28 +502,36 @@ sub buildNavigationButtons{
 sub authenticate{
 try  {
 
-        my     $ct = ctime(stat($database));
-        if($ct < str2time("20 Apr 2019")){
-                return;
-        }
-
-
         my $st =$db->prepare("SELECT * FROM AUTH WHERE alias='$userid' and passw='$password';");
                        $st->execute();
         if($st->fetchrow_array()){return;}
+
+        #Check if passw has been wiped for reset?
+           $st =$db->prepare("SELECT * FROM AUTH WHERE alias='$userid';");
+                       $st->execute();  
+                       my @w = $st->fetchrow_array();
+        if(@w && $w[1]==""){
+                 #Wiped with -> UPDATE AUTH SET passw='' WHERE alias='$userid';
+                       $st =$db->prepare("UPDATE AUTH SET passw='$password' WHERE alias='$userid';");
+                       $st->execute();  
+                 return;
+        }
+
         
+
         print $cgi->header(-expires=>"+0s", -charset=>"UTF-8");    
    print $cgi->start_html(-title => "Personal Log Login", 
-                                     -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'},
-                                   -style =>{-type => 'text/css', -src => 'wsrc/main.css'},
+                                       -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'},
+                                     -style =>{-type => 'text/css', -src => 'wsrc/main.css'},
                         );       
         
-        print $cgi->center($cgi->div("<b>Access Denied!</b> Invalid password! alias:$userid pass:$password"));
+        print $cgi->center($cgi->div("<b>Access Denied!</b> alias:$userid pass:$password"));
         print $cgi->end_html;
         
        $db->disconnect();
        $session->flush();
        exit;
 
 } catch{
                                        print $cgi->header(-expires=>"+0s", -charset=>"UTF-8");