Skip to content

Commit 03b50fe

Browse files
committed
Addresses #151 where auth function fails for mongoDB versions 4 and greater.
1 parent 163e5c6 commit 03b50fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Database/MongoDB/Query.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ auth un pw = do
276276
mmv <- readMaybe . T.unpack . head . T.splitOn "." <$> serverVersion
277277
maybe (return False) performAuth mmv
278278
where
279-
performAuth majorVersion =
280-
if majorVersion >= (3 :: Int)
281-
then authSCRAMSHA1 un pw
282-
else authMongoCR un pw
279+
performAuth majorVersion
280+
| majorVersion >= (4 :: Int) = authSCRAMSHA256 un pw
281+
| majorVersion >= 3 = authSCRAMSHA1 un pw
282+
| otherwise = authMongoCR un pw
283283

284284
authMongoCR :: (MonadIO m) => Username -> Password -> Action m Bool
285285
-- ^ Authenticate with the current database, using the MongoDB-CR authentication mechanism (default in MongoDB server < 3.0)

0 commit comments

Comments
 (0)