From e39c287569a20fc070b6ccdf52d339a7da1e11cf Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 31 Mar 2019 05:45:39 +0300 Subject: Handle `auth=fail` Ignore credentials provided by a user, serve documents with status code 401. --- Main.hsc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Main.hsc') diff --git a/Main.hsc b/Main.hsc index 53a9a2f..f75d69e 100644 --- a/Main.hsc +++ b/Main.hsc @@ -322,9 +322,10 @@ main = do to <- maybe 10 read <$> lookupEnv "TIMEOUT" maybe (respond 504 "") pure =<< timeout (to * 10 ^ (6 :: Int)) (case (lookup "auth" ps, baCredentials =<< BS.pack <$> ha) of + (Just "on", Nothing) -> respond 401 "" + (Just "try", Nothing) -> serve True xsltDir (connectdb "") ps + (Just "fail", _) -> serve True xsltDir (connectdb "") ps (_, Just (l, p)) -> serve False xsltDir (connectdb (connString [("user", l), ("password", p)])) ps - (Just "on", Nothing) -> respond 401 "" - (Just "try", Nothing) -> serve True xsltDir (connectdb "") ps _ -> serve False xsltDir (connectdb "") ps) -- cgit v1.2.3