Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend-sample-app.py concat issue on Python 3 #76

Open
joshmarvel opened this issue Apr 29, 2020 · 1 comment
Open

backend-sample-app.py concat issue on Python 3 #76

joshmarvel opened this issue Apr 29, 2020 · 1 comment

Comments

@joshmarvel
Copy link

backend-sample-app.py line 124 attempts to concatinate bytes literals and strings. On line 123 convert enc from a string to bytes literal. I purpose the following fix.
- enc = enc.decode()
+ enc = bytes(enc.decode(), encoding='utf-8')
self.send_header('Set-Cookie', b'nginxauth=' + enc + b'; httponly')

@bmbouter
Copy link

bmbouter commented Jun 15, 2020

I tried your patch but it didn't work for me (although maybe for you). The following patch did work for me:

diff --git a/backend-sample-app.py b/backend-sample-app.py
index 970c3ab..0b7b17b 100755
--- a/backend-sample-app.py
+++ b/backend-sample-app.py
@@ -121,7 +121,7 @@ class AppHandler(BaseHTTPRequestHandler):
             enc = base64.b64encode(ensure_bytes(user + ':' + passwd))
             if sys.version_info.major == 3:
                 enc = enc.decode()
-            self.send_header('Set-Cookie', b'nginxauth=' + enc + b'; httponly')
+            self.send_header('Set-Cookie', 'nginxauth=' + enc + '; httponly')
 
             self.send_header('Location', target)
             self.end_headers()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants