feat: reuse authentication for all HTTP integrations
This commit is contained in:
1 parent
879a4ae23c
commit
901fd3d940
36 files changed
+830
-295
No files matched your search
@@ -9,7 +9,7 @@ request to a different origin.
|
||||
|
||||
## Existing integrations
|
||||
|
||||
Sources can reuse configured Sonarr, Radarr, Lidarr, Readarr, Prowlarr, Overseerr, Jellyseerr, Seerr, Immich, slskd, Home Assistant, Coolify, Audiobookshelf, Speedtest Tracker, AdGuard Home, and Nextcloud integrations:
|
||||
Sources can reuse any configured HTTP integration, including its saved credentials and login session. WebSocket-only integrations and the internal mock integration are excluded:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -23,7 +23,7 @@ paths append to the saved URL, including reverse-proxy subpaths. Changing the in
|
||||
Deleting it leaves the widget unconfigured until another instance is selected. The binding is shared by every placement
|
||||
of that widget definition. Exports and Workshop submissions retain the required type and omit the local integration ID.
|
||||
|
||||
Arbitrary integration requests require integration `full` access, including GET requests: service APIs can expose credentials or change state through reads. Board permissions still apply separately. Saved credentials are redacted from upstream responses. Non-GET integration requests must be actions. Requests and redirects stay within the configured URL path.
|
||||
Arbitrary integration requests require integration `full` access, including GET requests: service APIs can expose credentials or change state through reads. Board permissions still apply separately. Saved credentials are redacted from upstream responses. Non-GET integration requests must be actions. Requests and redirects stay within the configured URL path. Expired sessions are refreshed; queries can retry once, while actions require another explicit invocation.
|
||||
|
||||
## Named requests
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import type { WorkshopSubmission, WorkshopVote } from "@site/src/lib/pocketbase"
|
||||
import { getWorkshopBackend } from "@site/src/lib/pocketbase";
|
||||
import { getRuntimeWorkshopApiUrl } from "@site/src/lib/runtime-config";
|
||||
import type { SubmissionType } from "@site/src/lib/workshop-schema";
|
||||
import { integrationDefs } from "@homarr/definitions";
|
||||
import { integrationDefs, isHttpIntegrationKind } from "@homarr/definitions";
|
||||
import type { HomarrCustomWidgetV2 } from "@homarr/custom-widgets/core";
|
||||
import {
|
||||
githubAvatarUrl,
|
||||
@@ -100,7 +100,11 @@ const avatarFallback = (name: string) => name.trim().slice(0, 1).toUpperCase() |
|
||||
type WidgetSource = HomarrCustomWidgetV2["sources"][string];
|
||||
|
||||
const sourceHost = (source: WidgetSource) => {
|
||||
if (source.type === "integration") return `${integrationDefs[source.integrationKind].name} integration`;
|
||||
if (source.type === "integration") {
|
||||
if (isHttpIntegrationKind(source.integrationKind))
|
||||
return `${integrationDefs[source.integrationKind].name} integration`;
|
||||
return `${source.integrationKind} integration`;
|
||||
}
|
||||
const { baseUrl } = source;
|
||||
try {
|
||||
return new URL(baseUrl).host;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { SourceSetupPanel } from "~/components/custom-widgets/source-setup-panel";
|
||||
import { SourceSetupPanel } from "~/components/custom-widgets/integration-source-select";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useMemo } from "react";
|
||||
import {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { SourceSetupPanel } from "~/components/custom-widgets/source-setup-panel";
|
||||
import { SourceSetupPanel } from "~/components/custom-widgets/integration-source-select";
|
||||
import type { ModalProps } from "@mantine/core";
|
||||
|
||||
import type { HomarrCustomWidgetV2 } from "@homarr/custom-widgets/core";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { SourceSetupPanel } from "~/components/custom-widgets/source-setup-panel";
|
||||
import { SourceSetupPanel } from "~/components/custom-widgets/integration-source-select";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Button, Center, Group, Loader, Modal, Stack, Text } from "@mantine/core";
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
|
||||
import { Alert, Select, Stack, Text } from "@mantine/core";
|
||||
|
||||
import { CustomWidgetSourceSetupPanel } from "@homarr/custom-widgets/workbench";
|
||||
import type { CustomWidgetSourceSetupPanelProps } from "@homarr/custom-widgets/workbench";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import type { CustomWidgetIntegrationSource } from "@homarr/custom-widgets/core";
|
||||
import { customWidgetIntegrationKinds } from "@homarr/custom-widgets/core";
|
||||
import { integrationDefs } from "@homarr/definitions";
|
||||
import { integrationDefs, integrationKinds, isHttpIntegrationKind } from "@homarr/definitions";
|
||||
import { useI18n } from "@homarr/translation/client";
|
||||
|
||||
const httpIntegrationKinds = integrationKinds.filter(isHttpIntegrationKind);
|
||||
|
||||
interface IntegrationSourceSelectProps {
|
||||
kind: CustomWidgetIntegrationSource["integrationKind"];
|
||||
integrationId?: string;
|
||||
@@ -27,18 +31,18 @@ export function IntegrationSourceSelect({ kind, integrationId, onChange, onKindC
|
||||
{onKindChange && (
|
||||
<Select
|
||||
label={t("integrationType")}
|
||||
data={customWidgetIntegrationKinds.map((value) => ({ value, label: integrationDefs[value].name }))}
|
||||
data={httpIntegrationKinds.map((value) => ({ value, label: integrationDefs[value].name }))}
|
||||
value={kind}
|
||||
allowDeselect={false}
|
||||
onChange={(value) => {
|
||||
const selected = customWidgetIntegrationKinds.find((candidate) => candidate === value);
|
||||
const selected = httpIntegrationKinds.find((candidate) => candidate === value);
|
||||
if (selected) onKindChange(selected);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<Select
|
||||
label={t("selectIntegration")}
|
||||
description={integrationDefs[kind].name}
|
||||
description={isHttpIntegrationKind(kind) ? integrationDefs[kind].name : kind}
|
||||
data={integrations.map(({ id, name }) => ({ value: id, label: name }))}
|
||||
value={integrationId ?? null}
|
||||
searchable
|
||||
@@ -55,3 +59,22 @@ export function IntegrationSourceSelect({ kind, integrationId, onChange, onKindC
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
export function SourceSetupPanel(props: CustomWidgetSourceSetupPanelProps) {
|
||||
return (
|
||||
<CustomWidgetSourceSetupPanel
|
||||
{...props}
|
||||
renderIntegrationSource={(setup, value) => {
|
||||
const kind = httpIntegrationKinds.find((candidate) => candidate === setup.integrationKind);
|
||||
if (!kind) return null;
|
||||
return (
|
||||
<IntegrationSourceSelect
|
||||
kind={kind}
|
||||
integrationId={value.integrationId}
|
||||
onChange={(integrationId) => props.onChange(setup.sourceId, { ...value, integrationId })}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { customWidgetIntegrationKinds } from "@homarr/custom-widgets/core";
|
||||
import { CustomWidgetSourceSetupPanel } from "@homarr/custom-widgets/workbench";
|
||||
import type { CustomWidgetSourceSetupPanelProps } from "@homarr/custom-widgets/workbench";
|
||||
|
||||
import { IntegrationSourceSelect } from "./integration-source-select";
|
||||
|
||||
export function SourceSetupPanel(props: CustomWidgetSourceSetupPanelProps) {
|
||||
return (
|
||||
<CustomWidgetSourceSetupPanel
|
||||
{...props}
|
||||
renderIntegrationSource={(setup, value) => {
|
||||
const kind = customWidgetIntegrationKinds.find((candidate) => candidate === setup.integrationKind);
|
||||
if (!kind) return null;
|
||||
return (
|
||||
<IntegrationSourceSelect
|
||||
kind={kind}
|
||||
integrationId={value.integrationId}
|
||||
onChange={(integrationId) => props.onChange(setup.sourceId, { ...value, integrationId })}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user