commit acf61d77bbe1dd5dacfb0bca6651e25d88c0dfc5 from: Tracey Emery date: Wed May 11 22:01:22 2022 UTC start two factor authentication integration and get rid of stupid copyright, and add other copyright holders to license. commit - e595ec2d96e0413bb97cb1e7ef610956b6ffcf13 commit + acf61d77bbe1dd5dacfb0bca6651e25d88c0dfc5 blob - ba576eafe7d5cc13df3641929dbb82d873ef3be8 blob + 3d53e0a5c4821a4adc04b4a1e5e360c16d050edf --- LICENSE +++ LICENSE @@ -1,6 +1,8 @@ BSD 3-Clause License Copyright (c) 2022, Tracey Emery +Copyright (c) 2022, Hospice Visions, Inc. +Copyright (c) 2022, Visions Home Health and Visions Home Care, LLC. All rights reserved. Redistribution and use in source and binary forms, with or without blob - b917cbe176d3d01dfa5a4cf1126d5298a081fc06 blob + 0a362d8c5283516f5ec5988da73b282c86e0e768 --- module/Securitx/config/module.config.php +++ module/Securitx/config/module.config.php @@ -55,6 +55,7 @@ return [ 'securitx/securitx/invite' => __DIR__ . '/../view/securitx/invite/invite.phtml', 'securitx/securitx/companies' => __DIR__ . '/../view/securitx/companies/companies.phtml', 'securitx/securitx/user' => __DIR__ . '/../view/securitx/user/user.phtml', + 'securitx/securitx/twofa' => __DIR__ . '/../view/securitx/twofa/twofa.phtml', 'securitx/securitx/forgot' => __DIR__ . '/../view/securitx/forgot/forgot.phtml', 'securitx/securitx/requestadmin' => __DIR__ . '/../view/securitx/requestadmin/requestadmin.phtml', 'securitx/securitx/requesteditor' => __DIR__ . '/../view/securitx/requesteditor/requesteditor.phtml', blob - 3b8051604a0c69d5cfe36e4e5387e8fe6d6ecb8a blob + 4df64ee1fc31234faef944c91f91b4b650b669c3 --- module/Securitx/src/Controller/SecuritxController.php +++ module/Securitx/src/Controller/SecuritxController.php @@ -61,6 +61,24 @@ class SecuritxController extends AbstractActionControl } if (!$member || !$member->verified) return $this->redirect()->toRoute('securitx'); + if ((time() - $member->moddate) > 60 * 60 * 24) { + if ((time() - $member->twofa_moddate) || + !$member->twofa_moddate) { + $member->twofa = rand(1000000, 9999999); + $member->twofa_moddate = time(); + $this->member_table->saveMember($member); + $emailer = new Emailer($this->email_host); + $emailer->sendTwofa($member->email, + $member->first, $member->last, $url, + $this->hipaa['notice'], $member->twofa); + } + return $this->redirect()->toRoute('securitx', + array( + 'action' => 'twofa', + 'id' => $member->u_key, + ) + ); + } $member->moddate = time(); $this->member_table->saveMember($member); @@ -258,7 +276,6 @@ class SecuritxController extends AbstractActionControl $item['tmp_name']); $fc = new FileCipher; $download = new Downloads(); - $download->moddate = time(); $download->id_key = basename($new_name, ".pdf"); $download->u_key = $member->u_key; $download->e_key = uniqid(); @@ -453,6 +470,19 @@ class SecuritxController extends AbstractActionControl ]); } } + public function twofaAction() { + $member = new Member('member'); + $id = $this->params()->fromRoute('id'); + + try { + $member = $this->member_table->getVMember($id); + } catch (\InvalidArgumentException $ex) { + return $this->redirect()->toRoute('securitx'); + } + return new ViewModel([ + 'member' => $member, + ]); + } public function requestadminAction() { if (!$this->checkAnyAdmin()) return $this->redirect()->toRoute('securitx'); @@ -481,7 +511,6 @@ class SecuritxController extends AbstractActionControl if (!$member || !$member->verified) return $this->redirect()->toRoute('securitx'); - $member->moddate = time(); $this->member_table->saveMember($member); /* check member domain */ @@ -549,7 +578,9 @@ class SecuritxController extends AbstractActionControl inviter INTEGER, r_admin INTEGER, r_editor INTEGER, - ip_address TEXT + ip_address TEXT, + twofa INTEGER, + twofa_moddate INTEGER ) ', Adapter::QUERY_MODE_EXECUTE); $adapter->query(' @@ -883,7 +914,6 @@ class SecuritxController extends AbstractActionControl $member->v_key = ''; $member->u_key = uniqid(); $member->verified = 1; - $member->moddate = time(); $company = $this->company_table->getCompany($member->company_id); @@ -979,7 +1009,6 @@ class SecuritxController extends AbstractActionControl echo $new_name; $fc = new FileCipher; $download = new Downloads(); - $download->moddate = time(); $download->id_key = basename($new_name, ".pdf"); $download->u_key = $member->u_key; $download->e_key = uniqid(); blob - 9a7037193619e1c5b4358d3cc02032f63cb44f11 blob + be9bdf845ec75c46dc4d5bcbd1e2de821539f255 --- module/Securitx/src/Model/Emailer.php +++ module/Securitx/src/Model/Emailer.php @@ -13,6 +13,27 @@ class Emailer { $this->ip = $email_host['ip']; } + public function sendTwofa($email, $first, $last, $url, $hipaa, $code) { + $message = new Message(); + $message->addFrom('no-reply@' . $this->hostname, 'SecuritX'); + $message->addTo("$email", "$first $last"); + $message->addReplyTo('no-reply@' . $this->hostname, 'SecuritX'); + $message->setSubject('Your SecuritX Two Factor Authentication Code'); + $message->setBody( + "Hello $first,\r\n\r\nHere is your two factor " . + "authentication code. This code expires in 10 minutes." . + "Thank you!\r\n\r\n$code\r\n\r\n" . + "--\r\n\r\n$hipaa" + ); + + $transport = new SmtpTransport(); + $options = new SmtpOptions([ + 'name' => $this->hostname, + 'host' => $this->ip, + ]); + $transport->setOptions($options); + $transport->send($message); + } public function sendVerifyEmail($email, $first, $last, $url, $hipaa) { $message = new Message(); $message->addFrom('no-reply@' . $this->hostname, 'SecuritX'); blob - 414e95a954bab674ce7e88ebb69d91722cb8fa32 blob + 895470e6da876a04c6971e23cdca7e96011f6504 --- module/Securitx/src/Model/Member.php +++ module/Securitx/src/Model/Member.php @@ -27,6 +27,8 @@ class Member implements InputFilterAwareInterface { public $r_editor; public $ip_address; public $company_id; + public $twofa; + public $twofa_moddate; private $inputFilter; @@ -47,6 +49,8 @@ class Member implements InputFilterAwareInterface { $this->r_editor = !empty($data['r_editor']) ? $data['r_editor'] : 0; $this->ip_address = !empty($data['ip_address']) ? $data['ip_address'] : 0; $this->company_id = !empty($data['company_id']) ? $data['company_id'] : null; + $this->twofa = !empty($data['twofa']) ? $data['twofa'] : null; + $this->twofa_moddate = !empty($data['twofa_moddate']) ? $data['twofa_moddate'] : null; } public function setInputFilter(InputFilterInterface $inputFilter) { blob - 7a691a00881e86d261706f4df2c7825918a435ad blob + f48aee4c1adf8f2c1fe9ff39873d73a1bc68426b --- module/Securitx/src/Model/MemberTable.php +++ module/Securitx/src/Model/MemberTable.php @@ -67,7 +67,7 @@ class MemberTable { 'v_key' => $member->v_key, 'u_key' => $member->u_key, 'verified' => $member->verified, - 'moddate' => time(), + 'moddate' => $member->moddate, 'is_admin' => $member->is_admin, 'is_editor' => $member->is_editor, 'inviter' => $member->inviter, @@ -75,6 +75,8 @@ class MemberTable { 'r_editor' => $member->r_editor, 'ip_address' => $member->ip_address, 'company_id' => intval($member->company_id), + 'twofa' => intval($member->twofa), + 'twofa_moddate' => intval($member->twofa_moddate), ]; $id = (int)$member->id; blob - a06059b2facac850052549539fcb53396bfb5854 blob + 4a331f8cf894a1ae18ae98b03bc4ba8f549f5ce8 --- module/Securitx/view/layout/layout.phtml +++ module/Securitx/view/layout/layout.phtml @@ -48,7 +48,7 @@
blob - /dev/null blob + 4f61cec26348400ff9ca32726e54cc546119d9f1 (mode 644) --- /dev/null +++ module/Securitx/view/securitx/twofa/twofa.phtml @@ -0,0 +1,10 @@ +headTitle('SecuritX: User Editor'); +?> +
+

Welcome to SecuritX

+ +

Hello, first ?>,
Please enter the code that was emailed to you.
If you have not received the email, check your Junk folder.

+ +
+