yesod-auth-1.1.5.1: Authentication for Yesod.

Safe HaskellNone

Yesod.Auth

Contents

Synopsis

Subsite

data Auth Source

Instances

data family Route a1

The type-safe URLs associated with a site argument.

data AuthPlugin master Source

Constructors

AuthPlugin 

Fields

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

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

Associated Types

type AuthId master Source

Methods

loginDest :: master -> Route masterSource

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

logoutDest :: master -> Route masterSource

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

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

Determine the ID associated with the set of credentials.

authPlugins :: master -> [AuthPlugin master]Source

Which authentication backends to use.

loginHandler :: GHandler Auth master RepHtmlSource

What to show on the login page.

renderAuthMessageSource

Arguments

:: master 
-> [Text]

languages

-> AuthMessage 
-> Text 

Used for i18n of messages provided by this package.

redirectToReferer :: master -> BoolSource

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

authHttpManager :: master -> ManagerSource

onLogin :: GHandler sub master ()Source

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

onLogout :: GHandler sub master ()Source

Called on logout. By default, does nothing

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

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 Source

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 ()Source

User functions

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

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))Source

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

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)Source

Exception