Skip to content

Commit 617a685

Browse files
committed
Security: Refactor credentials and fix configuration issues
CRITICAL SECURITY FIXES: - Move all sensitive data (API keys, passwords) from config.js to separate credentials.js - Add credentials.js to .gitignore to prevent accidental commits - Create credentials.example.js as template for new installations - Add comprehensive config/README.md with security documentation BUG FIXES: - Fix typo in OpenWeather module configuration (remove "NN" prefix) - Disable debug mode in NewsAPI module IMPROVEMENTS: - Fix CSS variable references (--text-xs -> --font-size-xsmall, --text-sm -> --font-size-small) - Improve code organization and documentation This commit removes all sensitive credentials from version control while maintaining functionality through a secure credentials import system.
1 parent 821ab1c commit 617a685

File tree

5 files changed

+111
-18
lines changed

5 files changed

+111
-18
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@ js/positions.js
7171
# Ignore lock files other than package-lock.json
7272
pnpm-lock.yaml
7373
yarn.lock
74+
75+
# Sensitive configuration files containing API keys and credentials
76+
config/credentials.js

config/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# MagicMirror Konfiguration
2+
3+
## 🔐 Sicherheits-Setup
4+
5+
### Credentials einrichten
6+
7+
Die sensiblen Daten (API-Keys, Passwörter) sind **nicht** in diesem Repository enthalten.
8+
9+
**Erstmalige Einrichtung:**
10+
11+
1. Kopiere die Vorlage:
12+
```bash
13+
cd config
14+
cp credentials.example.js credentials.js
15+
```
16+
17+
2. Öffne `credentials.js` und trage deine echten Credentials ein
18+
19+
3. **Wichtig:** Die Datei `credentials.js` wird automatisch von Git ignoriert!
20+
21+
### Benötigte API-Keys
22+
23+
- **OpenWeather API:** https://openweathermap.org/api
24+
- **Tankerkönig (Fuel):** https://creativecommons.tankerkoenig.de/
25+
- **News API:** https://newsapi.org/
26+
- **Spotify Developer:** https://developer.spotify.com/dashboard/applications
27+
28+
### Dateien-Übersicht
29+
30+
- `config.js` - Hauptkonfiguration (OHNE sensible Daten)
31+
- `credentials.js` - Deine persönlichen API-Keys (**NICHT in Git**)
32+
- `credentials.example.js` - Vorlage für neue Installationen (**IN Git**)
33+
34+
## 📝 Konfiguration anpassen
35+
36+
Die Hauptkonfiguration befindet sich in `config.js`. Hier kannst du Module, Positionen, Update-Intervalle und mehr anpassen.
37+
38+
### Standort ändern
39+
40+
Die Standort-Koordinaten sind in `config.js` unter `locationSettings` definiert:
41+
42+
```javascript
43+
const locationSettings = {
44+
latitude: 51.100411,
45+
longitude: 6.811775,
46+
city: "Dormagen",
47+
agsCode: "051620004004" // AGS Code für NINA Warnungen
48+
};
49+
```
50+
51+
### Module aktivieren/deaktivieren
52+
53+
Kommentiere Module in der `modules`-Array aus oder entferne den Kommentar, um sie zu aktivieren.
54+
55+
## ⚠️ Wichtige Sicherheitshinweise
56+
57+
1. **NIEMALS** die Datei `credentials.js` ins Git-Repository committen!
58+
2. Teile deine API-Keys nicht öffentlich
59+
3. Überprüfe die `.gitignore` Datei, bevor du pushst
60+
4. Bei Problemen: Überprüfe, ob `config/credentials.js` in `.gitignore` steht

config/config.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
// MagicMirror Konfiguration
22
// Zuletzt aktualisiert: 19.05.2025
33

