Skip to content

Commit c0224b5

Browse files
committed
update to 0.3.0 but comment password/encryption support
1 parent b7987b7 commit c0224b5

File tree

2 files changed

+61
-57
lines changed

2 files changed

+61
-57
lines changed

jupyter_xprahtml5_proxy/__init__.py

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,31 @@
66

77
HERE = os.path.dirname(os.path.abspath(__file__))
88

9-
10-
def _xprahtml5_urlparams():
11-
from getpass import getuser
12-
13-
url_params = '?' + '&'.join([
14-
'username=' + getuser(),
15-
'password=' + _xprahtml5_passwd,
16-
'encryption=AES',
17-
'key=' + _xprahtml5_aeskey,
18-
'sharing=true',
19-
])
20-
21-
return url_params
9+
### Why are so many lines commented?
10+
# Currently jupyter-server-proxy does not support url-parameters, yet.
11+
# A pull request is waiting to be merged: https://github.com/jupyterhub/jupyter-server-proxy/pull/226
12+
# Be aware! Until then, we need to comment the support for password and encryption.
13+
14+
# def _xprahtml5_urlparams():
15+
# from getpass import getuser
16+
#
17+
# url_params = '?' + '&'.join([
18+
# 'username=' + getuser(),
19+
# 'password=' + _xprahtml5_passwd,
20+
# 'encryption=AES',
21+
# 'key=' + _xprahtml5_aeskey,
22+
# 'sharing=true',
23+
# ])
24+
#
25+
# return url_params
2226

2327

2428
def _xprahtml5_mappath(path):
2529

26-
# always pass the url parameter
30+
# # always pass the url parameter
2731
if path in ('/', '/index.html', ):
28-
url_params = _xprahtml5_urlparams()
29-
path = '/index.html' + url_params
32+
# url_params = _xprahtml5_urlparams()
33+
path = '/index.html' # + url_params
3034

3135
return path
3236

