Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@
# You may also want to change other configuration settings,
# like the user agent or the database URL.
#
# You probably would want to reassign the folder of `RELAY__AUTH__PEM_PATH`
# You probably would want to reassign the folder of `CBRIDGE__AUTH__PEM_PATH`
# if you're not running on a container.

# Server
RELAY__SERVER__ADDRESS=0.0.0.0:3000
RELAY__SERVER__USER_AGENT=nilirad-relay-server
RELAY__SERVER__IN_REQUEST_TIMEOUT=30s
RELAY__SERVER__OUT_REQUEST_TIMEOUT=30s
CBRIDGE__SERVER__ADDRESS=0.0.0.0:3000
CBRIDGE__SERVER__USER_AGENT=nilirad-commit-bridge
CBRIDGE__SERVER__IN_REQUEST_TIMEOUT=30s
CBRIDGE__SERVER__OUT_REQUEST_TIMEOUT=30s

# Database
RELAY__DATABASE__URL=sqlite://relay.db?mode=rwc
RELAY__DATABASE__TIMEOUT=3s
RELAY__DATABASE__POLLING_DB_BUFFER_SIZE=3
RELAY__DATABASE__POLLING_DB_ERROR_COOLDOWN=300s
RELAY__DATABASE__SUBSCRIPTIONS_LIST_LIMIT=50
RELAY__DATABASE__SUBSCRIPTIONS_LIST_LIMIT_CAP=100
CBRIDGE__DATABASE__URL=sqlite://commit-bridge.db?mode=rwc
CBRIDGE__DATABASE__TIMEOUT=3s
CBRIDGE__DATABASE__POLLING_DB_BUFFER_SIZE=3
CBRIDGE__DATABASE__POLLING_DB_ERROR_COOLDOWN=300s
CBRIDGE__DATABASE__SUBSCRIPTIONS_LIST_LIMIT=50
CBRIDGE__DATABASE__SUBSCRIPTIONS_LIST_LIMIT_CAP=100

# GitHub API
RELAY__GITHUB_API__BASE_URL=https://api.github.com
RELAY__GITHUB_API__VERSION=2026-03-10
RELAY__GITHUB_API__ACCEPT_HEADER=application/vnd.github+json
CBRIDGE__GITHUB_API__BASE_URL=https://api.github.com
CBRIDGE__GITHUB_API__VERSION=2026-03-10
CBRIDGE__GITHUB_API__ACCEPT_HEADER=application/vnd.github+json

# Engine
RELAY__ENGINE__POLLING_SLEEP=300s
RELAY__ENGINE__TRIGGER_QUEUE_POLLING_INTERVAL=5s
RELAY__ENGINE__TRIGGER_RETRY_MAX_ATTEMPTS=10
RELAY__ENGINE__TRIGGER_RETRY_BACKOFF_BASE=10s
RELAY__ENGINE__STUCK_TASK_THRESHOLD=300s
CBRIDGE__ENGINE__POLLING_SLEEP=300s
CBRIDGE__ENGINE__TRIGGER_QUEUE_POLLING_INTERVAL=5s
CBRIDGE__ENGINE__TRIGGER_RETRY_MAX_ATTEMPTS=10
CBRIDGE__ENGINE__TRIGGER_RETRY_BACKOFF_BASE=10s
CBRIDGE__ENGINE__STUCK_TASK_THRESHOLD=300s

# Auth
RELAY__AUTH__CLOCK_DRIFT_BUFFER=60s
RELAY__AUTH__TOKEN_VALIDITY=300s
# RELAY__AUTH__API_KEY=YOUR_API_KEY
# RELAY__AUTH__ALLOW_UNAUTHENTICATED=true
RELAY__AUTH__CLIENT_ID=YOUR_GITHUB_CLIENT_ID
RELAY__AUTH__PEM_PATH=/app/data/YOUR_PEM_FILE.pem
CBRIDGE__AUTH__CLOCK_DRIFT_BUFFER=60s
CBRIDGE__AUTH__TOKEN_VALIDITY=300s
# CBRIDGE__AUTH__API_KEY=YOUR_API_KEY
# CBRIDGE__AUTH__ALLOW_UNAUTHENTICATED=true
CBRIDGE__AUTH__CLIENT_ID=YOUR_GITHUB_CLIENT_ID
CBRIDGE__AUTH__PEM_PATH=/app/data/YOUR_PEM_FILE.pem
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Agent Instructions for `relay`
# Agent Instructions for `commit-bridge`

This file contains crucial context for AI agents working in this repository.

Expand Down
92 changes: 50 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "relay"
name = "commit-bridge"
version = "0.1.0"
edition = "2024"
license = "MIT OR Apache-2.0"
Expand All @@ -13,7 +13,7 @@ dotenvy = "0.15.7"
futures = "0.3.32"
http = "1.4.2"
humantime-serde = "1.1.1"
jsonwebtoken = { version = "10.4.0" }
jsonwebtoken = { version = "10.4.0", features = ["aws_lc_rs"] }
reqwest = { version = "0.13.4", features = ["json"] }
rovo = { version = "0.4.8", features = ["scalar"] }
schemars = { version = "0.9", features = ["chrono04"] }
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ COPY --from=planner /app/recipe.json recipe.json
ENV SQLX_OFFLINE=true
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin relay
RUN cargo build --release --bin commit-bridge

