tirbofish/kitgit · commit
2485bfd2c764fab203fd23c9274d7114d4ed70a0
merge: feat/deploy-keys into integrate/all-features
Type: SSH
SSH Key Fingerprint:
Verified
SgQHY4vUORbJC3ZtdixCl62ek/4QGh/iG2FRSyjfGPc
@@ -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); @@ -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