add ability to use API tokens
This commit is contained in:
parent
f161129b9d
commit
f048505000
@ -17,6 +17,12 @@ auth_backend = pve
|
|||||||
auth_totp = false
|
auth_totp = false
|
||||||
# If disabled, TLS certificate will not be checked
|
# If disabled, TLS certificate will not be checked
|
||||||
tls_verify = false
|
tls_verify = false
|
||||||
|
# User name
|
||||||
|
#user = user
|
||||||
|
# API Token Name
|
||||||
|
#token_name = dvi
|
||||||
|
#API Token Value
|
||||||
|
#token_value = xxx-x-x-x-xxx
|
||||||
|
|
||||||
[Hosts]
|
[Hosts]
|
||||||
# Hosts are entered as `IP/FQDN = Port`
|
# Hosts are entered as `IP/FQDN = Port`
|
||||||
|
14
vdiclient.py
14
vdiclient.py
@ -19,6 +19,9 @@ class G:
|
|||||||
#########
|
#########
|
||||||
title = 'VDI Login'
|
title = 'VDI Login'
|
||||||
backend = 'pve'
|
backend = 'pve'
|
||||||
|
user = None
|
||||||
|
token_name = None
|
||||||
|
token_value = None
|
||||||
totp = False
|
totp = False
|
||||||
imagefile = None
|
imagefile = None
|
||||||
kiosk = False
|
kiosk = False
|
||||||
@ -85,6 +88,12 @@ def loadconfig(config_location = None):
|
|||||||
G.totp = config['Authentication'].getboolean('auth_totp')
|
G.totp = config['Authentication'].getboolean('auth_totp')
|
||||||
if 'tls_verify' in config['Authentication']:
|
if 'tls_verify' in config['Authentication']:
|
||||||
G.verify_ssl = config['Authentication'].getboolean('tls_verify')
|
G.verify_ssl = config['Authentication'].getboolean('tls_verify')
|
||||||
|
if 'user' in config['Authentication']:
|
||||||
|
G.user = config['Authentication']['user']
|
||||||
|
if 'token_name' in config['Authentication']:
|
||||||
|
G.token_name = config['Authentication']['token_name']
|
||||||
|
if 'token_value' in config['Authentication']:
|
||||||
|
G.token_value = config['Authentication']['token_value']
|
||||||
if not 'Hosts' in config:
|
if not 'Hosts' in config:
|
||||||
win_popup_button(f'Unable to read supplied configuration:\nNo `Hosts` section defined!', 'OK')
|
win_popup_button(f'Unable to read supplied configuration:\nNo `Hosts` section defined!', 'OK')
|
||||||
return False
|
return False
|
||||||
@ -148,6 +157,7 @@ def setvmlayout(vms):
|
|||||||
layout.append([sg.Text(G.title, size =(30, 1), justification='c', font=["Helvetica", 18])])
|
layout.append([sg.Text(G.title, size =(30, 1), justification='c', font=["Helvetica", 18])])
|
||||||
layout.append([sg.Text('Please select a desktop instance to connect to', size =(40, 1), justification='c', font=["Helvetica", 10])])
|
layout.append([sg.Text('Please select a desktop instance to connect to', size =(40, 1), justification='c', font=["Helvetica", 10])])
|
||||||
for vm in vms:
|
for vm in vms:
|
||||||
|
if not vm["status"] == "unknown":
|
||||||
connkeyname = f'-CONN|{vm["vmid"]}-'
|
connkeyname = f'-CONN|{vm["vmid"]}-'
|
||||||
layout.append([sg.Text(vm['name'], font=["Helvetica", 14]), sg.Button('Connect', font=["Helvetica", 14], key=connkeyname)])
|
layout.append([sg.Text(vm['name'], font=["Helvetica", 14]), sg.Button('Connect', font=["Helvetica", 14], key=connkeyname)])
|
||||||
layout.append([sg.HorizontalSeparator()])
|
layout.append([sg.HorizontalSeparator()])
|
||||||
@ -264,7 +274,9 @@ def pveauth(username, passwd, totp):
|
|||||||
authenticated = False
|
authenticated = False
|
||||||
if not connected and not authenticated:
|
if not connected and not authenticated:
|
||||||
try:
|
try:
|
||||||
if totp:
|
if G.token_name and G.token_value:
|
||||||
|
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}',token_name=G.token_name,token_value=G.token_value, verify_ssl=G.verify_ssl, port=port)
|
||||||
|
elif totp:
|
||||||
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}', otp=totp, password=passwd, verify_ssl=G.verify_ssl, port=port)
|
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}', otp=totp, password=passwd, verify_ssl=G.verify_ssl, port=port)
|
||||||
else:
|
else:
|
||||||
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}', password=passwd, verify_ssl=G.verify_ssl, port=port)
|
G.proxmox = proxmoxer.ProxmoxAPI(host, user=f'{username}@{G.backend}', password=passwd, verify_ssl=G.verify_ssl, port=port)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user