Skip to content

Commit 71e6a5f

Browse files
authored
Support password changing via cli args (#4)
Signed-off-by: Tully Foote <[email protected]>
1 parent 9805578 commit 71e6a5f

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Setup virtualenv with this installed or developed
1010

1111
Go to http://localhost:8080/vnc.html
1212

13+
It is highly recommended to change the default username and password!
14+
1315
testing username and password are
1416

15-
testuser:testpassword
17+
novnc_example_user:novnc_example_password_$Insecure_$Changeme!!

novnc_rocker/novnc.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ def get_preamble(self, cli_args):
2323
return ''
2424

2525
def get_files(self, cli_args):
26-
file_list = ['supervisor.conf', 'self.pem', '.htpasswd', 'nginx.conf']
26+
file_list = ['supervisor.conf', 'self.pem', 'nginx.conf']
2727
files = {}
2828
for f in file_list:
2929
files['%s' % f] = pkgutil.get_data(
3030
'novnc_rocker',
3131
'templates/%s' % f).decode('utf-8')
32-
template_list = ['novnc.conf', 'rproxy-nginx-site']
32+
template_list = ['novnc.conf', 'rproxy-nginx-site', '.htpasswd']
3333
for f in template_list:
3434
files['%s' % f] = em.expand(
3535
pkgutil.get_data(
@@ -57,4 +57,14 @@ def register_arguments(parser, defaults={}):
5757
action='store',
5858
type=int,
5959
default=defaults.get('novnc-port', 8080),
60-
help="what port to use for novnc")
60+
help="what port to use for novnc")
61+
parser.add_argument('--novnc-user',
62+
action='store',
63+
type=str,
64+
default=defaults.get('novnc-user', 'novnc_example_user'),
65+
help="what username to use for novnc")
66+
parser.add_argument('--novnc-password',
67+
action='store',
68+
type=str,
69+
default=defaults.get('novnc-user', 'novnc_example_password_$Insecure_$Changeme!!'),
70+
help="what password to use for novnc")

novnc_rocker/templates/.htpasswd

-1
This file was deleted.

novnc_rocker/templates/.htpasswd.em

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@{import bcrypt}@
2+
@(novnc_user):@(bcrypt.hashpw(novnc_password.encode('utf8'), bcrypt.gensalt(rounds=10)).decode())

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
url="https://github.com/tfoote/novnc-rocker",
2222
license='Apache 2.0',
2323
install_requires=[
24+
'bcrypt',
2425
'rocker',
2526
],
2627
entry_points={

0 commit comments

Comments
 (0)