kitgit

tirbofish/kitgit · commit

2485bfd2c764fab203fd23c9274d7114d4ed70a0

merge: feat/deploy-keys into integrate/all-features

Verified

Thribhu K <4tkbytes@pm.me> · 2026-07-28 23:39

view full diff

diff --git a/migrations/013_deploy_keys.sql b/migrations/013_deploy_keys.sql
new file mode 100644
index 0000000..dd351b3
--- /dev/null
+++ b/migrations/013_deploy_keys.sql
@@ -0,0 +1,14 @@
+-- Repo-scoped SSH deploy keys (read-only or read-write).
+CREATE TABLE IF NOT EXISTS deploy_keys (
+    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
+    repo_id UUID NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
+    name TEXT NOT NULL DEFAULT 'deploy',
+    public_key TEXT NOT NULL,
+    fingerprint TEXT NOT NULL UNIQUE,
+    read_only BOOLEAN NOT NULL DEFAULT TRUE,
+    created_by UUID REFERENCES users(id) ON DELETE SET NULL,
+    created_at TIMESTAMPTZ NOT NULL DEFAULT now()
+);
+
+CREATE INDEX IF NOT EXISTS deploy_keys_repo_id_idx ON deploy_keys(repo_id);
+CREATE INDEX IF NOT EXISTS deploy_keys_fingerprint_idx ON deploy_keys(fingerprint);
\ No newline at end of file
diff --git a/src/db/deploy_keys.rs b/src/db/deploy_keys.rs
new file mode 100644
index 0000000..d538af3
--- /dev/null
+++ b/src/db/deploy_keys.rs
@@ -0,0 +1,98 @@
+//! Repo-scoped SSH deploy keys (read-only or read-write).
+
+use anyhow::Result;
+use chrono::{DateTime, Utc};
+use serde::Serialize;
+use sqlx::{FromRow, PgPool};
+use uuid::Uuid;
+
+#[derive(Debug, Clone, FromRow, Serialize)]
+pub struct DeployKey {
+    pub id: Uuid,
+    pub repo_id: Uuid,
+    pub name: String,
+    pub public_key: String,
+    pub fingerprint: String,
+    pub read_only: bool,
+    pub created_by: Option<Uuid>,
+    pub created_at: DateTime<Utc>,
+}
+
+impl DeployKey {
+    pub fn permission_label(&self) -> &'static str {
+        if self.read_only {

Large diffs are not rendered by default. Showing the first 50 of 518 lines. Show full diff