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
+188
-5
@@ -1,5 +1,4 @@
|
||||
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
||||
import { useRpc, useSettings } from "@getpaseo/plugin/client";
|
||||
import { openExternalUrl, type PluginSurfaceProps, useRpc, useSettings } from "@getpaseo/plugin/client";
|
||||
import {
|
||||
ScrollView,
|
||||
SettingsAction,
|
||||
@@ -19,6 +18,7 @@ import {
|
||||
flySpritesSettings,
|
||||
type FlySpritesSettings,
|
||||
} from "../shared/settings";
|
||||
import { useOpenBaoAuth } from "./use-openbao-auth";
|
||||
|
||||
const MODE_OPTIONS: readonly { label: string; value: FlySpritesSettings["defaultProviderMode"] }[] = [
|
||||
{ label: "Remote Shell Worker (bash -lc)", value: "shell" },
|
||||
@@ -29,6 +29,7 @@ export function FlySpritesSettingsScreen({ theme, layout, host }: PluginSurfaceP
|
||||
const settings = useSettings(flySpritesSettings);
|
||||
const testConnection = useRpc(testConnectionRpc);
|
||||
const toast = useToast();
|
||||
const openbao = useOpenBaoAuth();
|
||||
|
||||
const [draft, setDraft] = useState<FlySpritesSettings>(defaultFlySpritesSettings);
|
||||
const [testing, setTesting] = useState(false);
|
||||
@@ -118,11 +119,37 @@ export function FlySpritesSettingsScreen({ theme, layout, host }: PluginSurfaceP
|
||||
}
|
||||
}
|
||||
|
||||
async function handleStartZitadel() {
|
||||
if (isDirty) {
|
||||
await settings.save(draft, revision);
|
||||
}
|
||||
await openbao.startLogin();
|
||||
}
|
||||
|
||||
async function handlePullOpenBao() {
|
||||
if (isDirty) {
|
||||
await settings.save(draft, revision);
|
||||
}
|
||||
await openbao.pullNow();
|
||||
}
|
||||
|
||||
const baoStatus = openbao.status;
|
||||
const pendingFlow = baoStatus?.pendingAuth?.status === "pending" ? baoStatus.pendingAuth : null;
|
||||
const baoSummary = baoStatus?.authenticated
|
||||
? `Signed in as ${baoStatus.displayName ?? "Zitadel user"}${
|
||||
baoStatus.tokenPresent ? " · Token loaded" : " · Token not loaded"
|
||||
}`
|
||||
: "Not signed in";
|
||||
|
||||
return (
|
||||
<ScrollView style={styles.screen} contentContainerStyle={styles.body}>
|
||||
<SettingsSection
|
||||
title="Fly Sprites authentication"
|
||||
info={<Text style={styles.muted}>Host settings for {host.label}. Leave token blank to use SPRITES_TOKEN.</Text>}
|
||||
info={
|
||||
<Text style={styles.muted}>
|
||||
Host settings for {host.label}. Leave Sprites API token blank to pull from OpenBao or host env.
|
||||
</Text>
|
||||
}
|
||||
>
|
||||
{isInvalid ? (
|
||||
<SettingsCard>
|
||||
@@ -133,9 +160,9 @@ export function FlySpritesSettingsScreen({ theme, layout, host }: PluginSurfaceP
|
||||
<SettingsCard key={`auth-${revision}`}>
|
||||
<SettingsInput
|
||||
label="Sprites API token"
|
||||
hint="Used by the provider, agent tools, and worker manager."
|
||||
hint="Optional direct override. Leave blank to pull FLY_TOKEN from OpenBao."
|
||||
initialValue={draft.token}
|
||||
placeholder="SPRITES_TOKEN (leave blank to read host env)"
|
||||
placeholder="Leave blank to use OpenBao or SPRITES_TOKEN"
|
||||
secureTextEntry
|
||||
disabled={settings.saving}
|
||||
onChangeText={(token) => {
|
||||
@@ -164,6 +191,162 @@ export function FlySpritesSettingsScreen({ theme, layout, host }: PluginSurfaceP
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection
|
||||
title="OpenBao + Zitadel OIDC"
|
||||
info={
|
||||
<Text style={styles.muted}>
|
||||
Pulls {draft.openbaoSecretKey || "FLY_TOKEN"} from {draft.openbaoKvMount || "secret"}/
|
||||
{draft.openbaoSecretPath || "paseo"} via Zitadel Device Code auth.
|
||||
</Text>
|
||||
}
|
||||
>
|
||||
<SettingsCard key={`openbao-${revision}`}>
|
||||
<SettingsSwitch
|
||||
label="Pull token from OpenBao"
|
||||
hint="Uses your Zitadel OpenBao session when direct token is blank."
|
||||
value={draft.openbaoEnabled}
|
||||
disabled={settings.saving}
|
||||
onValueChange={(openbaoEnabled) => {
|
||||
const next = { ...draft, openbaoEnabled };
|
||||
setDraft(next);
|
||||
void saveDraft(next);
|
||||
}}
|
||||
/>
|
||||
<SettingsRow
|
||||
label="OpenBao session"
|
||||
hint={baoStatus?.lastError ?? baoSummary}
|
||||
error={baoStatus?.lastError ?? undefined}
|
||||
/>
|
||||
{pendingFlow ? (
|
||||
<SettingsAction
|
||||
label={`Waiting for Zitadel approval (Code: ${pendingFlow.userCode})`}
|
||||
hint={pendingFlow.verificationUriComplete || pendingFlow.verificationUri}
|
||||
actionLabel="Open Zitadel"
|
||||
onPress={() =>
|
||||
void openExternalUrl(pendingFlow.verificationUriComplete || pendingFlow.verificationUri)
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
<SettingsAction
|
||||
label="Zitadel OIDC sign-in"
|
||||
hint="Opens Zitadel Device Code authorization in your browser and exchanges JWT with OpenBao."
|
||||
actionLabel={
|
||||
openbao.busy
|
||||
? "Working…"
|
||||
: baoStatus?.authenticated
|
||||
? "Re-authenticate"
|
||||
: "Sign in with Zitadel"
|
||||
}
|
||||
disabled={openbao.busy || settings.saving || !draft.openbaoEnabled}
|
||||
onPress={() => void handleStartZitadel()}
|
||||
/>
|
||||
{baoStatus?.authenticated ? (
|
||||
<>
|
||||
<SettingsAction
|
||||
label="Refresh token from OpenBao"
|
||||
hint={`Reads ${draft.openbaoKvMount}/${draft.openbaoSecretPath} (${draft.openbaoSecretKey}).`}
|
||||
actionLabel="Pull now"
|
||||
disabled={openbao.busy || settings.saving || !draft.openbaoEnabled}
|
||||
onPress={() => void handlePullOpenBao()}
|
||||
/>
|
||||
<SettingsAction
|
||||
label="Sign out of OpenBao"
|
||||
hint="Clears saved OpenBao token for this host."
|
||||
actionLabel="Sign out"
|
||||
disabled={openbao.busy}
|
||||
onPress={() => void openbao.logout()}
|
||||
/>
|
||||
</>
|
||||
) : null}
|
||||
<SettingsInput
|
||||
label="OpenBao URL"
|
||||
initialValue={draft.openbaoAddr}
|
||||
placeholder="https://bao.site.latha.org"
|
||||
disabled={settings.saving}
|
||||
onChangeText={(openbaoAddr) => {
|
||||
setStatusMessage(null);
|
||||
setDraft((prev) => ({ ...prev, openbaoAddr }));
|
||||
}}
|
||||
/>
|
||||
<SettingsInput
|
||||
label="OpenBao KV mount"
|
||||
initialValue={draft.openbaoKvMount}
|
||||
placeholder="secret"
|
||||
disabled={settings.saving}
|
||||
onChangeText={(openbaoKvMount) => {
|
||||
setStatusMessage(null);
|
||||
setDraft((prev) => ({ ...prev, openbaoKvMount }));
|
||||
}}
|
||||
/>
|
||||
<SettingsInput
|
||||
label="OpenBao secret path"
|
||||
initialValue={draft.openbaoSecretPath}
|
||||
placeholder="paseo"
|
||||
disabled={settings.saving}
|
||||
onChangeText={(openbaoSecretPath) => {
|
||||
setStatusMessage(null);
|
||||
setDraft((prev) => ({ ...prev, openbaoSecretPath }));
|
||||
}}
|
||||
/>
|
||||
<SettingsInput
|
||||
label="OpenBao secret key"
|
||||
initialValue={draft.openbaoSecretKey}
|
||||
placeholder="FLY_TOKEN"
|
||||
disabled={settings.saving}
|
||||
onChangeText={(openbaoSecretKey) => {
|
||||
setStatusMessage(null);
|
||||
setDraft((prev) => ({ ...prev, openbaoSecretKey }));
|
||||
}}
|
||||
/>
|
||||
<SettingsInput
|
||||
label="OpenBao auth mount & role"
|
||||
hint={`Mount: ${draft.openbaoAuthMount} · Role: ${draft.openbaoRole}`}
|
||||
initialValue={`${draft.openbaoAuthMount}:${draft.openbaoRole}`}
|
||||
placeholder="jwt:admin"
|
||||
disabled={settings.saving}
|
||||
onChangeText={(val) => {
|
||||
const [mount, role] = val.split(":");
|
||||
setStatusMessage(null);
|
||||
setDraft((prev) => ({
|
||||
...prev,
|
||||
openbaoAuthMount: (mount ?? "jwt").trim() || "jwt",
|
||||
openbaoRole: (role ?? "admin").trim() || "admin",
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
<SettingsInput
|
||||
label="Zitadel issuer URL"
|
||||
initialValue={draft.zitadelIssuer}
|
||||
placeholder="https://auth.site.latha.org"
|
||||
disabled={settings.saving}
|
||||
onChangeText={(zitadelIssuer) => {
|
||||
setStatusMessage(null);
|
||||
setDraft((prev) => ({ ...prev, zitadelIssuer }));
|
||||
}}
|
||||
/>
|
||||
<SettingsInput
|
||||
label="Zitadel client ID"
|
||||
initialValue={draft.zitadelClientId}
|
||||
placeholder="400222693598691513"
|
||||
disabled={settings.saving}
|
||||
onChangeText={(zitadelClientId) => {
|
||||
setStatusMessage(null);
|
||||
setDraft((prev) => ({ ...prev, zitadelClientId }));
|
||||
}}
|
||||
/>
|
||||
<SettingsInput
|
||||
label="Zitadel scope"
|
||||
initialValue={draft.zitadelScope}
|
||||
placeholder="openid profile email"
|
||||
disabled={settings.saving}
|
||||
onChangeText={(zitadelScope) => {
|
||||
setStatusMessage(null);
|
||||
setDraft((prev) => ({ ...prev, zitadelScope }));
|
||||
}}
|
||||
/>
|
||||
</SettingsCard>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection title="Sprite defaults & provider">
|
||||
<SettingsCard key={`defaults-${revision}`}>
|
||||
<SettingsSelect
|
||||
|
||||
Reference in new issue
Block a user