urapt is a self-hostable APT repository server with a companion CLI for pushing and managing Debian .deb packages. Server (urapt-server): - REST API + APT endpoint, SQLite storage (pure-Go modernc driver, no CGO) - .deb files stored content-addressed on disk, reference-counted for dedup - Server-managed RSA-4096 OpenPGP signing key (ProtonMail/go-crypto) - APT indices (Release/InRelease/Packages[.gz/.xz]) generated on demand from the DB, cached in memory, signed with the server key - Full APT model: repositories -> distributions -> components -> architectures - Bearer-token auth for REST; HTTP Basic auth for private-repo APT reads - First registrant becomes admin; repo-scoped permissions (read/write/read-write/admin) plus owner and server-admin roles - Multipart package push with control-field extraction, list/show/delete, pool serving, blob ref-count cleanup - Audit log CLI (urapt): - register/login/logout/whoami, token management - repo/distro/component/arch CRUD, member management - push/pull/ls/show/rm for packages - apt-config helper that emits apt setup commands (key, sources.list, auth.conf for private repos) Packaging & docs: - Dockerfile (multi-stage distroless), docker-compose.yml, sample config - README quick start, architecture overview, config reference, security notes - PLAN.md design blueprint, CHANGELOG.md, GPL-3.0 LICENSE - GitHub Actions CI (test, lint, cross-build for linux/darwin amd64/arm64) - Makefile release target producing static binaries + tarballs + checksums Tests cover the data-access layer, auth/permission checks, APT index generation, .deb parsing, GPG signing, the REST API, and the typed API client. Verified end-to-end on a Raspberry Pi (arm64) pushing and installing a real package.
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package restapi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
apitypes "urapt/shared/api"
|
|
"urapt/shared/httputil"
|
|
"urapt/shared/version"
|
|
)
|
|
|
|
// ServerInfo returns build/setup metadata for the server.
|
|
func (api *API) ServerInfo(w http.ResponseWriter, r *http.Request) {
|
|
users, err := api.Store.ListUsers(r.Context())
|
|
if err != nil {
|
|
httputil.WriteError(w, http.StatusInternalServerError, httputil.CodeInternal, "failed to read users")
|
|
return
|
|
}
|
|
fp := ""
|
|
if api.Signer != nil {
|
|
fp = api.Signer.Fingerprint()
|
|
}
|
|
httputil.WriteJSON(w, http.StatusOK, apitypes.ServerInfo{
|
|
Version: version.Version,
|
|
NeedsSetup: len(users) == 0,
|
|
DefaultKeyFingerprint: fp,
|
|
OpenRegistration: api.Config.OpenRegistration,
|
|
})
|
|
}
|
|
|
|
// ServerPubkey returns the ASCII-armored default signing key.
|
|
func (api *API) ServerPubkey(w http.ResponseWriter, r *http.Request) {
|
|
if api.Signer == nil {
|
|
httputil.WriteError(w, http.StatusServiceUnavailable, httputil.CodeInternal, "no signing key configured")
|
|
return
|
|
}
|
|
pub, err := api.Signer.PublicKeyArmored()
|
|
if err != nil {
|
|
httputil.WriteError(w, http.StatusInternalServerError, httputil.CodeInternal, "failed to read key")
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/pgp-keys")
|
|
w.WriteHeader(http.StatusOK)
|
|
_, _ = w.Write([]byte(pub))
|
|
}
|