feat: add infrastructure diagnostic and monitoring scripts
This commit is contained in:
35
scripts/check_authentik_events.py
Normal file
35
scripts/check_authentik_events.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import urllib.request
|
||||
import ssl
|
||||
import json
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
AK_BASE = "https://authentik.snarfnet.net"
|
||||
AK_TOKEN = "SnarfNetPermanentAutomationToken2026"
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {AK_TOKEN}",
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
}
|
||||
|
||||
# Fetch recent events
|
||||
req = urllib.request.Request(f"{AK_BASE}/api/v3/events/events/?page_size=20", headers=headers)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=10, context=ctx) as r:
|
||||
data = json.loads(r.read().decode())
|
||||
for ev in data.get("results", []):
|
||||
action = ev.get("action")
|
||||
user = ev.get("user", {}).get("username")
|
||||
context = ev.get("context", {})
|
||||
created = ev.get("created")
|
||||
print(f"[{created}] Action: {action} | User: {user}")
|
||||
if "message" in context or "redirect_uri" in str(context) or "error" in str(context) or "client_id" in str(context):
|
||||
print(f" Context: {json.dumps(context, indent=2)}")
|
||||
except Exception as e:
|
||||
print(f"Error querying Authentik: {e}")
|
||||
Reference in New Issue
Block a user