feat(sync): paginate Android sync with change tokens
Lint / Lint (push) Successful in 1m8s
Tests / Go backend (push) Failing after 1m23s
Tests / Dashboard checks (push) Failing after 38s
Docker / Docker Build & Push (push) Failing after 6m29s

This commit is contained in:
Gabriel20xx committed 2026-10-20 15:27:53 +00:00
1 parent 0ff94f9b10
commit 97c237be80
76 files changed
+3401 -851

No files matched your search

+30 -3
View File
@@ -18,8 +18,35 @@ import (
"net/url"
"strings"
"sync"
"unicode/utf8"
)
// MinInternalSecretLength is the shortest SECRET a service accepts for its internal routes.
const MinInternalSecretLength = 16
// exampleInternalSecrets are the placeholders shipped in .env.example files, plus the bare variable
// name. They are public, so they never gate a route.
var exampleInternalSecrets = map[string]bool{
"SECRET": true,
"change-me-to-a-long-random-value": true,
}
// InternalSecretUsable reports whether secret is strong enough to gate an internal route: at least
// MinInternalSecretLength characters and not an example placeholder. Length counts characters, as
// the Python and Node helpers do, not bytes.
func InternalSecretUsable(secret string) bool {
return utf8.RuneCountInString(secret) >= MinInternalSecretLength && !exampleInternalSecrets[secret]
}
// InternalSecretMatches reports whether presented is the configured secret. A secret that is not
// usable (see InternalSecretUsable) never matches, and the comparison is constant-time.
func InternalSecretMatches(presented, secret string) bool {
if !InternalSecretUsable(secret) {
return false
}
return subtle.ConstantTimeCompare([]byte(presented), []byte(secret)) == 1
}
// Info is AuthGuard's, CarrierNode's, and ProjectConfigurator's current base URL(s), as pushed by
// ProjectConfigurator.
type Info struct {
@@ -178,11 +205,11 @@ func normalizeInfo(info Info) Info {
// ProjectConfigurator calls to push a fresh Info: mount it at that path (see
// ProjectConfigurator/README.md) behind a secret check for this service's own
// SECRET (the same value ProjectConfigurator and CarrierNode were configured
// with - an empty secret refuses every caller, the same fail-closed default ProjectConfigurator's
// own internal-auth-gated routes use).
// with - a secret that is not usable (see InternalSecretUsable) refuses every caller, the same
// fail-closed default ProjectConfigurator's own internal-auth-gated routes use).
func Handler(secret string, store *Store) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if secret == "" || subtle.ConstantTimeCompare([]byte(r.Header.Get("X-Internal-Auth")), []byte(secret)) != 1 {
if !InternalSecretMatches(r.Header.Get("X-Internal-Auth"), secret) {
writeError(w, http.StatusUnauthorized, "internal service authentication required")
return
}