]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: SSO error: AttributeError: 'str' object has no attribute 'decode' 51951/head
authorVolker Theile <vtheile@suse.com>
Tue, 9 May 2023 13:19:42 +0000 (15:19 +0200)
committerNizamudeen A <nia@redhat.com>
Wed, 7 Jun 2023 06:43:34 +0000 (12:13 +0530)
The token is `str` in PyJWT >= 2 and Python3. Check `controllers/auth.py` where the same code is used.

Fixes: https://tracker.ceph.com/issues/59689
References: https://github.com/SUSE/ceph/pull/506

Signed-off-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit 0fc6e7637657a96acfb0aa01dde6b3fbd81a136d)

src/pybind/mgr/dashboard/controllers/saml2.py

index 55445bc94d7b2cc6d174b8745418232785c73209..c11b18a27bc7e7e41caf8272ebd13fa0889c3bd6 100644 (file)
@@ -69,7 +69,10 @@ class Saml2(BaseController, ControllerAuthMixin):
 
             token = JwtManager.gen_token(username)
             JwtManager.set_user(JwtManager.decode_token(token))
-            token = token.decode('utf-8')
+
+            # For backward-compatibility: PyJWT versions < 2.0.0 return bytes.
+            token = token.decode('utf-8') if isinstance(token, bytes) else token
+
             self._set_token_cookie(url_prefix, token)
             raise cherrypy.HTTPRedirect("{}/#/login?access_token={}".format(url_prefix, token))