ready for public
This commit is contained in:
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
.env
|
||||||
|
*.pyc
|
||||||
|
__pycache__/
|
||||||
|
*.log
|
||||||
|
/app/logs/
|
||||||
|
instance/
|
||||||
|
.env.*
|
||||||
23
README.md
23
README.md
@@ -20,16 +20,21 @@ A lightweight web UI to manage MAC address-based FreeRADIUS configurations backe
|
|||||||
Add the following tables to your RADIUS database:
|
Add the following tables to your RADIUS database:
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
CREATE TABLE IF NOT EXISTS rad_description (
|
CREATE TABLE `rad_description` (
|
||||||
username VARCHAR(64) PRIMARY KEY,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
description TEXT
|
`username` char(12) DEFAULT NULL,
|
||||||
);
|
`description` varchar(200) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS mac_vendor_cache (
|
CREATE TABLE `mac_vendor_cache` (
|
||||||
mac_prefix VARCHAR(6) PRIMARY KEY,
|
`mac_prefix` varchar(6) NOT NULL,
|
||||||
vendor_name VARCHAR(255),
|
`vendor_name` varchar(255) DEFAULT NULL,
|
||||||
last_updated TIMESTAMP
|
`status` enum('found','not_found') DEFAULT 'found',
|
||||||
);
|
`last_checked` datetime DEFAULT current_timestamp(),
|
||||||
|
`last_updated` datetime DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`mac_prefix`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
10
app/app.py
10
app/app.py
@@ -4,15 +4,11 @@ from views.user_views import user
|
|||||||
from views.group_views import group
|
from views.group_views import group
|
||||||
from config import app_config
|
from config import app_config
|
||||||
from database import init_app
|
from database import init_app
|
||||||
import logging
|
import os, logging
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
import os
|
|
||||||
|
|
||||||
log_to_file = os.getenv('LOG_TO_FILE', 'false').lower() == 'true'
|
if app.config['LOG_TO_FILE']:
|
||||||
log_file_path = os.getenv('LOG_FILE_PATH', '/app/logs/app.log')
|
handler = RotatingFileHandler(app.config['LOG_FILE_PATH'], maxBytes=1000000, backupCount=3)
|
||||||
|
|
||||||
if log_to_file:
|
|
||||||
handler = RotatingFileHandler(log_file_path, maxBytes=1000000, backupCount=3)
|
|
||||||
handler.setLevel(logging.INFO)
|
handler.setLevel(logging.INFO)
|
||||||
app.logger.addHandler(handler)
|
app.logger.addHandler(handler)
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
"""Base configuration."""
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
TESTING = False
|
TESTING = False
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
SECRET_KEY = os.getenv('FLASK_SECRET_KEY', 'default-insecure-key')
|
SECRET_KEY = os.getenv('FLASK_SECRET_KEY', 'default-insecure-key')
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
LOG_TO_FILE = os.getenv('LOG_TO_FILE', 'false').lower() == 'true'
|
||||||
|
LOG_FILE_PATH = os.getenv('LOG_FILE_PATH', '/app/logs/app.log')
|
||||||
|
|
||||||
|
# MAC Lookup API
|
||||||
OUI_API_URL = os.getenv('OUI_API_URL', 'https://api.maclookup.app/v2/macs/{}')
|
OUI_API_URL = os.getenv('OUI_API_URL', 'https://api.maclookup.app/v2/macs/{}')
|
||||||
OUI_API_KEY = os.getenv('OUI_API_KEY', '')
|
OUI_API_KEY = os.getenv('OUI_API_KEY', '')
|
||||||
OUI_API_LIMIT_PER_SEC = int(os.getenv('OUI_API_LIMIT_PER_SEC', '2'))
|
OUI_API_LIMIT_PER_SEC = int(os.getenv('OUI_API_LIMIT_PER_SEC', '2'))
|
||||||
|
|||||||
BIN
app/static/android-chrome-192x192.png
Normal file
BIN
app/static/android-chrome-192x192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
app/static/android-chrome-512x512.png
Normal file
BIN
app/static/android-chrome-512x512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 262 KiB |
BIN
app/static/apple-touch-icon.png
Normal file
BIN
app/static/apple-touch-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
BIN
app/static/favicon-16x16.png
Normal file
BIN
app/static/favicon-16x16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 728 B |
BIN
app/static/favicon-32x32.png
Normal file
BIN
app/static/favicon-32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
app/static/favicon.ico
Normal file
BIN
app/static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -228,9 +228,9 @@ def refresh_vendors():
|
|||||||
db = get_db()
|
db = get_db()
|
||||||
cursor = db.cursor(dictionary=True)
|
cursor = db.cursor(dictionary=True)
|
||||||
|
|
||||||
api_url = os.getenv('MACLOOKUP_API_URL', 'https://api.maclookup.app/v2/macs/{}').strip('"')
|
api_url = os.getenv('OUI_API_API_URL', 'https://api.maclookup.app/v2/macs/{}').strip('"')
|
||||||
api_key = os.getenv('MACLOOKUP_API_KEY', '').strip('"')
|
api_key = os.getenv('OUI_API_API_KEY', '').strip('"')
|
||||||
limit = int(os.getenv('MACLOOKUP_RATE_LIMIT', 2))
|
limit = int(os.getenv('OUI_API_RATE_LIMIT', 2))
|
||||||
headers = {'Authorization': f'Bearer {api_key}'} if api_key else {}
|
headers = {'Authorization': f'Bearer {api_key}'} if api_key else {}
|
||||||
|
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
|
|||||||
@@ -7,20 +7,12 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- ./app:/app
|
- ./app:/app
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
environment:
|
environment:
|
||||||
- FLASK_APP=app.py
|
- FLASK_APP=app.py
|
||||||
- FLASK_ENV=development
|
- FLASK_ENV=development
|
||||||
- MYSQL_HOST=192.168.60.150
|
|
||||||
- MYSQL_USER=user_92z0Kj
|
|
||||||
- MYSQL_PASSWORD=5B3UXZV8vyrB
|
|
||||||
- MYSQL_DATABASE=radius_NIaIuT
|
|
||||||
- FLASK_SECRET_KEY=default-insecure-key
|
|
||||||
- PYTHONPATH=/app
|
- PYTHONPATH=/app
|
||||||
- MACLOOKUP_RATE_LIMIT=2
|
|
||||||
- MACLOOKUP_API_KEY="" # if using a key later
|
|
||||||
- MACLOOKUP_API_URL="https://api.maclookup.app/v2/macs/{}"
|
|
||||||
- LOG_TO_FILE=true
|
|
||||||
- LOG_FILE_PATH=/app/logs/app.log
|
|
||||||
restart: no
|
restart: no
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
|
|||||||
Reference in New Issue
Block a user