refuseAPITokenForAdmin guards every /api/v1/admin route (BUG-3361). An admin's PAT carries their identity, not their platform authority: one used to be enough to register an account, promote it to admin, sign in as it, and reset any password. A browser or `pad auth login` CLI session is required, th
(next http.Handler)
| 901 | // required, the line BUG-2890 drew for token minting. The cloud sidecar |
| 902 | // authenticates with the cloud secret, never a PAT, so it is unaffected. |
| 903 | func (s *Server) refuseAPITokenForAdmin(next http.Handler) http.Handler { |
| 904 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 905 | if isAPITokenAuth(r) && !s.adminAcceptsAPITokens() { |
| 906 | writeError(w, http.StatusForbidden, "session_required", |
| 907 | "Platform administration requires an interactive session, not an API token") |
| 908 | return |
| 909 | } |
| 910 | next.ServeHTTP(w, r) |
| 911 | }) |
| 912 | } |
| 913 | |
| 914 | // Init2FASecret loads the 2FA challenge signing key from platform_settings. |
| 915 | // If no key exists (first run), a new random key is generated and persisted. |
nothing calls this directly
no test coverage detected