Skip to content

Commit ffbb63b

Browse files
committed
more py3 fixes
1 parent 42fa7ba commit ffbb63b

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

root/app/ldap-backend-app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def do_POST(self):
136136

137137
cipher_suite = Fernet(REPLACEWITHFERNETKEY)
138138
enc = cipher_suite.encrypt(ensure_bytes(user + ':' + passwd))
139+
enc = enc.decode()
139140
self.send_header('Set-Cookie', 'nginxauth=' + enc + '; httponly')
140141

141142
self.send_header('Location', target)

root/app/nginx-ldap-auth-daemon.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def do_GET(self):
8787
try:
8888
cipher_suite = Fernet(REPLACEWITHFERNETKEY)
8989
self.log_message('Trying to dechipher credentials...')
90-
auth_decoded = cipher_suite.decrypt(auth_header[6:])
90+
auth_decoded = auth_header[6:].encode()
91+
auth_decoded = cipher_suite.decrypt(auth_decoded)
9192
auth_decoded = auth_decoded.decode("utf-8")
9293
user, passwd = auth_decoded.split(':', 1)
9394
except InvalidToken:

root/etc/cont-init.d/30-config

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/with-contenv bash
22

33
# generate fernet key for ldap if it doesn't exist
4-
[[ $(cat /app/ldap-backend-app.py | grep 'REPLACEWITHFERNETKEY') ]] && \
5-
FERNETKEY=$(python3 /app/fernet-key.py) && \
6-
sed -i "s/REPLACEWITHFERNETKEY/${FERNETKEY}/" /app/ldap-backend-app.py && \
7-
sed -i "s/REPLACEWITHFERNETKEY/${FERNETKEY}/" /app/nginx-ldap-auth-daemon.py
4+
if grep -q 'REPLACEWITHFERNETKEY' /app/ldap-backend-app.py; then
5+
FERNETKEY=$(python3 /app/fernet-key.py)
6+
sed -i "s/REPLACEWITHFERNETKEY/${FERNETKEY}/" /app/ldap-backend-app.py
7+
sed -i "s/REPLACEWITHFERNETKEY/${FERNETKEY}/" /app/nginx-ldap-auth-daemon.py
8+
echo "generated fernet key"
9+
fi

0 commit comments

Comments
 (0)