bugy / script-server

Web UI for your scripts with execution management
Other
1.61k stars 249 forks source link

HTPasswd issue on Windows #429

Closed billybenson closed 3 years ago

billybenson commented 3 years ago

Hi @bugy - I can't seem to get htpassword to work. This is the error when I run launcher:

[2021-04-12 16:08:56,400 [root.INFO] Starting Script Server, v1.17.0-master@61a1c9f Traceback (most recent call last): File "C:\script-server\launcher.py", line 11, in <module> main.main() File "src\main.py", line 81, in main server_config = server_conf.from_json(SERVER_CONF_PATH, TEMP_FOLDER) File "src\model\server_conf.py", line 65, in from_json json_object = json.loads(file_content) File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Invalid \escape: line 6 column 23 (char 100)``](url)

I have added to my conf file already:

"auth": { "type": "htpasswd", "htpasswd_path": "path/to/.htpasswd" }

bugy commented 3 years ago

According to the error, json file is corrupted. Most probably you have to escape slashes in the path, i.e. \/ instead of /

You can try editing the json file in any json editor (for example online https://jsonformatter.org/json-editor) and it will show you the exact error

billybenson commented 3 years ago

Thanks, you were correct. It is now working as expected with the correct slashes in the path to the file.

I cannot edit my scripts now when browsing to http://localhost:5000/admin.html.

I receive 403 forbidden error. Do I need to add additional config to the conf.json file for this?

bugy commented 3 years ago

Yes, please check https://github.com/bugy/script-server/wiki/Server-configuration#--admin_users, example usage:

{
  "access": {
    "admin_users": [ "user1", "user2" ],
  }
}