wai-middleware-bearer
WAI Middleware for Bearer Token Authentication
https://github.com/martin-bednar/wai-middleware-bearer#readme
LTS Haskell 23.27: | 1.0.3 |
Stackage Nightly 2025-07-13: | 1.0.3 |
Latest on Hackage: | 1.0.3 |
MIT licensedbyMartin Bednar
Maintained by[email protected]
This version can be pinned in stack with:
wai-middleware-bearer-1.0.3@sha256:bc3e7edbfe0fe9a2bed5c538a009a1a53cace5eae3871dfc29572ddb54fca502,1675
Module documentation for 1.0.3
- Network
- Network.Wai
- Network.Wai.Middleware
- Network.Wai
Depends on 5 packages(full list with versions):
wai-middleware-bearer
WAI middleware providingbearer token authentication.
Usage example
The following code shows a secureHello World application:
{-# LANGUAGE OverloadedStrings #-}module Main whereimport Network.Wai.Middleware.BearerTokenAuthimport Network.Waiimport Network.HTTP.Types.Status (status200)import Network.Wai.Handler.Warp (run)myApp :: ApplicationmyApp req rsp = rsp $ responseLBS status200 [] "Hello World"secureApp :: ApplicationsecureApp = tokenListAuth ["abc", "123"] myAppmain :: IO ()main = run 3000 secureApp
Valid token request example (200 OK):
$ curl -H "Authorization: bearer abc" 'localhost:3000'Hello World⏎
Invalid token request example (401 Unauthorized):
$ curl -H "Authorization: bearer otherToken" 'localhost:3000'Bearer token authentication is required⏎
Missing token request example (401 Unauthorized):
curl 'localhost:3000'Bearer token authentication is required⏎