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

Safe HaskellNone

Web.Simple.Auth

Description

Provides HTTP Basic Authentication.

Synopsis

Documentation

type AuthRouter r a = (Request -> ByteString -> ByteString -> Controller r (Maybe Request)) -> Controller r a -> Controller r aSource

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

basicAuthRoute :: String -> AuthRouter r aSource

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

basicAuthSource

Arguments

:: String

Realm

-> ByteString

Username

-> ByteString

Password

-> Controller r a 
-> Controller r a 

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 Route.

authRewriteReq :: AuthRouter r a -> (ByteString -> ByteString -> Controller r Bool) -> Controller r a -> Controller r aSource

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