FROM debian:bookworm-slim AS final
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/relay /usr/local/bin/relay
ENV RELAY__DATABASE__URL="sqlite:///app/data/relay.db?mode=rwc"
COPY --from=builder /app/target/release/commit-bridge /usr/local/bin/commit-bridge
ENV CBRIDGE__DATABASE__URL="sqlite:///app/data/commit-bridge.db?mode=rwc"
VOLUME ["/app/data"]
EXPOSE 3000
WORKDIR /app/data
CMD ["relay"]
CMD ["commit-bridge"]
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
# Relay Server
<h1 align="center">CommitBridge</h1>

<p align="center">
<em>Seamless workflow dispatch for remote git dependencies.</em>
</p>

<p align="center">
<a href="https://github.com/Nilirad/commit-bridge/actions/workflows/ci.yml"><img src="https://github.com/Nilirad/commit-bridge/actions/workflows/ci.yml/badge.svg" alt="CI Status"></a>&nbsp;
<a href="https://github.com/Nilirad/commit-bridge/actions/workflows/deny.yml"><img src="https://github.com/Nilirad/commit-bridge/actions/workflows/deny.yml/badge.svg" alt="Security Audit"></a>&nbsp;
<a href="https://github.com/Nilirad/commit-bridge/blob/main/Cargo.toml"><img src="https://img.shields.io/badge/License-MIT%20OR%20Apache--2.0-blue.svg" alt="Dual License"></a>
</p>

<p align="center">
<a href="https://crates.io/crates/commit-bridge"><img src="https://img.shields.io/crates/v/commit-bridge.svg" alt="Crates.io Version"></a>&nbsp;
<a href="https://docs.rs/commit-bridge"><img src="https://docs.rs/commit-bridge/badge.svg" alt="Docs.rs Status"></a>&nbsp;
<a href="https://hub.docker.com/r/Nilirad/commit-bridge"><img src="https://img.shields.io/docker/v/Nilirad/commit-bridge?sort=semver&logo=docker" alt="Docker Image"></a>
</p>

---

Triggering a repository workflow
in response to a commit on a different repository is not a trivial problem.
Expand Down Expand Up @@ -49,7 +67,7 @@ from other `repository_dispatch` events.
Clone this repository:

```shell
git clone https://github.com/Nilirad/relay.git
git clone https://github.com/Nilirad/commit-bridge.git
```

Then,
Expand Down Expand Up @@ -96,8 +114,8 @@ cp .env.example .env
```

Then,
edit the `.env` file to add your GitHub App's client id (`RELAY__AUTH__CLIENT_ID`)
and prepare the necessary paths for your GitHub App private key (`RELAY__AUTH__PEM_PATH`).
edit the `.env` file to add your GitHub App's client id (`CBRIDGE__AUTH__CLIENT_ID`)
and prepare the necessary paths for your GitHub App private key (`CBRIDGE__AUTH__PEM_PATH`).
Finally,
follow one of the three options below.

Expand Down Expand Up @@ -176,7 +194,7 @@ cargo run --release

By default, this server mandates authentication for all `/subscriptions` endpoints.

1. **Configure:** Set the `RELAY__AUTH__API_KEY` environment variable to a secure value in your `.env` file.
1. **Configure:** Set the `CBRIDGE__AUTH__API_KEY` environment variable to a secure value in your `.env` file.
2. **Authenticate:** Include the key in the `X-API-KEY` header for all requests:

```shell
Expand All @@ -192,7 +210,7 @@ Note that while this protects against key content discovery,
an attacker may still be able to infer the length of the API key
by measuring response times.
For maximum security,
ensure that your `RELAY__AUTH__API_KEY` is long
ensure that your `CBRIDGE__AUTH__API_KEY` is long
and generated using a cryptographically secure random source.

### Disabling Authentication (Not Recommended)
Expand All @@ -206,7 +224,7 @@ If you require an unauthenticated setup for rapid local prototyping,
you can explicitly opt-in by setting the following environment variable:

```text
RELAY__AUTH__ALLOW_UNAUTHENTICATED=true
CBRIDGE__AUTH__ALLOW_UNAUTHENTICATED=true
```

## License
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yaml.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
services:
relay:
commit-bridge:
build:
context: .
dockerfile: Dockerfile
image: nilirad/relay:latest
container_name: relay-server
image: nilirad/commit-bridge:latest
container_name: commit-bridge-server
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- relay_data:/app/data
- commit_bridge_data:/app/data
- ./YOUR_PEM_FILE.pem:/app/data/YOUR_PEM_FILE.pem:ro
env_file:
- .env
Expand All @@ -23,4 +23,4 @@ services:
path: Cargo.lock

volumes:
relay_data:
commit_bridge_data:
4 changes: 2 additions & 2 deletions examples/timing_attack_check.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use dudect_bencher::{BenchRng, Class, CtRunner, ctbench_main};

use commit_bridge::domain::NonEmptyString;
use commit_bridge::verify_api_key;
use dudect_bencher::rand::RngExt;
use rand::distr::{Alphanumeric, SampleString};
use relay::domain::NonEmptyString;
use relay::verify_api_key;

fn bench_verify_api_key(runner: &mut CtRunner, rng: &mut BenchRng) {
const SET_SIZE: usize = 100_000;
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@

shellHook = ''
echo "Rust dev shell ready (Rust $(rustc --version))"
export DATABASE_URL="sqlite://relay.db?mode=rwc"
export DATABASE_URL="sqlite://commit-bridge.db?mode=rwc"
'';
};
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "relay";
pname = "commit-bridge";
version = "0.1.0";
src = ./.;
cargoLock = {
Expand Down
Loading
Loading