MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / admin_validator

Function admin_validator

src/octoprint/server/util.py:406–423  ·  view source on GitHub ↗

Validates that the given request is made by an admin user, identified either by API key or existing Flask session. Must be executed in an existing Flask request context! :param request: The Flask request object

(request)

Source from the content-addressed store, hash-verified

404
405
406def admin_validator(request):
407 """
408 Validates that the given request is made by an admin user, identified either by API key or existing Flask
409 session.
410
411 Must be executed in an existing Flask request context!
412
413 :param request: The Flask request object
414 """
415
416 apikey = getApiKey(request)
417 if settings().get(["api", "enabled"]) and apikey is not None:
418 user = getUserForApiKey(apikey)
419 else:
420 user = current_user
421
422 if user is None or not user.is_authenticated or not user.is_admin():
423 raise HTTPError(403)
424
425
426#~~ user access validator for use with tornado

Callers

nothing calls this directly

Calls 5

settingsFunction · 0.90
getApiKeyFunction · 0.85
getUserForApiKeyFunction · 0.85
is_adminMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected