Skip to content

Commit 8ca3d9a

Browse files
committed
Fix broken basic auth with long username/password
With long usernames and passwords (like those produced by Learning Locker), the base64.encodestring produces multiline digest for the Auth header, thus breaking the requests. This patch uses the better b64encode, which doesn't add any spurious newlines.
1 parent a3fb50b commit 8ca3d9a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tincan/remote_lrs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def __init__(self, *args, **kwargs):
7777
and kwargs["password"] is not None \
7878
and "auth" not in kwargs:
7979
# The base64 encode tacks on a \n character to the string which needs to be removed.
80-
auth_string = "Basic " + base64.encodestring(unicode(kwargs["username"]) +
81-
":" +
82-
unicode(kwargs["password"]))[:-1]
80+
auth_string = "Basic " + base64.b64encode(unicode(kwargs["username"]) +
81+
":" +
82+
unicode(kwargs["password"]))
8383

8484
kwargs.pop("username")
8585
kwargs.pop("password")

0 commit comments

Comments
 (0)