📚Docs + Omada work #708
This commit is contained in:
35
front/php/templates/auth.php
Executable file
35
front/php/templates/auth.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
$isAuthenticated = false;
|
||||
|
||||
// Check if the user is logged in
|
||||
if (isset($_SESSION["login"]) && $_SESSION["login"] == 1) {
|
||||
$isAuthenticated = true;
|
||||
}
|
||||
|
||||
// $current_directory = __DIR__;
|
||||
// echo "Current directory: " . $current_directory;
|
||||
|
||||
// Check if a valid cookie is present
|
||||
$CookieSaveLoginName = "NetAlertX_SaveLogin";
|
||||
$config_file = "../../../config/app.conf"; // depends on where this file is called from
|
||||
$config_file_lines = file($config_file);
|
||||
$config_file_lines = array_values(preg_grep('/^SETPWD_password.*=/', $config_file_lines));
|
||||
$password_line = explode("'", $config_file_lines[0]);
|
||||
$Pia_Password = $password_line[1];
|
||||
|
||||
if (isset($_COOKIE[$CookieSaveLoginName]) && $Pia_Password == $_COOKIE[$CookieSaveLoginName]) {
|
||||
$isAuthenticated = true;
|
||||
}
|
||||
|
||||
if ($isAuthenticated) {
|
||||
echo 'Authorized 200';
|
||||
http_response_code(200);
|
||||
exit; // Important: Ensure script exits after successful authentication
|
||||
} else {
|
||||
http_response_code(401);
|
||||
echo 'Unauthorized 401';
|
||||
exit; // Ensure script exits after failed authentication
|
||||
}
|
||||
?>
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"code_name": "folder_name",
|
||||
"unique_prefix": "",
|
||||
"plugin_type": "core|general|system|scanner|other|publisher",
|
||||
"plugin_type": "scanner",
|
||||
"enabled": true,
|
||||
"data_source": "script|app-db-query|template|sqlite-db-query",
|
||||
"data_source": "script",
|
||||
"mapped_to_table": "CurrentScan",
|
||||
"data_filters": [
|
||||
{
|
||||
@@ -122,6 +122,25 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "list_example",
|
||||
"type": "list",
|
||||
"default_value": ["existing_entry_1", "existing_entry_2"],
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Setting name"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Description / simple setup instructions"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "multiselect_example_from_setting",
|
||||
"type": "text.multiselect",
|
||||
@@ -255,7 +274,7 @@
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value3",
|
||||
"mapped_to_column": "cur_SyncHubNodeName",
|
||||
"mapped_to_column": "cur_Type",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"type": "label",
|
||||
@@ -265,14 +284,14 @@
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Sync Node"
|
||||
"string": "Device Type"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"column": "Watched_Value4",
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
"show": false,
|
||||
"type": "label",
|
||||
"default_value": "",
|
||||
"options": [],
|
||||
@@ -280,7 +299,7 @@
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Device GUID"
|
||||
"string": "N/A"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -288,7 +307,7 @@
|
||||
"column": "Dummy",
|
||||
"mapped_to_column": "cur_ScanMethod",
|
||||
"mapped_to_column_data": {
|
||||
"value": "sync"
|
||||
"value": "Example Plugin"
|
||||
},
|
||||
"css_classes": "col-sm-2",
|
||||
"show": true,
|
||||
|
||||
@@ -6,7 +6,6 @@ import sys
|
||||
import json
|
||||
import sqlite3
|
||||
|
||||
|
||||
# Define the installation path and extend the system path for plugin imports
|
||||
INSTALL_PATH = "/app"
|
||||
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
|
||||
@@ -47,18 +46,18 @@ def main():
|
||||
#"database_column_definitions": [
|
||||
# {
|
||||
# "column": "Object_PrimaryID", <--------- the value I save into primaryId
|
||||
# "mapped_to_column": "cur_MAC", <--------- gets unserted into the CurrentScan DB table column cur_MAC
|
||||
# "mapped_to_column": "cur_MAC", <--------- gets inserted into the CurrentScan DB table column cur_MAC
|
||||
#
|
||||
for device in device_data:
|
||||
plugin_objects.add_object(
|
||||
primaryId = device['some_id'],
|
||||
secondaryId = device['some_id'],
|
||||
watched1 = device['some_id'],
|
||||
watched2 = device['some_id'],
|
||||
watched3 = device['some_id'],
|
||||
watched4 = device['some_id'],
|
||||
primaryId = device['mac_address'],
|
||||
secondaryId = device['ip_address'],
|
||||
watched1 = device['hostname'],
|
||||
watched2 = device['vendor'],
|
||||
watched3 = device['device_type'],
|
||||
watched4 = device['last_seen'],
|
||||
extra = '',
|
||||
foreignKey = device['some_id'])
|
||||
foreignKey = device['mac_address'])
|
||||
|
||||
mylog('verbose', [f'[{pluginName}] New entries: "{len(new_devices)}"'])
|
||||
|
||||
@@ -75,7 +74,34 @@ def get_device_data(some_setting):
|
||||
# do some processing, call exteranl APIs, and return a device_data list
|
||||
# ...
|
||||
#
|
||||
# Sample data for testing purposes, you can adjust the processing in main() as needed
|
||||
# ... before adding it to the plugin_objects.add_object(...)
|
||||
device_data = [
|
||||
{
|
||||
'device_id': 'device1',
|
||||
'mac_address': '00:11:22:33:44:55',
|
||||
'ip_address': '192.168.1.2',
|
||||
'hostname': 'iPhone 12',
|
||||
'vendor': 'Apple Inc.',
|
||||
'device_type': 'Smartphone',
|
||||
'last_seen': '2024-06-27 10:00:00',
|
||||
'port': '1',
|
||||
'network_id': 'network1'
|
||||
},
|
||||
{
|
||||
'device_id': 'device2',
|
||||
'mac_address': '00:11:22:33:44:66',
|
||||
'ip_address': '192.168.1.3',
|
||||
'hostname': 'Moto G82',
|
||||
'vendor': 'Motorola Inc.',
|
||||
'device_type': 'Laptop',
|
||||
'last_seen': '2024-06-27 10:05:00',
|
||||
'port': '',
|
||||
'network_id': 'network1'
|
||||
}
|
||||
]
|
||||
|
||||
# Return the data to be detected by teh main application
|
||||
return device_data
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -119,22 +119,21 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "site",
|
||||
"type": "text",
|
||||
"maxLength": 50,
|
||||
"default_value": "",
|
||||
"function": "sites",
|
||||
"type": "list",
|
||||
"default_value": [],
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "OMADA site"
|
||||
"string": "OMADA sites"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Omada SDN site id. You can get it by..."
|
||||
"string": "Omada SDN site IDs. You can get it by..."
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -178,6 +177,25 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "force_overwrite",
|
||||
"type": "boolean",
|
||||
"default_value": false,
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Force overwrite"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "By default NetAlertX will only populate missing names in OMADASDN devices (i.e.: where the name is defaulting to the device MAC address) ; with this setting toggled, it will overwrite existing values regardless."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "CMD",
|
||||
"type": "readonly",
|
||||
@@ -247,6 +265,58 @@
|
||||
"string": "Maximale Zeit in Sekunden, die auf den Abschluss des Skripts gewartet werden soll. Bei Überschreitung dieser Zeit wird das Skript abgebrochen."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"default_value": [],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Send a notification if selected values change. Use <code>CTRL + Click</code> to select/deselect. <ul> <li><code>Watched_Value1</code> is Hostname </li><li><code>Watched_Value2</code> is Parent Node </li><li><code>Watched_Value3</code> is Port </li><li><code>Watched_Value4</code> is SSID </li></ul>"
|
||||
}
|
||||
],
|
||||
"function": "WATCH",
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Watched"
|
||||
},
|
||||
{
|
||||
"language_code": "es_es",
|
||||
"string": "Visto"
|
||||
}
|
||||
],
|
||||
"options": [
|
||||
"Watched_Value1",
|
||||
"Watched_Value2",
|
||||
"Watched_Value3",
|
||||
"Watched_Value4"
|
||||
],
|
||||
"type": "text.multiselect"
|
||||
},
|
||||
{
|
||||
"default_value": ["new", "watched-changed"],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Send a notification only on these statuses. <code>new</code> means a new unique (unique combination of PrimaryId and SecondaryId) object was discovered. <code>watched-changed</code> means that selected <code>Watched_ValueN</code> columns changed."
|
||||
}
|
||||
],
|
||||
"function": "REPORT_ON",
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Report on"
|
||||
}
|
||||
],
|
||||
"options": [
|
||||
"new",
|
||||
"watched-changed",
|
||||
"watched-not-changed",
|
||||
"missing-in-last-scan"
|
||||
],
|
||||
"type": "text.multiselect"
|
||||
}
|
||||
],
|
||||
"database_column_definitions": [
|
||||
|
||||
@@ -85,8 +85,8 @@
|
||||
|
||||
<!-- JavaScript to fetch and display data based on selected format -->
|
||||
<script>
|
||||
// JavaScript to fetch and display data based on selected format
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// JavaScript to fetch and display data based on selected format
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const notificationData = document.getElementById('notificationData');
|
||||
const timestamp = document.getElementById('timestamp');
|
||||
const notiGuid = document.getElementById('guid');
|
||||
|
||||
Reference in New Issue
Block a user