Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat: add API auth toggle to settings UI + store

Louis Beaumontcfc1a74e1a1f
diff --git a/apps/screenpipe-app-tauri/components/settings/general-settings.tsx b/apps/screenpipe-app-tauri/components/settings/general-settings.tsx
index 551739660..479eac8c2 100644
--- a/apps/screenpipe-app-tauri/components/settings/general-settings.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/general-settings.tsx
@@ -388,6 +388,32 @@ export default function GeneralSettings() {
</CardContent>
</Card>
+ {/* API Authentication */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center space-x-3">
+ <Shield className="h-5 w-5 text-muted-foreground" />
+ <div>
+ <Label className="text-sm font-medium">
+ require API authentication
+ </Label>
+ <p className="text-xs text-muted-foreground mt-0.5">
+ remote devices must use the same account to access this API.
+ localhost is always allowed.
+ </p>
+ </div>
+ </div>
+ <Switch
+ checked={settings.apiAuth ?? false}
+ onCheckedChange={(checked) => {
+ handleSettingsChange({ apiAuth: checked });
+ }}
+ />
+ </div>
+ </CardContent>
+ </Card>
+
</div>
);
}
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 32ba9f009..a7e8fda65 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -189,6 +189,7 @@ export type Settings = SettingsStore & {
endTime: string;
recordMode: string;
}>;
+ apiAuth?: boolean;
}
export function getEffectiveFilters(settings: Settings) {
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index afd575e6e..5cd69cec4 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -1015,6 +1015,17 @@ async validateDataDir(path: string) : Promise<Result<null, string>> {
},
async getHardwareCapability() : Promise<HardwareCapability> {
return await TAURI_INVOKE("get_hardware_capability");
+},
+/**
+ * Tauri command: re-encrypt store.bin after frontend saves.
+ */
+async reencryptStore() : Promise<Result<null, string>> {
+ try {
+ return { status: "ok", data: await TAURI_INVOKE("reencrypt_store") };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
}
}
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/store.rs b/apps/screenpipe-app-tauri/src-tauri/src/store.rs
index 2339aac4a..6c0bb6246 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/store.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/store.rs
@@ -821,11 +821,20 @@ impl SettingsStore {
) -> screenpipe_engine::RecordingConfig {
let resolved_engine = self.resolve_audio_engine();
let settings = self.to_recording_settings();
- screenpipe_engine::RecordingConfig::from_settings(
+ let mut config = screenpipe_engine::RecordingConfig::from_settings(
&settings,
data_dir,
Some(&resolved_engine),
- )
+ );
+ // Set the API auth key from the user's token/api_key for remote auth
+ if config.api_auth {
+ config.api_auth_key = self
+ .user
+ .api_key
+ .clone()
+ .or_else(|| self.user.token.clone());
+ }
+ config
}
fn resolve_audio_engine(&self) -> String {
diff --git a/crates/screenpipe-config/src/recording.rs b/crates/screenpipe-config/src/recording.rs
index 4fdd5cd15..180f0b9ba 100644
--- a/crates/screenpipe-config/src/recording.rs
+++ b/crates/screenpipe-config/src/recording.rs
@@ -253,6 +253,10 @@ pub struct RecordingSettings {
/// Per-day schedule rules (only used when schedule_enabled is true)
#[serde(rename = "scheduleRules", default)]
pub schedule_rules: Vec<ScheduleRule>,
+
+ /// Require authentication for remote (non-localhost) API access.
+ #[serde(rename = "apiAuth", default)]
+ pub api_auth: bool,
}
impl RecordingSettings {
@@ -329,6 +333,7 @@ impl Default for RecordingSettings {
device_tier: None,
schedule_enabled: false,
schedule_rules: vec![],
+ api_auth: false,
}
}
}
diff --git a/crates/screenpipe-engine/src/recording_config.rs b/crates/screenpipe-engine/src/recording_config.rs
index 9e7dc365d..d49ce68ea 100644
--- a/crates/screenpipe-engine/src/recording_config.rs
+++ b/crates/screenpipe-engine/src/recording_config.rs
@@ -205,7 +205,7 @@ impl RecordingConfig {
schedule_enabled: settings.schedule_enabled,
schedule_rules: settings.schedule_rules.clone(),
max_snapshot_width: settings.max_snapshot_width,
- api_auth: false,
+ api_auth: settings.api_auth,
api_auth_key: None,
}
}