yesod-auth-1.1.5.3: Authentication for Yesod.

Safe HaskellNone

Yesod.Auth

Contents

Synopsis

Subsite

data Auth

Instances

data family Route a

The type-safe URLs associated with a site argument.

data AuthPlugin master

Constructors

AuthPlugin 

Fields

apName :: Text
 
apDispatch :: Method -> [Piece] -> GHandler Auth master ()
 
apLogin :: forall sub. (Route Auth -> Route master) -> GWidget sub master ()
 

getAuth :: a -> Auth

class (Yesod master, PathPiece (AuthId master), RenderMessage master FormMessage) => YesodAuth master where

Associated Types

type AuthId master

Methods

loginDest :: master -> Route master

Default destination on successful login, if no other destination exists.

logoutDest :: master -> Route master

Default destination on successful logout, if no other destination exists.

getAuthId :: Creds master -> GHandler sub master (Maybe (AuthId master))

Determine the ID associated with the set of credentials.

authPlugins :: master -> [AuthPlugin master]

Which authentication backends to use.

loginHandler :: GHandler Auth master RepHtml

What to show on the login page.

renderAuthMessage

Arguments

:: master 
-> [Text]

languages

-> AuthMessage 
-> Text 

Used for i18n of messages provided by this package.

redirectToReferer :: master -> Bool

After login and logout, redirect to the referring page, instead of loginDest and logoutDest. Default is False.

authHttpManager :: master -> Manager

onLogin :: GHandler sub master ()

Called on a successful login. By default, calls setMessageI NowLoggedIn.

onLogout :: GHandler sub master ()

Called on logout. By default, does nothing

maybeAuthId :: GHandler sub master (Maybe (AuthId master))

Retrieves user credentials, if user is authenticated.

By default, this calls defaultMaybeAuthId to get the user ID from the session. This can be overridden to allow authentication via other means, such as checking for a special token in a request header. This is especially useful for creating an API to be accessed via some means other than a browser.

Since 1.1.2

Plugin interface

data Creds master

User credentials

Constructors

Creds 

Fields

credsPlugin :: Text

How the user was authenticated

credsIdent :: Text

Identifier. Exact meaning depends on plugin.

credsExtra :: [(Text, Text)]
 

setCreds :: YesodAuth master => Bool -> Creds master -> GHandler sub master ()

User functions

defaultMaybeAuthId :: YesodAuth master => GHandler sub master (Maybe (AuthId master))

Retrieves user credentials from the session, if user is authenticated.

Since 1.1.2

maybeAuth :: (YesodAuth master, PersistMonadBackend (b (GHandler sub master)) ~ PersistEntityBackend val, b ~ YesodPersistBackend master, Key val ~ AuthId master, PersistStore (b (GHandler sub master)), PersistEntity val, YesodPersist master) => GHandler sub master (Maybe (Entity val))

requireAuthId :: YesodAuth master => GHandler sub master (AuthId master)

requireAuth :: (YesodAuth master, b ~ YesodPersistBackend master, PersistMonadBackend (b (GHandler sub master)) ~ PersistEntityBackend val, Key val ~ AuthId master, PersistStore (b (GHandler sub master)), PersistEntity val, YesodPersist master) => GHandler sub master (Entity val)

Exception