htpasswd: ignore comments
This commit is contained in:
parent
73038e518a
commit
f912642c20
@ -216,7 +216,7 @@ class Auth(BaseAuth):
|
|||||||
with open(self.filename) as f:
|
with open(self.filename) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
line = line.rstrip("\n")
|
line = line.rstrip("\n")
|
||||||
if line.lstrip():
|
if line.lstrip() and not line.lstrip().startswith("#"):
|
||||||
try:
|
try:
|
||||||
login, hash_value = line.split(":", maxsplit=1)
|
login, hash_value = line.split(":", maxsplit=1)
|
||||||
# Always compare both login and password to avoid
|
# Always compare both login and password to avoid
|
||||||
|
@ -121,6 +121,9 @@ class TestBaseAuthRequests(BaseTest):
|
|||||||
self._test_htpasswd("plain", " tmp : bepo ", (
|
self._test_htpasswd("plain", " tmp : bepo ", (
|
||||||
(" tmp ", " bepo ", 207), ("tmp", "bepo", 401)))
|
(" tmp ", " bepo ", 207), ("tmp", "bepo", 401)))
|
||||||
|
|
||||||
|
def test_htpasswd_comment(self):
|
||||||
|
self._test_htpasswd("plain", "#comment\n #comment\n \ntmp:bepo\n\n")
|
||||||
|
|
||||||
def test_remote_user(self):
|
def test_remote_user(self):
|
||||||
self.configuration["auth"]["type"] = "remote_user"
|
self.configuration["auth"]["type"] = "remote_user"
|
||||||
self.application = Application(self.configuration, self.logger)
|
self.application = Application(self.configuration, self.logger)
|
||||||
|
Loading…
Reference in New Issue
Block a user