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
|
||||
# If disabled, TLS certificate will not be checked
|
||||
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 are entered as `IP/FQDN = Port`
|
||||
|
20
vdiclient.py
20
vdiclient.py
@ -19,6 +19,9 @@ class G:
|
||||
#########
|
||||
title = 'VDI Login'
|
||||
backend = 'pve'
|
||||
user = None
|
||||
token_name = None
|
||||
token_value = None
|
||||
totp = False
|
||||
imagefile = None
|
||||
kiosk = False
|
||||
@ -85,6 +88,12 @@ def loadconfig(config_location = None):
|
||||
G.totp = config['Authentication'].getboolean('auth_totp')
|
||||
if 'tls_verify' in config['Authentication']:
|
||||
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:
|
||||
win_popup_button(f'Unable to read supplied configuration:\nNo `Hosts` section defined!', 'OK')
|
||||
return False
|
||||
@ -148,9 +157,10 @@ def setvmlayout(vms):
|
||||
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])])
|
||||
for vm in vms:
|
||||
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.HorizontalSeparator()])
|
||||
if not vm["status"] == "unknown":
|
||||
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.HorizontalSeparator()])
|
||||
layout.append([sg.Button('Logout', font=["Helvetica", 14])])
|
||||
return layout
|
||||
|
||||
@ -264,7 +274,9 @@ def pveauth(username, passwd, totp):
|
||||
authenticated = False
|
||||
if not connected and not authenticated:
|
||||
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)
|
||||
else:
|
||||
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