Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function SecuritySettings({ visibleItems }: SecuritySettingsProps) {
});

const [confirmOpen, setConfirmOpen] = useState(false);
const [confirmTargetEnabled, setConfirmTargetEnabled] = useState(false);

const runToggle = (enabled: boolean) => {
toast.promise(setExpose.mutateAsync({ enabled }), {
Expand All @@ -59,11 +60,8 @@ export function SecuritySettings({ visibleItems }: SecuritySettingsProps) {
};

const handleChange = (next: boolean) => {
if (next) {
setConfirmOpen(true);
} else {
runToggle(false);
}
setConfirmTargetEnabled(next);
setConfirmOpen(true);
};

return (
Expand Down Expand Up @@ -101,10 +99,12 @@ export function SecuritySettings({ visibleItems }: SecuritySettingsProps) {

<ExposeViaRelayConfirmDialog
open={confirmOpen}
targetEnabled={confirmTargetEnabled}
onOpenChange={setConfirmOpen}
onConfirm={() => {
const enabled = confirmTargetEnabled;
setConfirmOpen(false);
runToggle(true);
runToggle(enabled);
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ const CONFIRM_PHRASE = "I understand";

interface ExposeViaRelayConfirmDialogProps {
open: boolean;
targetEnabled: boolean;
onOpenChange: (open: boolean) => void;
onConfirm: () => void;
}

export function ExposeViaRelayConfirmDialog({
open,
targetEnabled,
onOpenChange,
onConfirm,
}: ExposeViaRelayConfirmDialogProps) {
Expand All @@ -32,51 +34,56 @@ export function ExposeViaRelayConfirmDialog({
if (!open) setTyped("");
}, [open]);

const canConfirm = typed === CONFIRM_PHRASE;
const canConfirm = !targetEnabled || typed === CONFIRM_PHRASE;

return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent className="max-w-[480px]">
<AlertDialogHeader>
<AlertDialogTitle>
Expose this device to Superset Relay?
{targetEnabled ? "Enable Relay access?" : "Disable Relay access?"}
</AlertDialogTitle>
<AlertDialogDescription asChild>
<div className="space-y-3 text-sm text-muted-foreground">
<p>
Turning this on allows any remote device which you grant access
to — and anything that can compromise the Superset Relay — to
reach into this device to run commands. They will be able to
read and write files in your configured project directories, run
shell commands as you, and access any tools the host service
exposes.
</p>
<p>
Only enable this if you are okay with the risk that this
entails. Most users should leave this off.
This restarts the host service and stops running terminals. File
watches and other host-backed work will be interrupted.
</p>
{targetEnabled ? (
<p>
Remote workspaces you grant access to will be able to reach
this device through Superset Relay.
</p>
) : (
<p>
Remote workspaces will no longer be able to reach this device
through Superset Relay.
</p>
)}
</div>
</AlertDialogDescription>
</AlertDialogHeader>

<div className="space-y-2 pt-2">
<Label htmlFor="expose-relay-confirm" className="text-xs">
Type{" "}
<span className="font-mono font-medium text-foreground">
{CONFIRM_PHRASE}
</span>{" "}
to continue
</Label>
<Input
id="expose-relay-confirm"
autoFocus
value={typed}
onChange={(event) => setTyped(event.target.value)}
placeholder={CONFIRM_PHRASE}
autoComplete="off"
spellCheck={false}
/>
</div>
{targetEnabled && (
<div className="space-y-2 pt-2">
<Label htmlFor="expose-relay-confirm" className="text-xs">
Type{" "}
<span className="font-mono font-medium text-foreground">
{CONFIRM_PHRASE}
</span>{" "}
to continue
</Label>
<Input
id="expose-relay-confirm"
autoFocus
value={typed}
onChange={(event) => setTyped(event.target.value)}
placeholder={CONFIRM_PHRASE}
autoComplete="off"
spellCheck={false}
/>
</div>
)}

<AlertDialogFooter>
<Button variant="ghost" size="sm" onClick={() => onOpenChange(false)}>
Expand All @@ -88,7 +95,7 @@ export function ExposeViaRelayConfirmDialog({
disabled={!canConfirm}
onClick={onConfirm}
>
Enable
{targetEnabled ? "Enable and restart" : "Disable and restart"}
</Button>
</AlertDialogFooter>
</AlertDialogContent>
Expand Down
Loading