File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ def do_POST(self):
136
136
137
137
cipher_suite = Fernet (REPLACEWITHFERNETKEY )
138
138
enc = cipher_suite .encrypt (ensure_bytes (user + ':' + passwd ))
139
+ enc = enc .decode ()
139
140
self .send_header ('Set-Cookie' , 'nginxauth=' + enc + '; httponly' )
140
141
141
142
self .send_header ('Location' , target )
Original file line number Diff line number Diff line change @@ -87,7 +87,8 @@ def do_GET(self):
87
87
try:
88
88
cipher_suite = Fernet(REPLACEWITHFERNETKEY)
89
89
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)
91
92
auth_decoded = auth_decoded.decode(" utf-8" )
92
93
user, passwd = auth_decoded.split(' :' , 1)
93
94
except InvalidToken:
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/with-contenv bash
2
2
3
3
# 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
You can’t perform that action at this time.
0 commit comments