forge
ExploreLog in

Tahinli/forge

public
0 watching
★ 0
1.2 KiB
1//! The boundary between the SSH server and forge-web (auth, authz, process building).
2
3use std::future::Future;
4
5use forge_git::GitService;
6
7use crate::parse::LfsOperation;
8
9/// Implemented by forge-web. The SSH server holds it in an `Arc`.
10pub trait GitBackend: Send + Sync + 'static {
11 /// Exact-match lookup of the raw public key blob, returning the user id.
12 fn authenticate_key(
13 &self,
14 algorithm: &str,
15 key_blob: &[u8],
16 ) -> impl Future<Output = Option<String>> + Send;
17
18 /// Authorizes and builds the git process (stdin and stdout are piped by the caller).
19 /// `Err` sends the message on stderr and exits 1.
20 fn prepare(
21 &self,
22 user_id: &str,
23 service: GitService,
24 repo_path: &str,
25 git_protocol: Option<&str>,
26 ) -> impl Future<Output = Result<tokio::process::Command, String>> + Send;
27
28 /// Authorizes a `git-lfs-authenticate` request and returns the JSON reply for stdout.
29 /// `repo_path` is `owner/repo` with `.git` stripped. `Err` sends the message on stderr
30 /// and exits 1.
31 fn lfs_authenticate(
32 &self,
33 user_id: &str,
34 repo_path: &str,
35 operation: LfsOperation,
36 ) -> impl Future<Output = Result<String, String>> + Send;
37}