more py3 fixes

This commit is contained in:
aptalca 2020-02-20 17:36:20 -05:00
parent 42fa7ba2c2
commit ffbb63bc0c
3 changed files with 9 additions and 5 deletions

View File

@ -136,6 +136,7 @@ class AppHandler(BaseHTTPRequestHandler):
cipher_suite = Fernet(REPLACEWITHFERNETKEY)
enc = cipher_suite.encrypt(ensure_bytes(user + ':' + passwd))
enc = enc.decode()
self.send_header('Set-Cookie', 'nginxauth=' + enc + '; httponly')
self.send_header('Location', target)

View File

@ -87,7 +87,8 @@ class AuthHandler(BaseHTTPRequestHandler):
try:
cipher_suite = Fernet(REPLACEWITHFERNETKEY)
self.log_message('Trying to dechipher credentials...')
auth_decoded = cipher_suite.decrypt(auth_header[6:])
auth_decoded = auth_header[6:].encode()
auth_decoded = cipher_suite.decrypt(auth_decoded)
auth_decoded = auth_decoded.decode("utf-8")
user, passwd = auth_decoded.split(':', 1)
except InvalidToken:

View File

@ -1,7 +1,9 @@
#!/usr/bin/with-contenv bash
# generate fernet key for ldap if it doesn't exist
[[ $(cat /app/ldap-backend-app.py | grep 'REPLACEWITHFERNETKEY') ]] && \
FERNETKEY=$(python3 /app/fernet-key.py) && \
sed -i "s/REPLACEWITHFERNETKEY/${FERNETKEY}/" /app/ldap-backend-app.py && \
sed -i "s/REPLACEWITHFERNETKEY/${FERNETKEY}/" /app/nginx-ldap-auth-daemon.py
if grep -q 'REPLACEWITHFERNETKEY' /app/ldap-backend-app.py; then
FERNETKEY=$(python3 /app/fernet-key.py)
sed -i "s/REPLACEWITHFERNETKEY/${FERNETKEY}/" /app/ldap-backend-app.py
sed -i "s/REPLACEWITHFERNETKEY/${FERNETKEY}/" /app/nginx-ldap-auth-daemon.py
echo "generated fernet key"
fi