Add security options for HTTPS and SSL verification

Co-authored-by: mblanke <9078342+mblanke@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-09 21:52:34 +00:00
parent 016598d54f
commit 4c89a0641b
3 changed files with 27 additions and 10 deletions

View File

@@ -81,17 +81,27 @@ Create a `config.json` file in the root directory:
"host": "192.168.1.100", "host": "192.168.1.100",
"port": 5000, "port": 5000,
"username": "your-username", "username": "your-username",
"password": "your-password" "password": "your-password",
"useHttps": false
}, },
"unifi": { "unifi": {
"host": "192.168.1.1", "host": "192.168.1.1",
"port": 443, "port": 443,
"username": "your-username", "username": "your-username",
"password": "your-password" "password": "your-password",
"verifySsl": false
} }
} }
``` ```
**Configuration Options:**
- **Synology**
- `useHttps`: Set to `true` to use HTTPS (recommended for production). Default: `false`
- **Unifi**
- `verifySsl`: Set to `true` if you have valid SSL certificates. Default: `false` (allows self-signed certificates)
**Note:** Both Synology and Unifi are optional. The dashboard will work with just Docker if you don't configure them. **Note:** Both Synology and Unifi are optional. The dashboard will work with just Docker if you don't configure them.
## 🎨 Features in Detail ## 🎨 Features in Detail

View File

@@ -3,12 +3,14 @@
"host": "192.168.1.100", "host": "192.168.1.100",
"port": 5000, "port": 5000,
"username": "your-username", "username": "your-username",
"password": "your-password" "password": "your-password",
"useHttps": false
}, },
"unifi": { "unifi": {
"host": "192.168.1.1", "host": "192.168.1.1",
"port": 443, "port": 443,
"username": "your-username", "username": "your-username",
"password": "your-password" "password": "your-password",
"verifySsl": false
} }
} }

View File

@@ -105,7 +105,7 @@ app.post('/api/docker/container/:id/:action', async (req, res) => {
// Synology endpoints // Synology endpoints
app.get('/api/synology/info', async (req, res) => { app.get('/api/synology/info', async (req, res) => {
try { try {
const { host, port = 5000, username, password } = config.synology || {}; const { host, port = 5000, username, password, useHttps = false } = config.synology || {};
if (!host || !username || !password) { if (!host || !username || !password) {
return res.json({ return res.json({
@@ -114,9 +114,12 @@ app.get('/api/synology/info', async (req, res) => {
}); });
} }
const protocol = useHttps ? 'https' : 'http';
// Login to Synology // Login to Synology
// Note: Use HTTPS in production to protect credentials
const loginResponse = await axios.get( const loginResponse = await axios.get(
`http://${host}:${port}/webapi/auth.cgi`, `${protocol}://${host}:${port}/webapi/auth.cgi`,
{ {
params: { params: {
api: 'SYNO.API.Auth', api: 'SYNO.API.Auth',
@@ -139,7 +142,7 @@ app.get('/api/synology/info', async (req, res) => {
// Get system info // Get system info
const infoResponse = await axios.get( const infoResponse = await axios.get(
`http://${host}:${port}/webapi/entry.cgi`, `${protocol}://${host}:${port}/webapi/entry.cgi`,
{ {
params: { params: {
api: 'SYNO.Core.System', api: 'SYNO.Core.System',
@@ -153,7 +156,7 @@ app.get('/api/synology/info', async (req, res) => {
// Get storage info // Get storage info
const storageResponse = await axios.get( const storageResponse = await axios.get(
`http://${host}:${port}/webapi/entry.cgi`, `${protocol}://${host}:${port}/webapi/entry.cgi`,
{ {
params: { params: {
api: 'SYNO.Core.System.Utilization', api: 'SYNO.Core.System.Utilization',
@@ -181,7 +184,7 @@ app.get('/api/synology/info', async (req, res) => {
// Unifi endpoints // Unifi endpoints
app.get('/api/unifi/devices', async (req, res) => { app.get('/api/unifi/devices', async (req, res) => {
try { try {
const { host, username, password, port = 443 } = config.unifi || {}; const { host, username, password, port = 443, verifySsl = false } = config.unifi || {};
if (!host || !username || !password) { if (!host || !username || !password) {
return res.json({ return res.json({
@@ -191,9 +194,11 @@ app.get('/api/unifi/devices', async (req, res) => {
} }
// Create axios instance with cookie jar // Create axios instance with cookie jar
// Note: SSL verification is disabled by default for self-signed certificates
// Set verifySsl: true in config.json if you have proper certificates
const api = axios.create({ const api = axios.create({
baseURL: `https://${host}:${port}`, baseURL: `https://${host}:${port}`,
httpsAgent: new (require('https').Agent)({ rejectUnauthorized: false }), httpsAgent: new (require('https').Agent)({ rejectUnauthorized: verifySsl }),
timeout: 5000 timeout: 5000
}); });