lio-simple-0.0.2.2: LIO support for the Simple web framework

Safe HaskellTrustworthy

LIO.Web.Simple.Auth

Contents

Description

Provides generic and HTTP Basic authentication.

Synopsis

Documentation

basicAuthSource

Arguments

:: Monad m 
=> String

Realm

-> (ByteString -> ByteString -> m Bool) 
-> SimpleMiddleware m 

A middleware that uses HTTP basic authentication to authenticate a request for a realm with the given username and password. The request is rewritten with an X-User request header containing the authenticated username before being passed to the next application. Note that the HTTP basic authentication header is only set if the executed app requests it, by setting the X-Login response header (e.g., with requestLogin).

handleAuth :: Monad m => SimpleApplication m -> SimpleMiddleware mSource

Executes the app and if the app Response has header X-Login and the user is not logged in, i.e., the X-User request header is not present, execute the login application.

requestLogin :: ResponseSource

Request authentication middleware to authenticate user

Helpers

withUserOrLogin :: Monad m => (ByteString -> ControllerT r m a) -> ControllerT r m aSource

Execute action with the current user's name. Otherwise, request that the user authenticate.

currentUser :: Monad m => ControllerT r m (Maybe ByteString)Source

Get the current user.