47 lines
1.7 KiB
Python
47 lines
1.7 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
|
|
|
|
token = "SnarfNetPermanentAutomationToken2026"
|
|
headers = {
|
|
"Authorization": f"Bearer {token}",
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
def api_call(url, method="GET", payload=None):
|
|
data = json.dumps(payload).encode('utf-8') if payload else None
|
|
req = urllib.request.Request(url, headers=headers, data=data, method=method)
|
|
try:
|
|
with urllib.request.urlopen(req, context=ctx, timeout=8) as resp:
|
|
return json.loads(resp.read().decode('utf-8'))
|
|
except urllib.error.HTTPError as e:
|
|
print(f"API Error {e.code} on {method} {url}: {e.read().decode('utf-8')}")
|
|
return None
|
|
|
|
# Update Provider 24 to forward_domain with cookie_domain snarfnet.net
|
|
payload = {
|
|
"mode": "forward_domain",
|
|
"external_host": "https://authentik.snarfnet.net",
|
|
"cookie_domain": "snarfnet.net",
|
|
"redirect_uris": [
|
|
{
|
|
"matching_mode": "strict",
|
|
"url": "https://authentik.snarfnet.net/outpost.goauthentik.io/callback?X-authentik-auth-callback=true"
|
|
}
|
|
]
|
|
}
|
|
|
|
res24 = api_call("https://authentik.snarfnet.net/api/v3/providers/proxy/24/", method="PATCH", payload=payload)
|
|
print("Updated Provider 24:", res24.get('name'), "| Mode:", res24.get('mode'), "| Cookie Domain:", res24.get('cookie_domain'))
|
|
|
|
res12 = api_call("https://authentik.snarfnet.net/api/v3/providers/proxy/12/", method="PATCH", payload=payload)
|
|
print("Updated Provider 12:", res12.get('name'), "| Mode:", res12.get('mode'), "| Cookie Domain:", res12.get('cookie_domain'))
|
|
|