Safe Haskell | None |
---|---|
Language | Haskell2010 |
- dbStore :: (WithPostgreSQLConn a, Serialize k, Eq k, Serialize v, MonadIO m) => a -> StoreSettings -> IO (SessionStore m k v)
- defaultSettings :: StoreSettings
- clearSession :: WithPostgreSQLConn a => a -> ByteString -> Request -> IO ()
- purgeOldSessions :: WithPostgreSQLConn a => a -> StoreSettings -> IO Int64
- purger :: WithPostgreSQLConn a => a -> StoreSettings -> IO ThreadId
- ratherSecureGen :: Int -> IO ByteString
- class WithPostgreSQLConn a where
- withPostgreSQLConn :: a -> (Connection -> IO b) -> IO b
- data StoreSettings = StoreSettings {}
Documentation
dbStore :: (WithPostgreSQLConn a, Serialize k, Eq k, Serialize v, MonadIO m) => a -> StoreSettings -> IO (SessionStore m k v) Source
Create a new postgresql backed wai session store.
defaultSettings :: StoreSettings Source
Create default settings using a session timeout of one hour, a cryptographically secure session id generator using 24 bytes of entropy and putStrLn to log events to stdout.
clearSession :: WithPostgreSQLConn a => a -> ByteString -> Request -> IO () Source
This function can be called to invalidate a session and enforce creating a new one with a new session ID. It should be called *before* and calls to sessionStore are made. It needs to be passed a request and the cookie name explicitly due to the limited nature of the Network.Wai.Session interface. Sessions should be cleared when a login is performed, to prevent certain kinds of session hijacking attacks.
purgeOldSessions :: WithPostgreSQLConn a => a -> StoreSettings -> IO Int64 Source
Delete expired sessions from the database.
purger :: WithPostgreSQLConn a => a -> StoreSettings -> IO ThreadId Source
Run a thread using forkIO that runs periodically to purge old sessions.
ratherSecureGen :: Int -> IO ByteString Source
Generate a session ID with n bytes of entropy
class WithPostgreSQLConn a where Source
By default, you pass a postgresql connection to the session store when creating it. The passed connection will have to stay open for the (possibly very long) existence of the session and it should not be used for any other purpose during that time. You can implement an instance of this class for a connection pool instead, so that the session manager will not require a permanent open PostgreSQL connection.
withPostgreSQLConn :: a -> (Connection -> IO b) -> IO b Source
Call the function (Connection -> IO b) with a valid and open PostgreSQL connection.
data StoreSettings Source
These settings control how the session store is behaving
StoreSettings | |
|