mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-29 07:21:16 -07:00
Enhancement: support dockhand api key auth (#6848)
This commit is contained in:
@@ -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
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -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, {
|
||||||
|
|||||||
Reference in New Issue
Block a user