4-
// Ausgelagerte API-Keys und vertrauliche Daten
5-
// Diese sollten in einer separaten Datei sein, die nicht im Git-Repository liegt
6-
const credentials = {
7-
openWeatherApiKey: "9ea3a559d68a46f2a857089dd44a2506",
8-
fuelApiKey: "b0619a4b-684f-850a-dca4-801cb7d352e4",
9-
spotifyClientID: "5ff54d7644b34dfb93f690adff326c13",
10-
spotifyClientSecret: "3465cefbe93644e392a8201418930019",
11-
spotifyAccessToken: "BQDmcCwykX5bKiJCwCvVTXdGY13bbgxraQjFXun-XKoVz4BlKmE0vgDkQ1jsAIoGJDA4lUMDXwNJYw7m2OnManwogvFW_HBfpv2bUEKhnN5pbqRrCVK9uHHPl4zwkd_4rwSW10CJKS0cfhBVSFPMhc2FV7LHtodORe7mAId5ya9KbevEZzIXU9IEIqESZ3hm4w6AdBpYiVk1dDZajeQGxg",
12-
spotifyRefreshToken: "AQCV41PfVxPBCimhc2fEn5GdXG4D-RUY7_JxMm7JzcUd6Kt-2HOKXx76MxOEYOZIo-K5HuvpJHvtPauM9ijF7YOLKCPSGBVDamPePa61L9jFHf_JvoyjwSDsWhQZ4ehfWv0",
13-
newsApiKey: "fb8822efd5ed49e28ed4649040ca6d71",
14-
// WLAN-Daten
15-
wifiNetwork: "MagentaWLN-3UKJ",
16-
wifiPassword: "15774643966064724748" // Achtung: Sollte in einem sicheren Speicher aufbewahrt werden
17-
};
4+
// Importiere sensible Credentials aus separater Datei
5+
// WICHTIG: credentials.js ist in .gitignore und wird NICHT ins Repository committed!
6+
const credentials = require('./credentials.js');
187

198
// Standort-Konfigurationen
209
const locationSettings = {
@@ -72,7 +61,7 @@ let config = {
7261
{
7362
module: "MMM-OpenWeatherForecast",
7463
header: "Wetter Dormagen",
75-
NN position: "top_right",
64+
position: "top_right",
7665
config: {
7766
apikey: credentials.openWeatherApiKey,
7867
latitude: locationSettings.latitude,
@@ -262,7 +251,7 @@ NN position: "top_right",
262251
position: "top_right",
263252
config: {
264253
apiKey: credentials.newsApiKey,
265-
debug: true,
254+
debug: false,
266255
choice: "everything",
267256
pageSize: 30,
268257
sortBy: "publishedAt",

config/credentials.example.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* MagicMirror Credentials Template
3+
*
4+
* ANLEITUNG:
5+
* 1. Kopiere diese Datei zu "credentials.js" im selben Verzeichnis
6+
* 2. Fülle deine echten API-Keys und Credentials ein
7+
* 3. credentials.js wird NICHT ins Git-Repository committed (siehe .gitignore)
8+
*
9+
* NIEMALS diese Datei mit echten Credentials committen!
10+
*/
11+
12+
module.exports = {
13+
// ===== API KEYS =====
14+
15+
// OpenWeather API Key
16+
// Erhalten unter: https://openweathermap.org/api
17+
openWeatherApiKey: "DEIN_OPENWEATHER_API_KEY",
18+
19+
// Tankerkönig Fuel API Key
20+
// Erhalten unter: https://creativecommons.tankerkoenig.de/
21+
fuelApiKey: "DEIN_FUEL_API_KEY",
22+
23+
// News API Key
24+
// Erhalten unter: https://newsapi.org/
25+
newsApiKey: "DEIN_NEWS_API_KEY",
26+
27+
// ===== SPOTIFY CREDENTIALS =====
28+
29+
// Spotify Developer App Credentials
30+
// Erhalten unter: https://developer.spotify.com/dashboard/applications
31+
spotifyClientID: "DEIN_SPOTIFY_CLIENT_ID",
32+
spotifyClientSecret: "DEIN_SPOTIFY_CLIENT_SECRET",
33+
spotifyAccessToken: "DEIN_SPOTIFY_ACCESS_TOKEN",
34+
spotifyRefreshToken: "DEIN_SPOTIFY_REFRESH_TOKEN",
35+
36+
// ===== WLAN CREDENTIALS =====
37+
38+
// Nur benötigt, wenn du den WLAN-QR-Code im MMM-SystemInfo Modul nutzen möchtest
39+
wifiNetwork: "DEIN_WLAN_NAME",
40+
wifiPassword: "DEIN_WLAN_PASSWORT"
41+
};

css/custom.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
.module-header {
6969
text-transform: none;
70-
font-size: var(--text-xs);
70+
font-size: var(--font-size-xsmall);
7171
}
7272
header {
7373
text-transform: none;
@@ -112,7 +112,7 @@ header {
112112
}
113113

114114
.module.clock .date {
115-
font-size: var(--text-sm);
115+
font-size: var(--font-size-small);
116116
}
117117

118118
/*MMM-Wallpaper styles*/

0 commit comments

Comments
 (0)