From c8a343811631d50ad49009862aa674b18be6b86f Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Wed, 28 Jul 2021 16:16:09 +0100 Subject: [PATCH] decode bytes from secure cookie The get_secure_cookie interface returns bytes not str https://www.tornadoweb.org/en/stable/web.html#tornado.web.RequestHandler.get_secure_cookie This fixes a minor issue where `handler.get_current_user` would return bytes rather than str. --- jupyter_server/auth/login.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jupyter_server/auth/login.py b/jupyter_server/auth/login.py index d0a2d722a4..30867c516a 100644 --- a/jupyter_server/auth/login.py +++ b/jupyter_server/auth/login.py @@ -172,6 +172,8 @@ def get_user(cls, handler): if user_id is None: get_secure_cookie_kwargs = handler.settings.get('get_secure_cookie_kwargs', {}) user_id = handler.get_secure_cookie(handler.cookie_name, **get_secure_cookie_kwargs ) + if user_id: + user_id = user_id.decode() else: cls.set_login_cookie(handler, user_id) # Record that the current request has been authenticated with a token.