[Haskell-cafe] happstack-authenticate 2

Corentin Dupont corentin.dupont at gmail.com
Tue Aug 4 10:51:13 UTC 2015


I need to store authenticateState in the state because I use it latter to
retrieve the user ID, name and email.
So I created a new layer in my state structure to store both
authenticateState and routeAuthentication.

On Tue, Aug 4, 2015 at 6:20 AM, Jeremy Shaw <jeremy at n-heptane.com> wrote:

> Hello,
>
> The tough problem that happstack-authenticate faces is that it has to be
> application agnostic. It doesn't really know much at all about how your
> application handles routing, how it deals with initializing and cleaning up
> database connections, etc. So, it all it can do is provide you with the
> functions you will need to initialize, route, and shutdown the
> authentication stuff.
>
> routeAuthentication is absolutely necessary -- how else would requests get
> routed to the authentication library?
>
> The authenticateState is provided in case you do want direct access to it,
> and so that you can pass it to routeAuthenticate. But you don't really need
> to carry it around everywhere -- you need only pass it to your routing
> layer.
>
>
> https://github.com/Happstack/happstack-authenticate/blob/master/demo/Main.hs
>
> You can see there that it passes the routeAuthentication function into a
> the 'implSite' in the routing monad. But the values are not stored in State
> or anything.
>
> In the example, everything is done in main :: IO (), because that is
> pretty much all the application does.
>
> In  clckwrks, things are deferred until much later. In fact, the
> authentication layer in clckwrks is implemented as a clckwrks plugin. So,
> it does not initialize the authentication until it gets around to
> initializing the plugins:
>
>
> https://github.com/clckwrks/clckwrks/blob/master/Clckwrks/Authenticate/Plugin.hs
>
>  - jeremy
>
> On Mon, Aug 3, 2015 at 6:02 AM, Corentin Dupont <corentin.dupont at gmail.com
> > wrote:
>
>> Hello,
>>
>> I'm a bit confused about the routeAuthenticate and authenticateState
>> bits in the new happstack-authenticate.
>>
>> It seems that I have to do this in the beginning of my application:
>>
>> (_, routeAuthenticate, authenticateState) <-
>>       liftIO $ initAuthentication Nothing (const $ return True)
>>         [ initPassword "http://localhost:8000/#resetPassword" "
>> example.org"
>>         , initOpenId]
>>
>> Where this should be done? In the main? If possible I'd prefer to delay
>> it because my main is web-agnotic.
>> Where should I store those two values? Should I put them in my monad
>> stack (I have a StateT)?
>> Is the routeAuthenticate really necessary? It looks a bit cumbersome to
>> carry it around everywhere in the states.
>>
>> Thanks,
>> Corentin
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "HAppS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to happs+unsubscribe at googlegroups.com.
>> To post to this group, send email to happs at googlegroups.com.
>> Visit this group at http://groups.google.com/group/happs.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150804/8d3f68ef/attachment-0001.html>


More information about the Haskell-Cafe mailing list