diff --git a/js/ui.js b/js/ui.js index 2c41a57..f0ffa1f 100644 --- a/js/ui.js +++ b/js/ui.js @@ -539,6 +539,7 @@ function _renderJobConfigFields(key, cfg) { `; if (key === 'patchmon_sync' || key === 'semaphore_sync') { const label = key === 'semaphore_sync' ? 'API Token (Bearer)' : 'API Token (Basic)'; + const tokenPlaceholder = key === 'patchmon_sync' ? 'token_key:token_secret' : ''; return `
@@ -548,6 +549,7 @@ function _renderJobConfigFields(key, cfg) {
`; } diff --git a/server/jobs.js b/server/jobs.js index dc61d1f..160bea3 100644 --- a/server/jobs.js +++ b/server/jobs.js @@ -41,8 +41,14 @@ async function patchmonSyncHandler(cfg) { const { api_url, api_token } = cfg; if (!api_url || !api_token) throw new Error('Patchmon not configured — set API URL and token'); + // Accept raw "key:secret" (recommended) or a pre-encoded base64 string. + // ":" cannot appear in a valid base64 string, so it's a reliable discriminator. + const credential = api_token.includes(':') + ? Buffer.from(api_token).toString('base64') + : api_token; + const res = await fetch(api_url, { - headers: { Authorization: `Basic ${api_token}` }, + headers: { Authorization: `Basic ${credential}` }, }); if (!res.ok) throw new Error(`Patchmon API ${res.status}`);