feat: add various infrastructure and service diagnostic scripts
This commit is contained in:
38
scripts/test_technitium_sso_set.py
Normal file
38
scripts/test_technitium_sso_set.py
Normal file
@@ -0,0 +1,38 @@
|
||||
import paramiko
|
||||
import json
|
||||
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
# Get fresh token
|
||||
stdin, stdout, stderr = ssh.exec_command('k3s kubectl exec -n dns deployment/technitium-dns -- curl -s "http://localhost:5380/api/user/login?user=admin&pass=snarfnetadmin"')
|
||||
data = json.loads(stdout.read().decode())
|
||||
token = data['token']
|
||||
print("Fresh token:", token)
|
||||
|
||||
# Now call api/admin/sso/get
|
||||
stdin, stdout, stderr = ssh.exec_command(f'k3s kubectl exec -n dns deployment/technitium-dns -- curl -s "http://localhost:5380/api/admin/sso/get?token={token}"')
|
||||
get_res = stdout.read().decode()
|
||||
print("SSO get:", get_res)
|
||||
|
||||
# Now call api/admin/sso/set
|
||||
url = (
|
||||
f'"http://localhost:5380/api/admin/sso/set?token={token}'
|
||||
'&ssoEnabled=true'
|
||||
'&ssoClientId=technitium-dns-oidc'
|
||||
'&ssoClientSecret=SnarfNetTechnitiumOIDC2026!'
|
||||
'&ssoMetadataAddress=https://authentik.snarfnet.net/application/o/dns1/.well-known/openid-configuration'
|
||||
'&ssoScopes=openid,profile,email'
|
||||
'&ssoAllowSignup=true'
|
||||
'&ssoAllowSignupOnlyForMappedUsers=false'
|
||||
'&ssoGroupMap=authentik%20Admins:Administrators"'
|
||||
)
|
||||
stdin, stdout, stderr = ssh.exec_command(f'k3s kubectl exec -n dns deployment/technitium-dns -- curl -s {url}')
|
||||
print("SSO set result:", stdout.read().decode())
|
||||
|
||||
# Check get again
|
||||
stdin, stdout, stderr = ssh.exec_command(f'k3s kubectl exec -n dns deployment/technitium-dns -- curl -s "http://localhost:5380/api/admin/sso/get?token={token}"')
|
||||
print("SSO get after set:", stdout.read().decode())
|
||||
|
||||
ssh.close()
|
||||
Reference in New Issue
Block a user