@@ -37,49 +41,49 @@ def setup_xprahtml5():
3741
"""
3842
from pathlib import Path
3943
from tempfile import gettempdir, mkstemp
40-
from random import choice
41-
from string import ascii_letters, digits
44+
# from random import choice
45+
# from string import ascii_letters, digits
4246

4347
global _xprahtml5_passwd, _xprahtml5_aeskey
4448

45-
# password generator
46-
def _get_random_alphanumeric_string(length):
47-
letters_and_digits = ascii_letters + digits
48-
return (''.join((choice(letters_and_digits) for i in range(length))))
49-
49+
# # password generator
50+
# def _get_random_alphanumeric_string(length):
51+
# letters_and_digits = ascii_letters + digits
52+
# return (''.join((choice(letters_and_digits) for i in range(length))))
53+
#
5054
# ensure a known secure sockets directory exists, as /run/user/$UID might not be available
5155
socket_path = os.path.join(gettempdir(), 'xpra_sockets_' + str(os.getuid()))
5256
Path(socket_path).mkdir(mode=0o700, parents=True, exist_ok=True)
5357
logger.info('Created secure socket directory for Xpra: ' + socket_path)
5458

55-
# generate file with random one-time-password
56-
_xprahtml5_passwd = _get_random_alphanumeric_string(16)
57-
try:
58-
fd_passwd, fpath_passwd = mkstemp()
59-
logger.info('Created secure password file for Xpra: ' + fpath_passwd)
60-
61-
with open(fd_passwd, 'w') as f:
62-
f.write(_xprahtml5_passwd)
63-
64-
except Exception:
65-
logger.error("Passwd generation in temp file FAILED")
66-
raise FileNotFoundError("Passwd generation in temp file FAILED")
67-
68-
# generate file with random encryption key
69-
_xprahtml5_aeskey = _get_random_alphanumeric_string(16)
70-
try:
71-
fd_aeskey, fpath_aeskey = mkstemp()
72-
logger.info('Created secure encryption key file for Xpra: ' + fpath_aeskey)
73-
74-
with open(fd_aeskey, 'w') as f:
75-
f.write(_xprahtml5_aeskey)
76-
77-
except Exception:
78-
logger.error("Encryption key generation in temp file FAILED")
79-
raise FileNotFoundError("Encryption key generation in temp file FAILED")
80-
81-
# launchers url file including url parameters
82-
urlfile = 'index.html' + _xprahtml5_urlparams()
59+
# # generate file with random one-time-password
60+
# _xprahtml5_passwd = _get_random_alphanumeric_string(16)
61+
# try:
62+
# fd_passwd, fpath_passwd = mkstemp()
63+
# logger.info('Created secure password file for Xpra: ' + fpath_passwd)
64+
#
65+
# with open(fd_passwd, 'w') as f:
66+
# f.write(_xprahtml5_passwd)
67+
#
68+
# except Exception:
69+
# logger.error("Passwd generation in temp file FAILED")
70+
# raise FileNotFoundError("Passwd generation in temp file FAILED")
71+
#
72+
# # generate file with random encryption key
73+
# _xprahtml5_aeskey = _get_random_alphanumeric_string(16)
74+
# try:
75+
# fd_aeskey, fpath_aeskey = mkstemp()
76+
# logger.info('Created secure encryption key file for Xpra: ' + fpath_aeskey)
77+
#
78+
# with open(fd_aeskey, 'w') as f:
79+
# f.write(_xprahtml5_aeskey)
80+
#
81+
# except Exception:
82+
# logger.error("Encryption key generation in temp file FAILED")
83+
# raise FileNotFoundError("Encryption key generation in temp file FAILED")
84+
#
85+
# # launchers url file including url parameters
86+
# urlfile = 'index.html' + _xprahtml5_urlparams()
8387

8488
# create command
8589
cmd = [
@@ -92,9 +96,9 @@ def _get_random_alphanumeric_string(length):
9296
# '--exit-with-client=yes', # stop Xpra when the browser disconnects
9397
'--start=xterm -fa Monospace',
9498
# '--start-child=xterm', '--exit-with-children',
95-
'--tcp-auth=file:filename=' + fpath_passwd,
96-
'--tcp-encryption=AES',
97-
'--tcp-encryption-keyfile=' + fpath_aeskey,
99+
# '--tcp-auth=file:filename=' + fpath_passwd,
100+
# '--tcp-encryption=AES',
101+
# '--tcp-encryption-keyfile=' + fpath_aeskey,
98102
'--clipboard-direction=both',
99103
'--no-mdns', # do not advertise the xpra session on the local network
100104
'--no-bell',
@@ -104,7 +108,7 @@ def _get_random_alphanumeric_string(length):
104108
'--no-notifications',
105109
'--no-systemd-run', # do not delegated start-cmd to the system wide proxy server instance
106110
# '--dpi=96', # only needed if Xserver does not support dynamic dpi change
107-
'--sharing', # this allows to open the desktop in multiple browsers at the same time
111+
# '--sharing', # this allows to open the desktop in multiple browsers at the same time
108112
'--no-daemon', # mandatory
109113
]
110114
logger.info('Xpra command: ' + ' '.join(cmd))
@@ -122,6 +126,6 @@ def _get_random_alphanumeric_string(length):
122126
'enabled': True,
123127
'icon_path': os.path.join(HERE, 'share/xpra-logo.svg'),
124128
'title': 'Xpra Desktop',
125-
'urlfile': urlfile,
129+
# 'urlfile': urlfile,
126130
},
127131
}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
with open(path.join(HERE, 'README.md'), 'r', encoding = 'utf-8') as fh:
66
long_description = fh.read()
77

8-
version='0.3.0'
8+
version='0.2.3'
99
setup(
1010
name = 'jupyter-xprahtml5-proxy',
1111
version = version,

0 commit comments

Comments
 (0)