-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Happstack Authentication Suite -- -- An easy way to to implement user authentication for Happstack web -- applications. @package happstack-auth @version 0.2.1.1 -- | Internal representation of state data types. module Happstack.Auth.Internal.Data -- | Add this to your Dependency-List of your application state data AuthState AuthState :: Sessions SessionData -> UserDB -> UserId -> AuthState sessions :: AuthState -> Sessions SessionData users :: AuthState -> UserDB nextUid :: AuthState -> UserId newtype SaltedHash SaltedHash :: [Octet] -> SaltedHash data SessionData SessionData :: UserId -> Username -> ClockTime -> (Either String ByteString, Maybe ByteString) -> SessionData sesUid :: SessionData -> UserId sesUsername :: SessionData -> Username sesTimeout :: SessionData -> ClockTime sesFingerprint :: SessionData -> (Either String ByteString, Maybe ByteString) -- | Abstract session identification newtype SessionKey SessionKey :: Integer -> SessionKey data Sessions a Sessions :: Map SessionKey a -> Sessions a unsession :: Sessions a -> Map SessionKey a data User User :: UserId -> Username -> SaltedHash -> User userid :: User -> UserId username :: User -> Username userpass :: User -> SaltedHash type UserDB = IxSet User -- | Abstract user identification newtype UserId UserId :: Word64 -> UserId unUid :: UserId -> Word64 newtype Username Username :: String -> Username unUser :: Username -> String -- | Internal representation of state functions. module Happstack.Auth.Internal buildSaltAndHash :: String -> IO (Maybe SaltedHash) data AskUsers AskUsers :: AskUsers data AddUser AddUser :: Username -> SaltedHash -> AddUser data GetUser GetUser :: Username -> GetUser data GetUserById GetUserById :: UserId -> GetUserById data DelUser DelUser :: Username -> DelUser data AuthUser AuthUser :: String -> String -> AuthUser data IsUser IsUser :: Username -> IsUser data ListUsers ListUsers :: ListUsers data NumUsers NumUsers :: NumUsers data UpdateUser UpdateUser :: User -> UpdateUser data SetPassword SetPassword :: Username -> SaltedHash -> SetPassword data ChangePassword ChangePassword :: String -> String -> SaltedHash -> ChangePassword data ClearAllSessions ClearAllSessions :: ClearAllSessions data SetSession SetSession :: SessionKey -> SessionData -> SetSession data GetSession GetSession :: SessionKey -> GetSession data GetSessions GetSessions :: GetSessions data NewSession NewSession :: SessionData -> NewSession data DelSession DelSession :: SessionKey -> DelSession data NumSessions NumSessions :: NumSessions data ClearExpiredSessions ClearExpiredSessions :: ClockTime -> ClearExpiredSessions data UpdateTimeout UpdateTimeout :: SessionKey -> ClockTime -> UpdateTimeout instance Typeable UpdateTimeout instance Typeable ClearExpiredSessions instance Typeable NumSessions instance Typeable DelSession instance Typeable NewSession instance Typeable GetSessions instance Typeable GetSession instance Typeable SetSession instance Typeable ClearAllSessions instance Typeable ChangePassword instance Typeable SetPassword instance Typeable UpdateUser instance Typeable NumUsers instance Typeable ListUsers instance Typeable IsUser instance Typeable AuthUser instance Typeable DelUser instance Typeable GetUserById instance Typeable GetUser instance Typeable AddUser instance Typeable AskUsers instance Version UpdateTimeout instance Serialize UpdateTimeout instance Version ClearExpiredSessions instance Serialize ClearExpiredSessions instance Version NumSessions instance Serialize NumSessions instance Version DelSession instance Serialize DelSession instance Version NewSession instance Serialize NewSession instance Version GetSessions instance Serialize GetSessions instance Version GetSession instance Serialize GetSession instance Version SetSession instance Serialize SetSession instance Version ClearAllSessions instance Serialize ClearAllSessions instance Version ChangePassword instance Serialize ChangePassword instance Version SetPassword instance Serialize SetPassword instance Version UpdateUser instance Serialize UpdateUser instance Version NumUsers instance Serialize NumUsers instance Version ListUsers instance Serialize ListUsers instance Version IsUser instance Serialize IsUser instance Version AuthUser instance Serialize AuthUser instance Version DelUser instance Serialize DelUser instance Version GetUserById instance Serialize GetUserById instance Version GetUser instance Serialize GetUser instance Version AddUser instance Serialize AddUser instance Version AskUsers instance Serialize AskUsers instance Methods AuthState instance (Serialize UpdateTimeout, Serialize ()) => UpdateEvent UpdateTimeout () instance (Serialize ClearExpiredSessions, Serialize ()) => UpdateEvent ClearExpiredSessions () instance (Serialize NumSessions, Serialize Int) => QueryEvent NumSessions Int instance (Serialize DelSession, Serialize ()) => UpdateEvent DelSession () instance (Serialize NewSession, Serialize SessionKey) => UpdateEvent NewSession SessionKey instance (Serialize GetSessions, Serialize (Sessions SessionData)) => QueryEvent GetSessions (Sessions SessionData) instance (Serialize GetSession, Serialize (Maybe SessionData)) => QueryEvent GetSession (Maybe SessionData) instance (Serialize SetSession, Serialize ()) => UpdateEvent SetSession () instance (Serialize ClearAllSessions, Serialize ()) => UpdateEvent ClearAllSessions () instance (Serialize ChangePassword, Serialize Bool) => UpdateEvent ChangePassword Bool instance (Serialize SetPassword, Serialize Bool) => UpdateEvent SetPassword Bool instance (Serialize UpdateUser, Serialize ()) => UpdateEvent UpdateUser () instance (Serialize NumUsers, Serialize Int) => QueryEvent NumUsers Int instance (Serialize ListUsers, Serialize [Username]) => QueryEvent ListUsers [Username] instance (Serialize IsUser, Serialize Bool) => QueryEvent IsUser Bool instance (Serialize AuthUser, Serialize (Maybe User)) => QueryEvent AuthUser (Maybe User) instance (Serialize DelUser, Serialize ()) => UpdateEvent DelUser () instance (Serialize GetUserById, Serialize (Maybe User)) => QueryEvent GetUserById (Maybe User) instance (Serialize GetUser, Serialize (Maybe User)) => QueryEvent GetUser (Maybe User) instance (Serialize AddUser, Serialize (Maybe User)) => UpdateEvent AddUser (Maybe User) instance (Serialize AskUsers, Serialize UserDB) => QueryEvent AskUsers UserDB -- | Happstack.Auth offers an easy way to implement user authentication for -- Happstack web applications. It uses Happstack.State as database -- back-end and SHA512 for password encryption. Session safety is ensured -- by a HTTP header fingerprint (client ip & user-agent) and a -- configurable session timeout. -- -- To use this module, add the AuthState to your state -- dependencies, for example: -- --
--   import Happstack.Auth
--   
--   instance Component MyState where
--       type Dependencies MyState = AuthState :+: End
--       initialValue = ...
--   
-- -- One of the first things in your response monad should be -- updateTimeout to make sure session timeouts are updated -- correctly. module Happstack.Auth -- | Register a new user register :: (MonadIO m, FilterMonad Response m, ServerMonad m) => Minutes -> Username -> Password -> m a -> m a -> m a changePassword :: (MonadIO m) => Username -> Password -> Password -> m Bool setPassword :: (MonadIO m) => Username -> Password -> m Bool -- | Update the session timeout of logged in users. Add this to the top of -- your application route, for example: -- --
--   appRoute :: ServerPart Response
--   appRoute = updateTimeout 5 >> msum
--       [ {- your routing here -}
--       ]
--   
updateTimeout :: (MonadIO m, FilterMonad Response m, MonadPlus m, ServerMonad m) => Minutes -> m () performLogin :: (MonadIO m, FilterMonad Response m, ServerMonad m) => Minutes -> User -> m a -> m a performLogout :: (MonadIO m, FilterMonad Response m) => SessionKey -> m () -- | Handles data from a login form to log the user in. loginHandler :: (MonadIO m, FilterMonad Response m, MonadPlus m, ServerMonad m) => Minutes -> Maybe String -> Maybe String -> m a -> (Maybe Username -> Maybe Password -> m a) -> m a logoutHandler :: (ServerMonad m, MonadPlus m, MonadIO m, FilterMonad Response m) => m a -> m a -- | Run a ServerPartT with the SessionData of the currently -- logged in user (if available) withSession :: (MonadIO m) => (SessionData -> ServerPartT m a) -> ServerPartT m a -> ServerPartT m a -- | Require a login loginGate :: (MonadIO m) => ServerPartT m a -> ServerPartT m a -> ServerPartT m a -- | Get the SessionData of the currently logged in user getSessionData :: (MonadIO m, MonadPlus m, ServerMonad m) => m (Maybe SessionData) -- | Get the identifier for the current session getSessionKey :: (MonadIO m, MonadPlus m, ServerMonad m) => m (Maybe SessionKey) clearSessionCookie :: (FilterMonad Response m) => m () addUser :: (MonadIO m) => Username -> Password -> m (Maybe User) getUser :: (MonadIO m) => Username -> m (Maybe User) getUserById :: (MonadIO m) => UserId -> m (Maybe User) delUser :: (MonadIO m) => Username -> m () -- | Update (replace) a user updateUser :: (MonadIO m) => User -> m () authUser :: (MonadIO m) => Username -> Password -> m (Maybe User) isUser :: (MonadIO m) => Username -> m Bool listUsers :: (MonadIO m) => m [Username] numUsers :: (MonadIO m) => m Int -- | Warning: This UserDB uses the internal types from -- Happstack.Auth.Data.Internal askUsers :: (MonadIO m) => m UserDB newSession :: (MonadIO m) => SessionData -> m SessionKey getSession :: (MonadIO m) => SessionKey -> m (Maybe SessionData) setSession :: (MonadIO m) => SessionKey -> SessionData -> m () delSession :: (MonadIO m) => SessionKey -> m () clearAllSessions :: (MonadIO m) => m () numSessions :: (MonadIO m) => m Int -- | Warning: This Sessions uses the internal types from -- Happstack.Auth.Data.Internal getSessions :: (MonadIO m) => m (Sessions SessionData) clearExpiredSessions :: (MonadIO m) => m () data User userName :: User -> Username userId :: User -> UserId type Username = String type Password = String -- | Abstract user identification data UserId data SessionData SessionData :: UserId -> Username -> ClockTime -> (Either String ByteString, Maybe ByteString) -> SessionData sessionUserId :: SessionData -> UserId sessionUsername :: SessionData -> Username sessionTimeout :: SessionData -> ClockTime -- | either IP or "x-forwarded-for" header & user-agent sessionFingerprint :: SessionData -> (Either String ByteString, Maybe ByteString) -- | Abstract session identification data SessionKey type Minutes = Int -- | Add this to your Dependency-List of your application state data AuthState authProxy :: Proxy AuthState instance Convertible SessionData SessionData instance Convertible SessionData SessionData instance Convertible User User instance Convertible User User