-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added security audit menu and fixed a mailer parameter bug
- Loading branch information
Showing
7 changed files
with
279 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
// ============================================================== | ||
// Copyright (C) 2024 Mark Vejvoda | ||
// Under GNU GPL v3.0 | ||
// ============================================================== | ||
namespace riprunner; | ||
|
||
define( 'INCLUSION_PERMITTED', true ); | ||
|
||
if(defined('__RIPRUNNER_ROOT__') === false) { | ||
define('__RIPRUNNER_ROOT__', dirname(dirname(__FILE__))); | ||
} | ||
|
||
require_once __RIPRUNNER_ROOT__ . '/template.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/authentication/authentication.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/models/global-model.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/models/live-callout-warning-model.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/models/security-menu-model.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/logging.php'; | ||
|
||
// Register our view and variables for the template | ||
Authentication::setJWTCookie(); | ||
Authentication::sec_session_start(); | ||
new LiveCalloutWarningViewModel($global_vm, $view_template_vars); | ||
$securitymenu_mv = new SecurityMenuViewModel($global_vm, $view_template_vars); | ||
|
||
// Load out template | ||
$template = $twig->resolveTemplate( | ||
array('@custom/security-menu-custom.twig.html', | ||
'security-menu.twig.html')); | ||
|
||
// Output our template | ||
echo $template->render($view_template_vars); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
// ============================================================== | ||
// Copyright (C) 2014 Mark Vejvoda | ||
// Under GNU GPL v3.0 | ||
// ============================================================== | ||
namespace riprunner; | ||
|
||
require_once __RIPRUNNER_ROOT__ . '/config.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/authentication/authentication.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/functions.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/models/base-model.php'; | ||
require_once __RIPRUNNER_ROOT__ . '/authentication/auth-notification.php'; | ||
|
||
// The model class handling variable requests dynamically | ||
class SecurityMenuViewModel extends BaseViewModel { | ||
|
||
protected function getVarContainerName() { | ||
return "securitymenu_vm"; | ||
} | ||
|
||
public function __get($name) { | ||
if('audit_list' === $name) { | ||
return $this->getAuditList(); | ||
} | ||
|
||
return parent::__get($name); | ||
} | ||
|
||
public function __isset($name) { | ||
if(in_array($name, | ||
array('audit_list')) === true) { | ||
return true; | ||
} | ||
return parent::__isset($name); | ||
} | ||
|
||
private function getAuditList() { | ||
global $log; | ||
|
||
|
||
$sql_statement = new SqlStatement($this->getGvm()->RR_DB_CONN); | ||
$sql = $sql_statement->getSqlStatement('login_audit_by_date_recent'); | ||
$qry_bind = $this->getGvm()->RR_DB_CONN->prepare($sql); | ||
|
||
$qry_bind->execute(); | ||
|
||
$rows = $qry_bind->fetchAll(\PDO::FETCH_ASSOC); | ||
$qry_bind->closeCursor(); | ||
|
||
$log->trace("About to display audit list for sql [$sql] result count: " . safe_count($rows)); | ||
|
||
$firehall = $this->getGvm()->firehall; | ||
$db_connection = $this->getGvm()->RR_DB_CONN; | ||
$auth_notification = new \riprunner\AuthNotification($firehall,$db_connection); | ||
$geo_location_cache = array(); | ||
|
||
$resultArray = array(); | ||
foreach($rows as $row){ | ||
// Add any custom fields with values here | ||
$ip = $row['login_ip']; | ||
if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $ip, $ip_match)) { | ||
$ip = $ip_match[0]; | ||
|
||
if(in_array($ip,$geo_location_cache)) { | ||
$ip_location = array_search($ip,$geo_location_cache); | ||
} | ||
else { | ||
$ip_location = $auth_notification->getIpLocation($ip); | ||
$geo_location_cache[$ip] = $ip_location; | ||
} | ||
} | ||
else { | ||
$ip_location = '???'; | ||
} | ||
$row['geo_location'] = $ip_location; | ||
$resultArray[] = $row; | ||
} | ||
|
||
return $resultArray; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Secure Login: Protected Page</title> | ||
{% if gvm.isMobile %} | ||
<link rel="stylesheet" href="{{ gvm.RR_DOC_ROOT }}/styles/mobile.css?version=1" /> | ||
<link rel="stylesheet" href="{{ gvm.RR_DOC_ROOT }}/styles/table-styles-mobile.css" /> | ||
{% else %} | ||
<link rel="stylesheet" href="{{ gvm.RR_DOC_ROOT }}/styles/main.css?version=1" /> | ||
<link rel="stylesheet" href="{{ gvm.RR_DOC_ROOT }}/styles/table-styles.css" /> | ||
{% endif %} | ||
<script type="text/JavaScript" src="{{ gvm.RR_DOC_ROOT }}/js/jquery-2.1.1.min.js"></script> | ||
<link rel="stylesheet" href="{{ gvm.RR_DOC_ROOT }}/styles/freeze-header.css" /> | ||
<script type="text/JavaScript" src="{{ gvm.RR_DOC_ROOT }}/js/forms.js"></script> | ||
</head> | ||
<body> | ||
<div class="container_center"> | ||
{% if gvm.auth.isAuth and gvm.auth.isAdmin %} | ||
|
||
{% include 'user-welcome.twig.html' %} | ||
{% include 'live-callout-warning.twig.html' %} | ||
|
||
<div class="menudiv_wrapper"> | ||
<nav class="vertical"> | ||
<ul> | ||
<li> | ||
<label for="main_page">Return to ..</label> | ||
<input type="radio" name="verticalMenu" id="main_page" /> | ||
<div> | ||
<ul> | ||
<li><a href="{{ gvm.RR_DOC_ROOT }}/controllers/main-menu-controller.php?{{ gvm.RR_JWT_TOKEN_PARAM|raw }}">Main Menu</a></li> | ||
</ul> | ||
</div> | ||
</li> | ||
<li> | ||
<label for="logout">Exit</label> | ||
<input type="radio" name="verticalMenu" id="logout" /> | ||
<div> | ||
<ul> | ||
<li><a href="{{ gvm.RR_DOC_ROOT }}/logout.php">Logout</a></li> | ||
</ul> | ||
</div> | ||
</li> | ||
</ul> | ||
</nav> | ||
</div> | ||
|
||
<h3>Recent Login Audit</h3> | ||
<form action="{{ gvm.RR_DOC_ROOT }}/controllers/security-menu-controller.php?{{ gvm.RR_JWT_TOKEN_PARAM|raw }}" | ||
method="post" name="security_form"> | ||
|
||
<center> | ||
|
||
<table id="box-table-a"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Id</th> | ||
<th scope="col">User Name</th> | ||
<th scope="col">Audit Status</th> | ||
<th scope="col">User Agent</th> | ||
<th scope="col">IP Address</th> | ||
<th scope="col">GEO Location</th> | ||
<th scope="col">Date/Time</th> | ||
<tr> | ||
</thead> | ||
|
||
|
||
|
||
{% for audit in securitymenu_vm.audit_list %} | ||
|
||
<tr> | ||
<td> | ||
{{ audit.id }} | ||
</td> | ||
|
||
<td> | ||
{{ audit.username }} | ||
</td> | ||
|
||
<td class="column_nowrap"> | ||
{{ audit.name }} | ||
</td> | ||
<td class="column_nowrap"> | ||
{{ audit.login_agent }} | ||
</td> | ||
|
||
<td class="column_nowrap"> | ||
{{ audit.login_ip }} | ||
</td> | ||
<td class="column_nowrap"> | ||
{{ audit.geo_location }} | ||
</td> | ||
<td class="column_nowrap"> | ||
{{ audit.updatetime }} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
|
||
</table> | ||
</center> | ||
</form> | ||
|
||
{% else %} | ||
{% include 'access-denied.twig.html' %} | ||
{% endif %} | ||
</div> | ||
</body> | ||
</html> |