Enhancement: support dockhand api key auth (#6848)

This commit is contained in:
shamoon
2026-07-07 18:44:31 -07:00
committed by GitHub
parent 1b027912f4
commit c323b5b2e4
2 changed files with 9 additions and 2 deletions
+1
View File
@@ -17,4 +17,5 @@ widget:
environment: local # optional: name or id; aggregates all when omitted environment: local # optional: name or id; aggregates all when omitted
username: your-user # required for local auth username: your-user # required for local auth
password: your-pass # required for local auth password: your-pass # required for local auth
key: dockhandapikey # optional, if using API key auth instead of username/password
``` ```
+8 -2
View File
@@ -38,12 +38,18 @@ export default async function dockhandProxyHandler(req, res) {
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget })); const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
const headers = {};
if (widget.key) {
headers.Authorization = `Bearer ${widget.key}`;
}
let [status, contentType, data] = await httpProxy(url, { let [status, contentType, data] = await httpProxy(url, {
method: req.method, method: req.method,
headers,
}); });
// Attempt login and retrying once // Attempt login (username + password only) and retry once
if (status === 401) { if (status === 401 && !widget.key) {
const loggedIn = await login(widget); const loggedIn = await login(widget);
if (loggedIn) { if (loggedIn) {
[status, contentType, data] = await httpProxy(url, { [status, contentType, data] = await httpProxy(url, {