clientsession 0.7

This commit is contained in:
Michael Snoyman 2011-08-19 10:36:57 +03:00
parent 716f062d5d
commit 67c1c55e41
3 changed files with 8 additions and 6 deletions

View File

@ -356,15 +356,16 @@ defaultYesodRunner s master toMasterRoute mkey murl handler req = do
$ filter (\(x, _) -> x /= nonceKey) session' $ filter (\(x, _) -> x /= nonceKey) session'
yar <- handlerToYAR master s toMasterRoute (yesodRender master) errorHandler rr murl sessionMap h yar <- handlerToYAR master s toMasterRoute (yesodRender master) errorHandler rr murl sessionMap h
let mnonce = reqNonce rr let mnonce = reqNonce rr
return $ yarToResponse (hr mnonce getExpires host exp') yar iv <- liftIO CS.randomIV
return $ yarToResponse (hr iv mnonce getExpires host exp') yar
where where
hr mnonce getExpires host exp' hs ct sm = hr iv mnonce getExpires host exp' hs ct sm =
hs''' hs'''
where where
sessionVal = sessionVal =
case (mkey, mnonce) of case (mkey, mnonce) of
(Just key, Just nonce) (Just key, Just nonce)
-> encodeSession key exp' host -> encodeSession key iv exp' host
$ Map.toList $ Map.toList
$ Map.insert nonceKey nonce sm $ Map.insert nonceKey nonce sm
_ -> mempty _ -> mempty

View File

@ -12,12 +12,13 @@ import Data.Text (Text, pack, unpack)
import Control.Arrow ((***)) import Control.Arrow ((***))
encodeSession :: CS.Key encodeSession :: CS.Key
-> CS.IV
-> UTCTime -- ^ expire time -> UTCTime -- ^ expire time
-> ByteString -- ^ remote host -> ByteString -- ^ remote host
-> [(Text, Text)] -- ^ session -> [(Text, Text)] -- ^ session
-> ByteString -- ^ cookie value -> ByteString -- ^ cookie value
encodeSession key expire rhost session' = encodeSession key iv expire rhost session' =
CS.encrypt key $ encode $ SessionCookie expire rhost session' CS.encrypt key iv $ encode $ SessionCookie expire rhost session'
decodeSession :: CS.Key decodeSession :: CS.Key
-> UTCTime -- ^ current time -> UTCTime -- ^ current time

View File

@ -40,7 +40,7 @@ library
, shakespeare-css >= 0.10 && < 0.11 , shakespeare-css >= 0.10 && < 0.11
, blaze-builder >= 0.2.1 && < 0.4 , blaze-builder >= 0.2.1 && < 0.4
, transformers >= 0.2 && < 0.3 , transformers >= 0.2 && < 0.3
, clientsession >= 0.6 && < 0.7 , clientsession >= 0.7 && < 0.8
, random >= 1.0.0.2 && < 1.1 , random >= 1.0.0.2 && < 1.1
, cereal >= 0.2 && < 0.4 , cereal >= 0.2 && < 0.4
, old-locale >= 1.0.0.2 && < 1.1 , old-locale >= 1.0.0.2 && < 1.1