nonce is a Maybe
This commit is contained in:
parent
e802df12dc
commit
8596bbc10e
@ -283,7 +283,7 @@ defaultYesodRunner y mkey murl handler req = do
|
|||||||
let sessionMap = Map.fromList
|
let sessionMap = Map.fromList
|
||||||
$ filter (\(x, _) -> x /= nonceKey) session'
|
$ filter (\(x, _) -> x /= nonceKey) session'
|
||||||
yar <- handlerToYAR y (yesodRender y) errorHandler rr murl sessionMap h
|
yar <- handlerToYAR y (yesodRender y) errorHandler rr murl sessionMap h
|
||||||
let mnonce = Just $ reqNonce rr -- FIXME
|
let mnonce = reqNonce rr
|
||||||
return $ yarToResponse (hr mnonce getExpires host exp') yar
|
return $ yarToResponse (hr mnonce getExpires host exp') yar
|
||||||
where
|
where
|
||||||
hr mnonce getExpires host exp' hs ct sm =
|
hr mnonce getExpires host exp' hs ct sm =
|
||||||
@ -599,11 +599,11 @@ parseWaiRequest env session' key' = do
|
|||||||
Nothing -> langs''
|
Nothing -> langs''
|
||||||
Just x -> x : langs''
|
Just x -> x : langs''
|
||||||
nonce <- case (key', lookup nonceKey session') of
|
nonce <- case (key', lookup nonceKey session') of
|
||||||
(Nothing, _) -> return $ error "You have attempted to use the nonce, but sessions are disabled." -- FIXME maybe this should be handled without an error?
|
(Nothing, _) -> return Nothing
|
||||||
(_, Just x) -> return x
|
(_, Just x) -> return $ Just x
|
||||||
(_, Nothing) -> do
|
(_, Nothing) -> do
|
||||||
g <- newStdGen
|
g <- newStdGen
|
||||||
return $ fst $ randomString 10 g
|
return $ Just $ fst $ randomString 10 g
|
||||||
return $ Request gets' cookies' env langs''' nonce
|
return $ Request gets' cookies' env langs''' nonce
|
||||||
where
|
where
|
||||||
randomString len =
|
randomString len =
|
||||||
|
|||||||
@ -101,7 +101,7 @@ data Request = Request
|
|||||||
-- | Languages which the client supports.
|
-- | Languages which the client supports.
|
||||||
, reqLangs :: [String]
|
, reqLangs :: [String]
|
||||||
-- | A random, session-specific nonce used to prevent CSRF attacks.
|
-- | A random, session-specific nonce used to prevent CSRF attacks.
|
||||||
, reqNonce :: String
|
, reqNonce :: Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup' :: Eq a => a -> [(a, b)] -> [b]
|
lookup' :: Eq a => a -> [(a, b)] -> [b]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user