requireCriticalConfigAuth guards script-plugin configs: API key passes; session users must supply the admin password.
(w http.ResponseWriter, r *http.Request, authObject auth.Auth, req configReq)
| 244 | |
| 245 | // requireCriticalConfigAuth guards script-plugin configs: API key passes; session users must supply the admin password. |
| 246 | func requireCriticalConfigAuth(w http.ResponseWriter, r *http.Request, authObject auth.Auth, req configReq) bool { |
| 247 | if authObject.GetAuthMode() == auth.Disabled || !configHasCriticalPlugin(req) { |
| 248 | return true |
| 249 | } |
| 250 | if key := apiKeyFromRequest(r); key != "" && authObject.ValidateApiKey(key) { |
| 251 | return true |
| 252 | } |
| 253 | if !authObject.IsAdminPasswordValid(r.Header.Get("X-Admin-Password")) { |
| 254 | jsonError(w, http.StatusPreconditionRequired, errors.New("admin password required")) |
| 255 | return false |
| 256 | } |
| 257 | return true |
| 258 | } |
| 259 | |
| 260 | // ensureDbAuth guards /db/ endpoints: API key Bearer passes directly; |
| 261 | // session users must also supply the admin password in X-Admin-Password header. |