mirror of
https://github.com/tmdinosaurcenter/kiosk-guestbook.git
synced 2026-06-04 03:50:14 -06:00
feat: add hardened HTTP Basic Auth for admin interface
This commit is contained in:
@@ -181,9 +181,12 @@ def index():
|
||||
def require_admin_auth(f):
|
||||
@wraps(f)
|
||||
def decorated(*args, **kwargs):
|
||||
admin_user = os.environ.get('ADMIN_USER')
|
||||
admin_password = os.environ.get('ADMIN_PASSWORD')
|
||||
if not admin_user or not admin_password:
|
||||
logger.error("ADMIN_USER and ADMIN_PASSWORD must be set to enable the admin interface.")
|
||||
abort(503)
|
||||
auth = request.authorization
|
||||
admin_user = os.environ.get('ADMIN_USER', '')
|
||||
admin_password = os.environ.get('ADMIN_PASSWORD', '')
|
||||
if not auth or auth.username != admin_user or auth.password != admin_password:
|
||||
return Response(
|
||||
'Authentication required.',
|
||||
|
||||
Reference in New Issue
Block a user