Safe Haskell | None |
---|---|
Language | Haskell2010 |
Implements HTTP Bearer Token Authentication.
This module is based on HttpAuth
.
Synopsis
- tokenAuth :: CheckToken -> Middleware
- tokenAuth' :: (Request -> CheckToken) -> Middleware
- tokenListAuth :: [ByteString] -> Middleware
- type CheckToken = ByteString -> IO Bool
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.