Documentation
¶
Overview ¶
Package httpapi is the HTTP driving adapter: it maps routes to use case services.
Index ¶
- Constants
- func PrincipalFrom(ctx context.Context) string
- func TenantFrom(ctx context.Context) string
- type Authenticator
- type Principal
- type Resolver
- type Router
- func (rt *Router) EnableAgent(orch *orchestrator.Orchestrator, sessions ports.AgentSessionStore, ...)
- func (rt *Router) Handler() http.Handler
- func (rt *Router) SetAgentDecisionStore(ds ports.DecisionStore)
- func (rt *Router) SetAgentPlanStore(ps ports.PlanStore)
- func (rt *Router) SetAgentRunContext(ctx context.Context)
- func (rt *Router) SetAutoVerifier(s autoVerifierService)
- func (rt *Router) SetDASTWorkflow(s dastWorkflowService)
- func (rt *Router) SetExploitation(v findingVerifier)
- func (rt *Router) SetJudgments(s judgmentService)
- func (rt *Router) SetProjects(s projectService)
- func (rt *Router) SetQualityGates(s qualityGateService)
- func (rt *Router) SetQualityProfiles(s qualityProfileService)
- func (rt *Router) SetRules(s rulesService)
- func (rt *Router) SetRuntimeVerifier(s runtimeVerifierService)
- func (rt *Router) SetThreatModel(s threatModelService)
- func (rt *Router) SetWriteupDrafts(s writeupDraftService)
Constants ¶
const PrincipalOperator = "operator"
PrincipalOperator is the fallback principal id (the bootstrap admin also uses it, so historical "operator" attribution stays coherent). Once auth is wired, the real authenticated user is stamped into the context per request.
Variables ¶
This section is empty.
Functions ¶
func PrincipalFrom ¶
PrincipalFrom returns the authenticated principal's id from ctx (the value used as the actor on every attributable action), defaulting to operator if unset.
func TenantFrom ¶
TenantFrom returns the authenticated principal's tenant from ctx – the tenant that scopes the request's data and stamps new records. Empty = the single default tenant (single-tenant mode).
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator validates the bearer token on each request via the Resolver and stamps the resolved principal into the request context for attribution.
func NewAuthenticator ¶
func NewAuthenticator(resolve Resolver) *Authenticator
NewAuthenticator builds an authenticator from a token resolver.
func (*Authenticator) Middleware ¶
Middleware enforces a valid bearer token on every route except publicPaths (no anonymous access) and stamps the authenticated principal into the context.
type Principal ¶
type Principal struct {
ID string
Name string
Role string
// TenantID is the tenant the principal belongs to – it scopes the request's data and stamps
// new records. Empty = the single default tenant (single-tenant mode).
TenantID string
}
Principal is the authenticated subject for a request.
type Resolver ¶
Resolver maps a presented bearer token to a Principal. ok=false means the token is unknown/disabled (→ 401). Implemented over the users service in the wiring.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router wires HTTP routes to use case services.
func NewRouter ¶
func NewRouter(log *slog.Logger, auth *Authenticator, eng *enguc.Service, sca *scauc.Service, aup *aupuc.Service, findings *findingsuc.Service, export *exportuc.Service, report *reportuc.Service, evidence *evidenceuc.Service, recon *reconuc.Service, logs ports.LogStream, transfer *transferuc.Service, audit *audituc.Service, vex *vexuc.Service, users *usersuc.Service, credentials *credentialsuc.Service) *Router
NewRouter builds the HTTP router.
func (*Router) EnableAgent ¶
func (rt *Router) EnableAgent(orch *orchestrator.Orchestrator, sessions ports.AgentSessionStore, approvals *approval.Service, approvalStore ports.ApprovalStore, queue ports.JobQueue, concurrency, queueDepth int)
EnableAgent wires the AI agent routes. concurrency bounds inline (non-durable) runs; queueDepth bounds the DURABLE path – the max number of not-yet-terminal agent jobs admitted before the API returns 503 (with Retry-After), so a flood / retry-storm / dead-letter re-drive cannot grow the jobs table without bound. Call after NewRouter; if never called the agent endpoints are not registered (fail-safe: SYNAPSE_AGENT_ENABLED=false leaves off).
func (*Router) Handler ¶
Handler returns the root http.Handler. Middleware chain (outermost first): normalize-path → auth → AUP gate → routes. Per-route RBAC is applied at registration via authz(perm, …) – not a path-set. Normalizing first ensures the public/AUP-exempt path-sets (matched on the request path) see exactly the path the ServeMux will route on (closes the raw-vs-cleaned path mismatch).
func (*Router) SetAgentDecisionStore ¶
func (rt *Router) SetAgentDecisionStore(ds ports.DecisionStore)
SetAgentDecisionStore wires the read-only decision log behind GET …/decisions.
func (*Router) SetAgentPlanStore ¶
SetAgentPlanStore wires the read-only execution-plan view behind GET …/plan.
func (*Router) SetAgentRunContext ¶
SetAgentRunContext binds inline agent runs to a server-lifetime context (cancelled on shutdown) so a SIGTERM stops in-flight runs instead of leaving detached goroutines.
func (*Router) SetAutoVerifier ¶
func (rt *Router) SetAutoVerifier(s autoVerifierService)
SetAutoVerifier wires the optional automated LLM judgment-verifier (nil ⇒ the auto-verify route is not registered). It seals a distinct-verifier verdict on each proposed gated judgment.
func (*Router) SetDASTWorkflow ¶
func (rt *Router) SetDASTWorkflow(s dastWorkflowService)
SetDASTWorkflow wires the governed safe-DAST proposal/approval/run endpoints.
func (*Router) SetExploitation ¶
func (rt *Router) SetExploitation(v findingVerifier)
SetExploitation wires the evidence-gated finding-verify endpoint.
func (*Router) SetJudgments ¶
func (rt *Router) SetJudgments(s judgmentService)
SetJudgments wires the AI judgment lifecycle endpoints. nil ⇒ routes are not registered.
func (*Router) SetProjects ¶
func (rt *Router) SetProjects(s projectService)
func (*Router) SetQualityGates ¶
func (rt *Router) SetQualityGates(s qualityGateService)
SetQualityGates wires quality gate management endpoints.
func (*Router) SetQualityProfiles ¶
func (rt *Router) SetQualityProfiles(s qualityProfileService)
SetQualityProfiles wires the quality-profile management endpoints. nil ⇒ routes are not registered.
func (*Router) SetRules ¶
func (rt *Router) SetRules(s rulesService)
SetRules wires the rule catalog endpoints. nil ⇒ not registered.
func (*Router) SetRuntimeVerifier ¶
func (rt *Router) SetRuntimeVerifier(s runtimeVerifierService)
SetRuntimeVerifier wires typed runtime-verifier result ingestion. nil means the route is absent.
func (*Router) SetThreatModel ¶
func (rt *Router) SetThreatModel(s threatModelService)
SetThreatModel wires the architecture threat-model ingest/read endpoints. nil ⇒ not registered.
func (*Router) SetWriteupDrafts ¶
func (rt *Router) SetWriteupDrafts(s writeupDraftService)
SetWriteupDrafts wires the human sign-off endpoints for AI-proposed write-up drafts. nil ⇒ not registered.
Source Files
¶
- agent_handler.go
- agent_readiness.go
- aup_handler.go
- auth.go
- codequality_handler.go
- credential_handler.go
- dast_workflow_handler.go
- engagement_handler.go
- evidence_handler.go
- export_handler.go
- finding_handler.go
- judgment_handler.go
- project_analysis_handler.go
- project_handler.go
- project_hotspot_handler.go
- project_issue_handler.go
- project_measure_handler.go
- project_overview_handler.go
- quality_gate_handler.go
- quality_profile_handler.go
- recon_handler.go
- report_handler.go
- response.go
- router.go
- rule_handler.go
- sca_handler.go
- threat_model_handler.go
- transfer_handler.go
- user_handler.go
- writeup_handler.go
- writeupdraft_handler.go