feat: add various infrastructure check and automation scripts
This commit is contained in:
28
scripts/check_authentik_stdin.py
Normal file
28
scripts/check_authentik_stdin.py
Normal file
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
|
||||
_, o, _ = c.exec_command("kubectl exec -n infra authentik-postgresql-0 -- cat /opt/bitnami/postgresql/secrets/password")
|
||||
pw = o.read().decode().strip()
|
||||
|
||||
def run_sql(sql):
|
||||
cmd = f"kubectl exec -i -n infra authentik-postgresql-0 -- /bin/bash -c 'export PGPASSWORD={pw}; psql -U authentik -d authentik'"
|
||||
stdin, stdout, stderr = c.exec_command(cmd)
|
||||
stdin.write(sql + "\n")
|
||||
stdin.close()
|
||||
return stdout.read().decode().strip()
|
||||
|
||||
print("--- APPLICATIONS ---")
|
||||
print(run_sql("SELECT name, slug FROM authentik_core_application;"))
|
||||
|
||||
print("\n--- PROXY PROVIDERS ---")
|
||||
print(run_sql("SELECT name, external_host, mode FROM authentik_providers_proxy_proxyprovider;"))
|
||||
|
||||
print("\n--- EXPRESSION POLICIES ---")
|
||||
print(run_sql("SELECT name, expression FROM authentik_policies_expression_expressionpolicy;"))
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user