wai-middleware-bearer-1.0.0.0: WAI middleware providing the Bearer Token HTTP authentication scheme.
Safe HaskellNone
LanguageHaskell2010

Network.Wai.Middleware.BearerTokenAuth

Description

Implements HTTP Bearer Token Authentication.

This module is based on HttpAuth.

Synopsis

Documentation

tokenAuth :: CheckToken -> Middleware Source #

Perform token authentication.

If the token is accepted, leave the Application unchanged. Otherwise, send a 401 Unauthorized HTTP response.

tokenAuth (\tok -> return $ tok == "abcd" )

tokenAuth' :: (Request -> CheckToken) -> Middleware Source #

Like tokenAuth, but also passes a request to the authentication function.

tokenListAuth :: [ByteString] -> Middleware Source #

Perform token authentication based on a list of allowed tokens.

tokenListAuth ["secret1", "secret2"]

type CheckToken = ByteString -> IO Bool Source #

Check if a given token is valid.