Flask service with users/roles and certificate request/download workflow.
- User and roles management (
admin,user) - Pre-registered admin account:
- username:
admin - password:
password
- username:
- Admin must change password at first login
- API
POST /certificate/requestaccepts JSON payload with:uuidanydeskcountrycitylatlonReturns a generatedreference_id
- API
GET /certificate/download/<reference_id>returns certificate package only after admin upload - On
/certificate/request, an email notification is sent to admin - Admin can:
- refuse request:
POST /admin/requests/<reference_id>/refuse - upload certificate package:
POST /admin/requests/<reference_id>/upload
- refuse request:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
python run.pyService URL:
http://127.0.0.1:5000
cp .env.example .env
docker compose up --buildStop:
docker compose downcp .env.example .env
docker build -t sensor-network-manager .
docker run --rm -p 5000:5000 --env-file .env \
-v "$(pwd)/instance:/app/instance" \
-v "$(pwd)/app/uploads:/app/app/uploads" \
sensor-network-managerPOST /loginPOST /change-passwordPOST /logout
POST /certificate/requestGET /certificate/download/<reference_id>
Example request payload:
{
"uuid": "it.uniparthenope.meteo.myhost.lab",
"anydesk": "123 456 789",
"country": "Italy",
"city": "Naples",
"lat": 40.8518,
"lon": 14.2681
}GET /admin/requestsPOST /admin/requests/<reference_id>/refusePOST /admin/requests/<reference_id>/upload(multipart form file field:certificate)
The helper script creates a certificate request and waits until download is available:
scripts/request_certificate_and_wait.sh
Default behavior:
- Auto-detects
uuidfrom reversed host FQDN with rootit.uniparthenope.meteo - Auto-detects AnyDesk ID
- Auto-detects geo info using:
http://ip-api.com/json?fields=country,cityhttp://ip-api.com/json?fields=lat,lon
Usage:
./scripts/request_certificate_and_wait.sh
./scripts/request_certificate_and_wait.sh output.zip
./scripts/request_certificate_and_wait.sh <uuid> <anydesk> [output_file]Useful env overrides:
BASE_URL,USERNAME,PASSWORD,NEW_PASSWORDUUID_ROOT,ANYDESK_IDCOUNTRY,CITY,LAT,LONPOLL_INTERVAL,MAX_WAIT_SECONDS
- First login with
admin/passwordonly allows password change. - By default email sending is disabled (
MAIL_ENABLED=false) and notifications are logged. - Enable SMTP in
.envto send real emails.