yesod-auth-deskcom-1.2: remote authentication support for Yesod apps.

Safe HaskellNone




class YesodAuthPersist master => YesodDeskCom master whereSource

Type class that you need to implement in order to support remote authentication.

Minimal complete definition: everything except for deskComTokenTimeout.


deskComCredentials :: master -> DeskComCredentialsSource

The credentials needed to use Multipass. Use deskComCreateCreds. We recommend caching the resulting DeskComCredentials value on your foundation data type since creating it is an expensive operation.

deskComUserInfo :: AuthId master -> HandlerT master IO DeskComUserSource

Gather information that should be given to about an user. Please see DeskComUser for more information about what these fields mean.

Simple example:

 deskComUserInfo uid = do
   user <- runDB $ get uid
   return def { duName  = userName user
              , duEmail = userEmail user }

Advanced example:

 deskComUserInfo uid = do
   render <- getUrlRender
   runDB $ do
     Just user <- get uid
     Just org  <- get (userOrganization user)
     return def { duName           = userName user
                , duEmail          = userEmail user
                , duOrganization   = Just (organizationName org)
                , duRemotePhotoURL = Just (render $ UserPhotoR uid)

Note: although I don't recomend this and I don't see any reason why you would do it, it is possible to use maybeAuth instead of requireAuth and login on with some sort of guest user should the user not be logged in.

deskComTokenTimeout :: master -> NominalDiffTimeSource

Each time we login an user on, we create a token. This function defines how much time the token should be valid before expiring. Should be greater than 0. Defaults to 5 minutes.



:: Text

The name of your site (e.g., "foo" if your site is at

-> Text

The domain of your site (e.g. "").

-> Text

The Multipass API key, a shared secret between and your site.

-> DeskComCredentials 

Create the credentials data type used by this library. This function is relatively expensive (uses SHA1 and AES), so you'll probably want to cache its result.

data DeskComCredentials Source

Credentials used to access your's Multipass.

data DeskComUser Source

Information about a user that is given to DeskCom. Please see's documentation ( in order to see more details of how theses fields are interpreted.

Only duName and duEmail are required. We suggest using def.




duName :: Text

User name, at least two characters. (required)

duEmail :: Text

E-mail address. (required)

duUserId :: DeskComUserId expects an string to be used as the ID of the user on their system. Defaults to UseYesodAuthId.

duCustomFields :: [DeskComCustomField]

Custom fields to be set.

duRedirectTo :: Maybe Text

When Just url, forces the user to be redirected to url after being logged in. Otherwise, the user is redirected either to the page they were trying to view (if any) or to your portal page at


data DeskComUserId Source

Which external ID should be given to



Use the user ID from persistent's database. This is the recommended and default value.

Explicit Text

Use this given value.

type DeskComCustomField = (Text, Text)Source

The value of a custom customer field as (key, value). Note that you have prefix your key with "custom_".

data DeskCom Source

Data type for yesod-auth-deskCom's subsite.

initDeskCom :: IO DeskComSource

Initialize the DeskCom subsite with a fresh CPRNG.

deskComLoginRoute :: Route DeskComSource

Redirect the user to such that they're already logged in when they arrive. For example, you may use deskComLoginRoute as the login URL on Multipass config.

deskComMaybeLoginRoute :: Route DeskComSource

If the user is logged in, redirect them to such that they're already logged in when they arrive (same as deskComLoginRoute). Otherwise, redirect them to without asking for credentials. For example, you may use deskComMaybeLoginRoute when the user clicks on a "Support" item on a menu.