c2188b862a571100481de0d4a154e11cc88c582e
- Changed inline style color from #1e3c72 to #00d4ff - Page visit count now matches cyan accent color theme - Consistent with other statistics numbers
🔐 Lizenzgenerator mit PostgreSQL Integration
Ein sicherer Lizenzgenerator mit PostgreSQL-Datenbank, interaktiver Karte und API-Key Authentifizierung.
✨ Features
- 🔑 Sichere Lizenzgenerierung mit HMAC-SHA256
- 🗄️ PostgreSQL Integration für lokale Datenspeicherung
- 🗺️ Interaktive Karte mit Leaflet.js und OpenStreetMap
- 🔍 Standortsuche über Nominatim API
- 🔐 API-Key Authentifizierung für alle API-Endpunkte
- 🌐 Web-Interface mit Login-Schutz
- 📱 Responsive Design für alle Geräte
🚀 Installation
Voraussetzungen
- Node.js (v16 oder höher)
- PostgreSQL Datenbank
- npm oder yarn
Setup
# Repository klonen
git clone <repository-url>
cd ninjaserver
# Abhängigkeiten installieren
npm install
# Umgebungsvariablen konfigurieren
cp .env.example .env
# .env-Datei mit Ihren Datenbankdaten bearbeiten
# Datenbank initialisieren
npm run init-db
# Server starten
npm start
🔐 Authentifizierung
Web-Interface
- Standardanmeldung:
admin/admin123 - Benutzer erstellen:
npm run create-user
API-Key Authentifizierung
Alle API-Endpunkte erfordern einen gültigen API-Key im Authorization Header:
Authorization: Bearer YOUR_API_KEY_HERE
API-Key generieren
curl -X POST http://localhost:3000/api/generate-api-key \
-H "Content-Type: application/json" \
-d '{"description": "Mein API Key", "standorte": "München, Berlin"}'
📡 API-Endpunkte
Geschützte Endpunkte (API-Key erforderlich)
Standorte abrufen
curl -X GET http://localhost:3000/api/locations \
-H "Authorization: Bearer YOUR_API_KEY"
Neuen Standort erstellen
curl -X POST http://localhost:3000/api/create-location \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"name": "München", "lat": 48.1351, "lon": 11.5820}'
API-Tokens abrufen
curl -X GET http://localhost:3000/api/tokens \
-H "Authorization: Bearer YOUR_API_KEY"
Token validieren
curl -X POST http://localhost:3000/api/validate-token \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"token": "TOKEN_TO_VALIDATE"}'
Token speichern
curl -X POST http://localhost:3000/api/save-token \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"token": "GENERATED_TOKEN", "description": "Beschreibung", "standorte": "Standorte"}'
Öffentliche Endpunkte (nur Web-Interface)
Login
curl -X POST http://localhost:3000/api/login \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "admin123"}'
Logout
curl -X POST http://localhost:3000/api/logout
🗄️ Datenbankstruktur
adminusers Tabelle
CREATE TABLE adminusers (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
is_active BOOLEAN DEFAULT true,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_login TIMESTAMP
);
api_tokens Tabelle
CREATE TABLE api_tokens (
id SERIAL PRIMARY KEY,
token VARCHAR(255) UNIQUE NOT NULL,
description TEXT,
standorte TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP,
is_active BOOLEAN DEFAULT true
);
locations Tabelle
CREATE TABLE locations (
id SERIAL PRIMARY KEY,
name VARCHAR(255) UNIQUE NOT NULL,
latitude DECIMAL(10, 8) NOT NULL,
longitude DECIMAL(11, 8) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
🧪 API testen
Test-Skript verwenden
# test-api.js bearbeiten und API_KEY setzen
node test-api.js
Manueller Test
# 1. API-Key generieren
curl -X POST http://localhost:3000/api/generate-api-key \
-H "Content-Type: application/json" \
-d '{"description": "Test Key"}'
# 2. API mit generiertem Key testen
curl -X GET http://localhost:3000/api/locations \
-H "Authorization: Bearer GENERATED_API_KEY"
📁 Projektstruktur
ninjaserver/
├── server.js # Hauptserver-Datei
├── routes/
│ └── api.js # API-Routen mit Bearer Token Auth
├── scripts/
│ ├── init-db.js # Datenbankinitialisierung
│ └── create-user.js # Benutzer-Erstellung
├── public/
│ ├── index.html # Hauptanwendung
│ └── login.html # Login-Seite
├── test-api.js # API-Test-Skript
└── package.json
🚀 Deployment
Lokale Entwicklung
npm run dev # Mit Nodemon für automatisches Neuladen
Produktion
npm start # Produktionsserver
🔒 Sicherheit
- API-Key Authentifizierung für alle API-Endpunkte
- Session-basierte Authentifizierung für Web-Interface
- Passwort-Hashing mit bcrypt
- HTTPS empfohlen für Produktionsumgebung
- Regelmäßige API-Key Rotation empfohlen
📝 Lizenz
Proprietär - Alle Rechte vorbehalten
👨💻 Autor
Carsten Graf
⚠️ Wichtig: Ändern Sie die Standardpasswörter in der Produktionsumgebung!
Description
Languages
JavaScript
60.9%
HTML
26.2%
CSS
10.8%
Python
2%
Shell
0.1%