CI / Format (push) Successful in 5s
CI / Clippy (push) Failing after 1m57s
CI / Security Audit (push) Has been skipped
CI / Tests (push) Has been skipped
CI / Detect Changes (push) Has been skipped
CI / Deploy Agent (push) Has been skipped
CI / Deploy Dashboard (push) Has been skipped
CI / Deploy Docs (push) Has been skipped
CI / Deploy MCP (push) Has been skipped
CI / Format (pull_request) Successful in 8s
CI / Clippy (pull_request) Failing after 1m53s
CI / Security Audit (pull_request) Has been skipped
CI / Tests (pull_request) Has been skipped
CI / Detect Changes (pull_request) Has been skipped
CI / Deploy Agent (pull_request) Has been skipped
CI / Deploy Dashboard (pull_request) Has been skipped
CI / Deploy Docs (pull_request) Has been skipped
CI / Deploy MCP (pull_request) Has been skipped
- Auto-generate webhook_secret on repository creation (UUID-based)
- Webhook routes use per-repo URLs: /webhook/{platform}/{repo_id}
- Verify signatures using per-repo secret (not global env var)
- Dashboard proxies webhooks to agent (agent not exposed publicly)
- Edit modal shows webhook URL + secret for user to copy into Gitea
- Add webhook-config API endpoint to retrieve per-repo secret
- Add Gitea option to edit dialog tracker type dropdown
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
use std::sync::Arc;
|
|
|
|
use axum::routing::post;
|
|
use axum::{Extension, Router};
|
|
|
|
use crate::agent::ComplianceAgent;
|
|
use crate::error::AgentError;
|
|
use crate::webhooks::{gitea, github, gitlab};
|
|
|
|
pub async fn start_webhook_server(agent: &ComplianceAgent) -> Result<(), AgentError> {
|
|
let app = Router::new()
|
|
// Per-repo webhook URLs: /webhook/{platform}/{repo_id}
|
|
.route(
|
|
"/webhook/github/{repo_id}",
|
|
post(github::handle_github_webhook),
|
|
)
|
|
.route(
|
|
"/webhook/gitlab/{repo_id}",
|
|
post(gitlab::handle_gitlab_webhook),
|
|
)
|
|
.route(
|
|
"/webhook/gitea/{repo_id}",
|
|
post(gitea::handle_gitea_webhook),
|
|
)
|
|
.layer(Extension(Arc::new(agent.clone())));
|
|
|
|
let addr = "0.0.0.0:3002";
|
|
let listener = tokio::net::TcpListener::bind(addr)
|
|
.await
|
|
.map_err(|e| AgentError::Other(format!("Failed to bind webhook server: {e}")))?;
|
|
|
|
tracing::info!("Webhook server listening on {addr}");
|
|
axum::serve(listener, app)
|
|
.await
|
|
.map_err(|e| AgentError::Other(format!("Webhook server error: {e}")))?;
|
|
|
|
Ok(())
|
|
}
|