-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Yesod Middleware for HTTP Basic Authentication
--   
--   An efficient Yesod middleware middleware for HTTP Basic
--   Authentication.
--   
--   Utilizes Yesod request-local caching mechanisms to store valid auth
--   credentials found in the Authorization header.
@package yesod-auth-basic
@version 0.1.0.2


-- | A Yesod middleware for
--   
--   Performs a single authentication lookup per request and uses the
--   &lt;&lt;<a>https://github.com/yesodweb/yesod/blob/7f775e1ddebaeb4b8509b512b6d4b539d96258bd/yesod-core/Yesod/Core/TypeCache.hs#L21</a>
--   Yesod request-local caching&gt;&gt; mechanisms to store valid auth
--   credentials found in the Authorization header.
--   
--   The recommended way to use this module is to override the
--   <tt>maybeAuthId</tt> to <tt>defaultMaybeBasicAuthId</tt> and supply a
--   lookup function.
--   
--   <pre>
--   instance YesodAuth App where
--       type AuthId App = Text
--       getAuthId = return . Just . credsIdent
--       maybeAuthId = defaultMaybeBasicAuthId checkCreds defaultAuthSettings
--         where
--           checkCreds = k s -&gt; return $ (k == "user")
--                                      &amp;&amp; (s == "secret")
--   </pre>
--   
--   WWW-Authenticate challenges are currently not implemented. The current
--   workaround is to override the error handler:
--   
--   <pre>
--   instance Yesod App where
--     errorHandler NotAuthenticated = selectRep $
--         provideRep $ do
--           addHeader <a>WWW-Authenticate</a> $ T.concat
--                 [ "RedirectJSON realm="Realm", param="myurl.com"" ]
--           -- send error response here
--           ...
--     errorHandler e = defaultErrorHandler e
--     ...
--   </pre>
--   
--   Proper response status on failed authentication is not implemented.
--   The current workaround is to override the <a>Yesod</a> typeclass
--   <tt>isAuthorized</tt> function to handle required auth routes. e.g.
--   
--   <pre>
--   instance Yesod App where
--     isAuthorized SecureR _   =
--       maybeAuthId &gt;&gt;= return . maybe AuthenticationRequired (const Authorized)
--     isAuthorized _ _         = Authorized
--   </pre>
module Yesod.Auth.Http.Basic

-- | Retrieve the <tt>AuthId</tt> using Authorization header.
--   
--   If valid credentials are found and authorized the auth id is cached.
--   
--   TODO use more general type than Text to represent the auth id
defaultMaybeBasicAuthId :: (MonadIO m, MonadThrow m, MonadBaseControl IO m) => CheckCreds -> AuthSettings -> HandlerT site m (Maybe Text)

-- | Authentication Settings
data AuthSettings
authRealm :: AuthSettings -> Text

-- | ready-to-go <a>AuthSettings</a> which can be used
defaultAuthSettings :: AuthSettings
