feat: add OpenBao + Zitadel OIDC device-code token integration
This commit is contained in:
1 parent
d399919690
commit
9188bfc277
9 files changed
+1232
-15
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
type PluginHostProps,
|
||||
openExternalUrl,
|
||||
useRpc,
|
||||
useSubscription,
|
||||
} from "@getpaseo/plugin/client";
|
||||
@@ -9,6 +10,7 @@ import { Pressable, Text, View } from "react-native";
|
||||
import {
|
||||
type CheckpointSummary,
|
||||
type SpriteSummary,
|
||||
type TokenSource,
|
||||
type WorkerSummary,
|
||||
createCheckpointRpc,
|
||||
createSpriteRpc,
|
||||
@@ -22,6 +24,7 @@ import {
|
||||
watchWorkersSub,
|
||||
workerLogsRpc,
|
||||
} from "../shared/contracts";
|
||||
import { useOpenBaoAuth } from "./use-openbao-auth";
|
||||
|
||||
interface WorkersScreenProps extends PluginHostProps {
|
||||
workspaceName?: string;
|
||||
@@ -49,7 +52,7 @@ export function FlySpritesWorkersScreen({
|
||||
const restoreCheckpoint = useRpc(restoreCheckpointRpc);
|
||||
|
||||
const [configured, setConfigured] = useState(false);
|
||||
const [tokenSource, setTokenSource] = useState<"settings" | "env" | "none">("none");
|
||||
const [tokenSource, setTokenSource] = useState<TokenSource>("none");
|
||||
const [remoteError, setRemoteError] = useState<string | null>(null);
|
||||
const [sprites, setSprites] = useState<SpriteSummary[]>([]);
|
||||
const [workers, setWorkers] = useState<WorkerSummary[]>([]);
|
||||
@@ -98,6 +101,10 @@ export function FlySpritesWorkersScreen({
|
||||
void refresh();
|
||||
}, [refresh]);
|
||||
|
||||
const openbao = useOpenBaoAuth({ onConnected: refresh });
|
||||
const pendingFlow =
|
||||
openbao.status?.pendingAuth?.status === "pending" ? openbao.status.pendingAuth : null;
|
||||
|
||||
const selectedWorker = useMemo(
|
||||
() => workers.find((w) => w.workerId === selectedWorkerId) ?? null,
|
||||
[workers, selectedWorkerId],
|
||||
@@ -357,8 +364,61 @@ export function FlySpritesWorkersScreen({
|
||||
{!configured ? (
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.error}>
|
||||
No Fly Sprites API token configured. Open Settings → Fly Sprites Workers or set SPRITES_TOKEN on the host.
|
||||
No Fly Sprites API token loaded. Sign in with Zitadel to pull FLY_TOKEN from OpenBao, or configure a token in Settings → Fly Sprites Workers.
|
||||
</Text>
|
||||
{openbao.status?.lastError ? (
|
||||
<Text style={styles.error}>OpenBao: {openbao.status.lastError}</Text>
|
||||
) : null}
|
||||
{pendingFlow ? (
|
||||
<View style={{ gap: 6 }}>
|
||||
<Text style={styles.muted}>
|
||||
Waiting for Zitadel approval · Code: {pendingFlow.userCode}
|
||||
</Text>
|
||||
<View style={styles.row}>
|
||||
<Pressable
|
||||
style={styles.btnPrimary}
|
||||
onPress={() =>
|
||||
void openExternalUrl(
|
||||
pendingFlow.verificationUriComplete || pendingFlow.verificationUri,
|
||||
)
|
||||
}
|
||||
>
|
||||
<Text style={styles.btnPrimaryText}>Open Zitadel Login</Text>
|
||||
</Pressable>
|
||||
<Pressable
|
||||
style={styles.btnSecondary}
|
||||
onPress={() => void copyText(pendingFlow.userCode)}
|
||||
>
|
||||
<Text style={styles.btnSecondaryText}>Copy Code</Text>
|
||||
</Pressable>
|
||||
</View>
|
||||
</View>
|
||||
) : (
|
||||
<View style={styles.row}>
|
||||
<Pressable
|
||||
style={styles.btnPrimary}
|
||||
onPress={() => void openbao.startLogin()}
|
||||
disabled={openbao.busy}
|
||||
>
|
||||
<Text style={styles.btnPrimaryText}>
|
||||
{openbao.busy
|
||||
? "Starting…"
|
||||
: openbao.status?.authenticated
|
||||
? "Re-authenticate Zitadel"
|
||||
: "Sign in with Zitadel"}
|
||||
</Text>
|
||||
</Pressable>
|
||||
{openbao.status?.authenticated ? (
|
||||
<Pressable
|
||||
style={styles.btnSecondary}
|
||||
onPress={() => void openbao.pullNow()}
|
||||
disabled={openbao.busy}
|
||||
>
|
||||
<Text style={styles.btnSecondaryText}>Pull from OpenBao</Text>
|
||||
</Pressable>
|
||||
) : null}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
|
||||
Reference in new issue
Block a user