diff --git a/modules/shared.py b/modules/shared.py index 38d24faee599ab758e44e958d73485b5308c6ae0..b9c2f0453bc205c870e771a08cba7c8f1a3d45b1 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -43,6 +43,7 @@ parser.add_argument("--ui-config-file", type=str, help="filename to use for ui c parser.add_argument("--hide-ui-dir-config", action='store_true', help="hide directory configuration from webui", default=False) parser.add_argument("--ui-settings-file", type=str, help="filename to use for ui settings", default=os.path.join(script_path, 'config.json')) parser.add_argument("--gradio-debug", action='store_true', help="launch gradio with --debug option") +parser.add_argument("--auth", type=str, help='set gradio authentication like "username:password"; or comma-delimit multiple like "u1:p1,u2:p2,u3:p3"', default=None) cmd_opts = parser.parse_args() diff --git a/webui.py b/webui.py index 35c8362b23fe3ccb78cf04c14222f72cd62efd8d..2b8dedc7d5693ce09b3fc9d87c9beb4ad07e370b 100644 --- a/webui.py +++ b/webui.py @@ -115,7 +115,8 @@ def webui(): run_pnginfo=modules.extras.run_pnginfo ) - demo.launch(share=cmd_opts.share, server_name="0.0.0.0" if cmd_opts.listen else None, server_port=cmd_opts.port, debug=cmd_opts.gradio_debug) + auth = [tuple(cred.split(':')) for cred in cmd_opts.auth.strip('"').split(',')] if cmd_opts.auth else None + demo.launch(share=cmd_opts.share, server_name="0.0.0.0" if cmd_opts.listen else None, server_port=cmd_opts.port, debug=cmd_opts.gradio_debug, auth=auth) if __name__ == "__main__":