Skip to content

Commit b02c29e

Browse files
Merge Stop leaking Nonce generator on authentication
pull request #89 from EdutainmentLIVE/master
2 parents 91fed88 + 87ddf52 commit b02c29e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Database/MongoDB/Query.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ authSCRAMSHA1 :: MonadIO m => Username -> Password -> Action m Bool
263263
-- ^ Authenticate with the current database, using the SCRAM-SHA-1 authentication mechanism (default in MongoDB server >= 3.0)
264264
authSCRAMSHA1 un pw = do
265265
let hmac = HMAC.hmac SHA1.hash 64
266-
nonce <- (Nonce.new >>= Nonce.nonce128 >>= return . B64.encode)
266+
nonce <- liftIO (Nonce.withGenerator Nonce.nonce128 >>= return . B64.encode)
267267
let firstBare = B.concat [B.pack $ "n=" ++ (T.unpack un) ++ ",r=", nonce]
268268
let client1 = ["saslStart" =: (1 :: Int), "mechanism" =: ("SCRAM-SHA-1" :: String), "payload" =: (B.unpack . B64.encode $ B.concat [B.pack "n,,", firstBare]), "autoAuthorize" =: (1 :: Int)]
269269
server1 <- runCommand client1

0 commit comments

Comments
 (0)