50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
import paramiko
|
|
|
|
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("140.44.4.11", username="root", key_filename=SSH_KEY, timeout=10)
|
|
|
|
def k8s(cmd):
|
|
full_cmd = f"kubectl {cmd}"
|
|
_, o, e = c.exec_command(full_cmd)
|
|
return o.read().decode().strip(), e.read().decode().strip()
|
|
|
|
pod = "authentik-server-cd7d9b949-vfl2m"
|
|
|
|
# Inspect applications in Authentik
|
|
py_query = """
|
|
python3 - << 'PYEOF'
|
|
from authentik.core.models import Application
|
|
from authentik.providers.proxy.models import ProxyProvider
|
|
from authentik.policies.models import PolicyBindingModel, Policy
|
|
|
|
print("=== APPLICATIONS ===")
|
|
for app in Application.objects.all():
|
|
print(f"App: {app.name} (slug: {app.slug})")
|
|
print(f" Provider: {app.provider}")
|
|
|
|
print("\n=== PROXY PROVIDERS ===")
|
|
for p in ProxyProvider.objects.all():
|
|
print(f"Provider: {p.name}")
|
|
print(f" External host: {p.external_host}")
|
|
print(f" Internal host: {p.internal_host}")
|
|
print(f" Mode: {p.mode}")
|
|
|
|
print("\n=== POLICIES ===")
|
|
for pol in Policy.objects.all():
|
|
print(f"Policy: {pol.name} ({pol.__class__.__name__})")
|
|
|
|
print("\n=== POLICY BINDINGS ===")
|
|
for pb in PolicyBindingModel.objects.all():
|
|
print(f"Binding: {pb.target} -> {pb.policy} (enabled={pb.enabled}, order={pb.order})")
|
|
PYEOF
|
|
"""
|
|
|
|
out, err = k8s(f"exec -n infra {pod} -c authentik-server -- {py_query}")
|
|
print(out)
|
|
if err: print("ERR:", err)
|
|
|
|
c.close()
|
|
|