Skip to main content

Crate solid_pod_rs_git

Crate solid_pod_rs_git 

Source
Expand description

§solid-pod-rs-git

Git HTTP smart-protocol backend for solid-pod-rs.

§Modules

  • service — Framework-agnostic GitHttpService that speaks git-http-backend CGI.
  • authBasic nostr:<token> and NIP-98 bearer auth extractors.
  • guard — Path-traversal rejection and repo-slug extraction.
  • config — Git repository config helpers (receive.denyCurrentBranch, etc.).
  • errorGitError enum with HTTP status-code mapping.

§Quick start

use std::path::PathBuf;
use solid_pod_rs_git::{GitHttpService, BasicNostrExtractor};

// Create the service rooted at a pod's data directory.
let service = GitHttpService::new(PathBuf::from("/var/pods/alice"))
    .with_auth(BasicNostrExtractor::new());

// In your HTTP router, translate framework types to GitRequest and call:
// let response = service.handle(git_request).await;

§Feature flags

FlagPurpose
with-git-binaryEnable integration tests that need the git CLI and git-http-backend CGI binary. Unit tests always run.

§Architecture

The crate is framework-agnostic: GitHttpService consumes a GitRequest and produces a GitResponse. The embedding HTTP server (axum, actix-web, hyper, …) translates between its native types and these. Internally the service spawns git http-backend (path overridable via GIT_HTTP_BACKEND_PATH) and shuttles bytes.

§solid-pod-rs-git

Status: 0.4.0-alpha.2 — functional Git HTTP backend. 1,685 LOC, 25 tests. Integrators may depend on this crate today.

§Target scope

  • Git HTTP smart-protocol backend (info/refs, upload-pack, receive-pack) mounted as a pod sub-scope.
  • Path-traversal hardening matching JSS src/handlers/git.js.
  • receive.denyCurrentBranch=updateInstead semantics for live, single-checkout pods.
  • Basic nostr:<token> client support bridging NIP-98 to git clients that speak HTTP Basic only.
  • WAC integration so repo .git/ trees honour the enclosing pod’s ACL.

Target LOC: ~450 + 12 integration tests at first landing.

§Parity rows

Rows that will close when this crate lands (see ../solid-pod-rs/PARITY-CHECKLIST.md):

  • 69Basic nostr:<token> HTTP Basic bridge to NIP-98.
  • 100 — Git HTTP smart-protocol backend.

§JSS references

  • src/handlers/git.js

§Licence

AGPL-3.0-only.

Re-exports§

pub use auth::AuthError;
pub use auth::BasicNostrExtractor;
pub use auth::GitAuth;
pub use config::find_git_dir;
pub use config::GitDir;
pub use error::GitError;
pub use guard::extract_repo_slug;
pub use guard::path_safe;
pub use service::GitHttpService;
pub use service::GitRequest;
pub use service::GitResponse;
pub use service::DEFAULT_GIT_HTTP_BACKEND;

Modules§

auth
Authentication bridge — converts a Basic nostr:<token> request header into a NIP-98 verification call, mirroring the JSS behaviour where a Basic auth line whose username is nostr and whose password is a base64-encoded NIP-98 event is accepted by the git handler (PARITY row 69).
config
Repo-level git config mutators — mirrors JSS src/handlers/git.js lines 133-150, which runs two git config invocations on every write request:
error
Typed error enum for the Git HTTP backend.
guard
Path-traversal guard — mirrors JSS src/handlers/git.js lines 31-62 (extractRepoPath + isPathWithinDataRoot).
service
Binder-agnostic Git HTTP service — spawns the system git http-backend CGI and shuttles stdin/stdout between it and the HTTP layer.