MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _parse_toml_basic

Function _parse_toml_basic

webapp_modern.py:10694–10734  ·  view source on GitHub ↗

Minimal TOML parser for reading simple config files when tomlkit is unavailable.

(filepath)

Source from the content-addressed store, hash-verified

10692 _auth_attempts[ip] = attempts
10693 if len(attempts) >= _AUTH_LOCKOUT_THRESHOLD:
10694 retry_after = int(_AUTH_LOCKOUT_WINDOW - (now - attempts[0])) + 1
10695 return True, max(retry_after, 1)
10696 return False, 0
10697
10698
10699def _auth_record_failure(ip):
10700 with _auth_attempts_lock:
10701 _auth_attempts.setdefault(ip, []).append(time.time())
10702
10703
10704def _auth_clear_failures(ip):
10705 with _auth_attempts_lock:
10706 _auth_attempts.pop(ip, None)
10707
10708
10709@app.route('/api/auth/login', methods=['POST'])
10710def auth_login():
10711 """Login with username and password."""
10712 ip = _auth_client_ip()
10713 limited, retry_after = _auth_rate_limited(ip)
10714 if limited:
10715 response = jsonify({'success': False, 'error': 'Too many failed attempts. Try again later.',
10716 'retry_after': retry_after})
10717 response.headers['Retry-After'] = str(retry_after)
10718 return response, 429
10719
10720 data = request.get_json()
10721 if not data:
10722 return jsonify({'success': False, 'error': 'No data provided'}), 400
10723
10724 username = data.get('username', '').strip()
10725 password = data.get('password', '')
10726
10727 result = auth_mgr.login(username, password)
10728 if result['success']:
10729 _auth_clear_failures(ip)
10730 session['authenticated'] = True
10731 session['username'] = username
10732 session['login_time'] = time.time()
10733 session.permanent = True
10734 return jsonify(result)
10735 else:
10736 _auth_record_failure(ip)
10737 return jsonify(result), 401

Callers 1

get_pwnagotchi_configFunction · 0.85

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected