Files
SnarfCode/scripts/inspect_ha_authentik.py

36 lines
1.2 KiB
Python

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"
}
req = urllib.request.Request(f"{AK_BASE}/api/v3/providers/oauth2/", headers=headers)
with urllib.request.urlopen(req, timeout=10, context=ctx) as r:
data = json.loads(r.read().decode())
for p in data.get("results", []):
if "home" in p.get("name", "").lower() or "assistant" in p.get("name", "").lower():
print("Home Assistant Provider:")
print(json.dumps(p, indent=2))
req2 = urllib.request.Request(f"{AK_BASE}/api/v3/providers/proxy/", headers=headers)
with urllib.request.urlopen(req2, timeout=10, context=ctx) as r:
data = json.loads(r.read().decode())
for p in data.get("results", []):
if "home" in p.get("name", "").lower() or "snarfhome" in str(p).lower():
print("Proxy Provider:")
print(json.dumps(p, indent=2))