6
6
7
7
HERE = os .path .dirname (os .path .abspath (__file__ ))
8
8
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
22
26
23
27
24
28
def _xprahtml5_mappath (path ):
25
29
26
- # always pass the url parameter
30
+ # # always pass the url parameter
27
31
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
30
34
31
35
return path
32
36
@@ -37,49 +41,49 @@ def setup_xprahtml5():
37
41
"""
38
42
from pathlib import Path
39
43
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
42
46
43
47
global _xprahtml5_passwd , _xprahtml5_aeskey
44
48
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
+ #
50
54
# ensure a known secure sockets directory exists, as /run/user/$UID might not be available
51
55
socket_path = os .path .join (gettempdir (), 'xpra_sockets_' + str (os .getuid ()))
52
56
Path (socket_path ).mkdir (mode = 0o700 , parents = True , exist_ok = True )
53
57
logger .info ('Created secure socket directory for Xpra: ' + socket_path )
54
58
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()
83
87
84
88
# create command
85
89
cmd = [
@@ -92,9 +96,9 @@ def _get_random_alphanumeric_string(length):
92
96
# '--exit-with-client=yes', # stop Xpra when the browser disconnects
93
97
'--start=xterm -fa Monospace' ,
94
98
# '--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,
98
102
'--clipboard-direction=both' ,
99
103
'--no-mdns' , # do not advertise the xpra session on the local network
100
104
'--no-bell' ,
@@ -104,7 +108,7 @@ def _get_random_alphanumeric_string(length):
104
108
'--no-notifications' ,
105
109
'--no-systemd-run' , # do not delegated start-cmd to the system wide proxy server instance
106
110
# '--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
108
112
'--no-daemon' , # mandatory
109
113
]
110
114
logger .info ('Xpra command: ' + ' ' .join (cmd ))
@@ -122,6 +126,6 @@ def _get_random_alphanumeric_string(length):
122
126
'enabled' : True ,
123
127
'icon_path' : os .path .join (HERE , 'share/xpra-logo.svg' ),
124
128
'title' : 'Xpra Desktop' ,
125
- 'urlfile' : urlfile ,
129
+ # 'urlfile': urlfile,
126
130
},
127
131
}
0 commit comments