simple-0.4.1: A minimalist web framework for the WAI server interface

Safe HaskellNone

Web.Simple.Auth

Synopsis

Documentation

type AuthRouter r = Routeable r => (Request -> ByteString -> ByteString -> IO (Maybe Request)) -> r -> Route ()Source

An AuthRouter authenticates a Request and, if successful, forwards the Request to the Routeable.

basicAuthRoute :: String -> AuthRouter rSource

An AuthRouter that uses HTTP basic authentication to authenticate a request in a particular realm.

authRewriteReq :: Routeable r => AuthRouter r -> (ByteString -> ByteString -> IO Bool) -> r -> Route ()Source

Wraps an AuthRouter to take a simpler authentication function (that just just takes a username and password, and returns True or False). It also adds an "X-User" header to the Request with the authenticated user's name (the first argument to the authentication function).

basicAuth :: Routeable r => String -> ByteString -> ByteString -> r -> Route ()Source

A Route that uses HTTP basic authentication to authenticate a request for a realm with the given username ans password. The request is rewritten with an 'X-User' header containing the authenticated username before being passed to the next next Route.