MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / checkBootstrapToken

Method checkBootstrapToken

internal/server/bootstrap.go:170–182  ·  view source on GitHub ↗

checkBootstrapToken validates the X-Bootstrap-Token header on r against the in-memory token using a constant-time comparison. Returns false if no token is configured or the header is missing/wrong. Caller MUST hold s.bootstrapMu — handleBootstrap takes the lock for the entire validate-token → check

(r *http.Request)

Source from the content-addressed store, hash-verified

168// the entire validate-token → check-UserCount → CreateUser → consume
169// sequence (F5).
170func (s *Server) checkBootstrapToken(r *http.Request) bool {
171 if s.bootstrapToken.IsZero() {
172 return false
173 }
174 provided := r.Header.Get(BootstrapTokenHeader)
175 if provided == "" {
176 return false
177 }
178 // Constant-time comparison so the response time can't leak
179 // per-character feedback to an attacker grinding through guesses. Both
180 // sides are non-empty here: an empty Secret equals an empty string.
181 return s.bootstrapToken.Equal(provided)
182}
183
184// SetBypassSetupToken wires the operator's PAD_BYPASS_SETUP_TOKEN choice
185// into the Server. When true, handleBootstrap accepts a self-host

Calls 3

EqualMethod · 0.80
GetMethod · 0.65
IsZeroMethod · 0.45