Clean up: remove stale scripts/docs, fix debug prints, update PLAN.md
Deploy Dashboard / deploy (push) Successful in 37s
Deploy Dashboard / deploy (push) Successful in 37s
This commit is contained in:
@@ -102,7 +102,7 @@ async def monitor_containers():
|
||||
)
|
||||
previous_states[c.id] = current_status
|
||||
except Exception as e:
|
||||
print(f"Error in container monitor: {e}")
|
||||
logging.getLogger(__name__).error("Error in container monitor: %s", e)
|
||||
|
||||
await asyncio.sleep(60)
|
||||
|
||||
|
||||
@@ -11,11 +11,13 @@ from slowapi.util import get_remote_address
|
||||
import jwt
|
||||
import config
|
||||
import auth
|
||||
import logging
|
||||
import pyotp
|
||||
from webauthn import generate_registration_options, verify_registration_response, generate_authentication_options, verify_authentication_response
|
||||
from webauthn.helpers.structs import PublicKeyCredentialDescriptor, UserVerificationRequirement
|
||||
from webauthn.helpers import bytes_to_base64url, base64url_to_bytes, options_to_json
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter()
|
||||
limiter = Limiter(key_func=get_remote_address)
|
||||
|
||||
@@ -43,9 +45,9 @@ class Verify2FARequest(BaseModel):
|
||||
code: str
|
||||
|
||||
async def send_failed_login_alert(ip_address: str, username: str, reason: str):
|
||||
print(f"Triggering Telegram alert for {username} from {ip_address}: {reason}", flush=True)
|
||||
logger.info("Triggering Telegram alert for %s from %s: %s", username, ip_address, reason)
|
||||
if not config.TELEGRAM_BOT_TOKEN or not config.TELEGRAM_CHAT_ID:
|
||||
print("Skipping Telegram alert: missing config", flush=True)
|
||||
logger.warning("Skipping Telegram alert: missing config")
|
||||
return
|
||||
msg = f"🚨 *Dashboard Security Alert* 🚨\nFailed login attempt detected.\n\n👤 User: `{username}`\n🌐 IP: `{ip_address}`\n❌ Reason: {reason}"
|
||||
try:
|
||||
@@ -59,9 +61,9 @@ async def send_failed_login_alert(ip_address: str, username: str, reason: str):
|
||||
data={"chat_id": config.TELEGRAM_CHAT_ID, "text": msg, "parse_mode": "Markdown"},
|
||||
timeout=10.0
|
||||
)
|
||||
print(f"Telegram alert sent, status: {res.status_code}", flush=True)
|
||||
logger.info("Telegram alert sent, status: %s", res.status_code)
|
||||
except Exception as e:
|
||||
print(f"Failed to send Telegram alert: {e}", flush=True)
|
||||
logger.warning("Failed to send Telegram alert: %s", e)
|
||||
|
||||
@router.post("/login", response_model=Token)
|
||||
@limiter.limit("5/minute")
|
||||
|
||||
Reference in New Issue
Block a user