server

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

POST /repo/{namespace}/{name}/advertise   (read: repo read ACL)
POST /repo/{namespace}/{name}/fetch       (read: repo read ACL)
POST /repo/{namespace}/{name}/push        (write: repo + branch ACL, non-fast-forward)

Authentication uses bearer tokens resolved against the store's users/tokens tables (store.LookupToken). Access is enforced per repository and, for push, per branch (see store.AddBranchACL / CanPushBranch). A write operation is recorded in the append-only audit_log when an AuditSink is configured.

When no users/tokens are registered the instance is treated as open (CLI default) and anonymous read/write is allowed; a configured branch allowlist still applies to push.

Index

Constants

View Source
const DefaultMaxBody = 512 << 20

DefaultMaxBody is the default request body limit (512 MiB).

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvertiseReq

type AdvertiseReq struct {
	Have        []string `json:"have"`
	HaveObjects []string `json:"have_objects"`
	WantChanges []string `json:"want_changes,omitempty"`
}

AdvertiseReq/Resp mirror the CLI's smart protocol request/response.

type AdvertiseResp

type AdvertiseResp struct {
	Repo    string       `json:"repo"`
	Changes []string     `json:"changes"`
	Refs    []*store.Ref `json:"refs"`
}

type AuditSink

type AuditSink interface {
	Record(store.AuditEvent)
}

AuditSink receives an AuditEvent for access attempts. The default sink writes to the store's append-only audit_log table; tests can supply a mock.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the VCS protocol handler. It resolves bearer tokens against the central store on every request and enforces repository/branch ACLs.

func New

func New(cs *store.CentralStore, sink AuditSink) *Server

New builds a Server over the given central store. If sink is nil a default store-backed sink is used (writing audit_log). The tokens parameter is gone: tokens are resolved via store.LookupToken on each request.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the HTTP router for this server. It may be mounted directly (e.g. http.Server{Handler: s.Handler()} or embedded in a larger mux).

func (*Server) Router

func (s *Server) Router() *http.ServeMux

Router returns the *http.ServeMux (same as Handler but typed).

func (*Server) SetMaxBody

func (s *Server) SetMaxBody(n int64)

SetMaxBody overrides the request body limit (bytes). Values <= 0 restore the default.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL