on master help sign in
Fix bug #9: tighten Timestamp annotations on handleChallenge, handleVerifyAuth, doPoll
de66ca8iko
server.knot+3−3
@@ -605,7 +605,7 @@ forwardQueuedToServer = \pubkey server -> atomic (do
605-- Capped per-key (maxChallengesPerKey); per-pubkey rate limiting is enforced
605-- Capped per-key (maxChallengesPerKey); per-pubkey rate limiting is enforced
606-- by the route's `rateLimit` clause. The IP is recorded so /auth/verify can
606-- by the route's `rateLimit` clause. The IP is recorded so /auth/verify can
607-- require the same client.
607-- require the same client.
608−handleChallenge : PubkeyHex -> Text -> IO {rw *challenges, clock, random} (Result HttpError {challenge: Text, expiresAt: Int})
608+handleChallenge : PubkeyHex -> Text -> IO {rw *challenges, clock, random} (Result HttpError {challenge: Text, expiresAt: Timestamp})
609handleChallenge = \pubkey clientIp -> do
609handleChallenge = \pubkey clientIp -> do
610 t <- now
610 t <- now
611 challenge <- genToken 48
611 challenge <- genToken 48
@@ -623,7 +623,7 @@ handleChallenge = \pubkey clientIp -> do
623-- On success, mints a session token, records local presence (`pubkey` is now
623-- On success, mints a session token, records local presence (`pubkey` is now
624-- live on this server), and gossips an `online` event to known peers. If
624-- live on this server), and gossips an `online` event to known peers. If
625-- `revokeOthers` is set, all other sessions for the same pubkey are dropped.
625-- `revokeOthers` is set, all other sessions for the same pubkey are dropped.
626−handleVerifyAuth : PubkeyHex -> Text -> Text -> Bool -> Text -> IO {rw *challenges, rw *forwardFailures, rw *presence, rw *sessions, network, clock, random} (Result HttpError {expiresAt: Int, token: Text})
626+handleVerifyAuth : PubkeyHex -> Text -> Text -> Bool -> Text -> IO {rw *challenges, rw *forwardFailures, rw *presence, rw *sessions, network, clock, random} (Result HttpError {expiresAt: Timestamp, token: Text})
627handleVerifyAuth = \pubkey challenge signature revokeOthers clientIp -> do
627handleVerifyAuth = \pubkey challenge signature revokeOthers clientIp -> do
628 t <- now
628 t <- now
629 let expiry = t + sessionExpiry
629 let expiry = t + sessionExpiry
@@ -698,7 +698,7 @@ handlePoll = \cursor authorization clientIp -> do
698-- the wait transaction reads `*messages` and `retry`s until a row matching
698-- the wait transaction reads `*messages` and `retry`s until a row matching
699-- this pubkey/cursor is committed; the timer wins on idle. Either way we
699-- this pubkey/cursor is committed; the timer wins on idle. Either way we
700-- re-collect at the new wall time, so a timeout returns an empty page.
700-- re-collect at the new wall time, so a timeout returns an empty page.
701−doPoll : {clampedCursor: Int, pubkey: PubkeyHex | a} -> Int<Ms> -> IO {r *messages, clock} {cursor: Int<Ms>, events: [{encryptedBlob: BlobHex}]}
701+doPoll : {clampedCursor: Timestamp, pubkey: PubkeyHex | a} -> Timestamp -> IO {r *messages, clock} {cursor: Timestamp, events: [{encryptedBlob: BlobHex}]}
702doPoll = \s t -> do
702doPoll = \s t -> do
703 let collectAt = \tnow -> atomic (do
703 let collectAt = \tnow -> atomic (do
704 msgs <- *messages
704 msgs <- *messages