Branch restrictions — fully enforced:
CRUD rules with pattern (exact or glob like release/*), requirePR, blockForcePush, bypass user list Enforcement via pkt-line parsing inside the git HTTP handler — before any data reaches git http-backend, each ref update is extracted and checked against stored rules Direct push to main with requirePR: true → 403 with message; push to unprotected branches still works Inline checkboxes in the UI update rules immediately Branching model — stored config: GET/PUT per repo, defaults to feature/bugfix/release/hotfix prefixes Toggle enabled/disabled, custom prefix per type with live preview No enforcement (naming guide only, as Bitbucket does) Merge strategies — enforced in PR merge endpoint: GET/PUT per repo, defaults all three allowed Merge handler now accepts strategy: "merge"|"squash"|"rebase" in request body, checks against stored policy Disallowed strategy → 409 with clear error; allowed strategy → merges and fires pull_request webhook Must have at least one strategy enabled (validated server-side) Webhooks — full delivery with HMAC: CRUD with title, URL, secret (optional), events (push/pull_request/issue), active toggle Test button sends live HTTP POST to the configured URL and shows status code in UI FireWebhooks() fires asynchronously from PR merge and can be called from any handler X-ForgeBucket-Signature-256: sha256=<hmac> header when secret is set Last delivery status and timestamp stored on webhook record and shown in list
This commit is contained in:
+21
-2
@@ -44,8 +44,10 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, staticFi
|
||||
issueH := handlers.NewIssueHandler(engine)
|
||||
sshKeyH := handlers.NewSSHKeyHandler(engine)
|
||||
memberH := handlers.NewMemberHandler(engine)
|
||||
keyH := handlers.NewDeployKeyHandler(engine)
|
||||
tokenH := handlers.NewAccessTokenHandler(engine)
|
||||
keyH := handlers.NewDeployKeyHandler(engine)
|
||||
tokenH := handlers.NewAccessTokenHandler(engine)
|
||||
workflowH := handlers.NewWorkflowHandler(engine)
|
||||
webhookH := handlers.NewWebhookHandler(engine)
|
||||
|
||||
// ── Git smart-HTTP transport ───────────────────────────────────────────────
|
||||
// These routes MUST be registered before the SPA catch-all and outside CSRF.
|
||||
@@ -153,6 +155,23 @@ func New(cfg *config.Config, engine *xorm.Engine, store sessions.Store, staticFi
|
||||
r.With(csrf).Post("/", tokenH.Create)
|
||||
r.With(csrf).Delete("/{tokenID}", tokenH.Delete)
|
||||
})
|
||||
r.Route("/branch-protections", func(r chi.Router) {
|
||||
r.Get("/", workflowH.ListBranchProtections)
|
||||
r.With(csrf).Post("/", workflowH.CreateBranchProtection)
|
||||
r.With(csrf).Patch("/{bpID}", workflowH.UpdateBranchProtection)
|
||||
r.With(csrf).Delete("/{bpID}", workflowH.DeleteBranchProtection)
|
||||
})
|
||||
r.Get("/branching-model", workflowH.GetBranchingModel)
|
||||
r.With(csrf).Put("/branching-model", workflowH.UpdateBranchingModel)
|
||||
r.Get("/merge-strategies", workflowH.GetMergeStrategies)
|
||||
r.With(csrf).Put("/merge-strategies", workflowH.UpdateMergeStrategies)
|
||||
r.Route("/webhooks", func(r chi.Router) {
|
||||
r.Get("/", webhookH.List)
|
||||
r.With(csrf).Post("/", webhookH.Create)
|
||||
r.With(csrf).Patch("/{whID}", webhookH.Update)
|
||||
r.With(csrf).Delete("/{whID}", webhookH.Delete)
|
||||
r.With(csrf).Post("/{whID}/test", webhookH.Test)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user