Skip to content

Commit ed9b6e7

Browse files
authored
Merge pull request #18 from artiomn/base-auth-fix
Non-working HTTP basic authentication was fixed
2 parents d5d4fc8 + fcaec0f commit ed9b6e7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
157157

158158
## Versions
159159

160+
* **01.07.19:** - Fall back to base64 encoding when basic http auth is used.
160161
* **28.06.19:** - Rebasing to alpine 3.10.
161162
* **23.03.19:** - Switching to new Base images, shift to arm32v7 tag.
162163
* **22.02.19:** - Rebasing to alpine 3.9.

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ app_setup_block: |
3434
3535
# changelog
3636
changelogs:
37+
- { date: "01.07.19:", desc: "Fall back to base64 encoding when basic http auth is used." }
3738
- { date: "28.06.19:", desc: "Rebasing to alpine 3.10." }
3839
- { date: "23.03.19:", desc: "Switching to new Base images, shift to arm32v7 tag." }
3940
- { date: "22.02.19:", desc: "Rebasing to alpine 3.9." }

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import sys, os, signal, base64, ldap, Cookie, argparse
1010
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
1111
from cryptography.fernet import Fernet
12+
from cryptography.fernet import InvalidToken
1213

1314
#Listen = ('localhost', 8888)
1415
#Listen = "/tmp/auth.sock" # Also uncomment lines in 'Requests are
@@ -74,11 +75,16 @@ def do_GET(self):
7475

7576
try:
7677
cipher_suite = Fernet('REPLACEWITHFERNETKEY')
78+
self.log_message('Trying to dechipher credentials...')
7779
auth_decoded = cipher_suite.decrypt(auth_header[6:])
7880
user, passwd = auth_decoded.split(':', 1)
79-
80-
except:
81+
except InvalidToken:
82+
self.log_message('Incorrect token. Trying to decode credentials from BASE64...')
83+
auth_decoded = base64.b64decode(auth_header[6:])
84+
user, passwd = auth_decoded.split(':', 1)
85+
except Exception as e:
8186
self.auth_failed(ctx)
87+
self.log_error(e)
8288
return True
8389

8490
ctx['user'] = user
@@ -245,8 +251,10 @@ def do_GET(self):
245251
self.send_response(200)
246252
self.end_headers()
247253

248-
except:
254+
except Exception as e:
249255
self.auth_failed(ctx)
256+
self.log_error(str(e))
257+
raise
250258

251259
def exit_handler(signal, frame):
252260
global Listen

0 commit comments

Comments
 (0)