From 530b96bc808ea84418078b2be51fc30cbbefb4c9 Mon Sep 17 00:00:00 2001 From: Min RK Date: Sun, 15 May 2022 20:27:46 +0200 Subject: [PATCH] implement password_required check in LegacyIdentityProvider previous implementation was on ServerApp --- jupyter_server/auth/identity.py | 7 +++++++ tests/auth/test_login.py | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jupyter_server/auth/identity.py b/jupyter_server/auth/identity.py index 805148da87..2431eaf0d8 100644 --- a/jupyter_server/auth/identity.py +++ b/jupyter_server/auth/identity.py @@ -692,4 +692,11 @@ def validate_security( app: ServerApp, ssl_options: dict | None = None, ) -> None: + if self.password_required and (not self.hashed_password): + self.log.critical( + _i18n("Jupyter servers are configured to only be run with a password.") + ) + self.log.critical(_i18n("Hint: run the following command to set a password")) + self.log.critical(_i18n("\t$ python -m jupyter_server.auth password")) + sys.exit(1) return self.login_handler_class.validate_security(app, ssl_options) diff --git a/tests/auth/test_login.py b/tests/auth/test_login.py index 5a3a60b98e..25d88f67c1 100644 --- a/tests/auth/test_login.py +++ b/tests/auth/test_login.py @@ -7,7 +7,6 @@ from tornado.httpclient import HTTPClientError from tornado.httputil import parse_cookie, url_concat -from jupyter_server.serverapp import ServerApp from jupyter_server.utils import url_path_join