@hackage servant-auth-token0.5.6.0
Servant based API and server for token based authorisation
Categories
License
BSD-3-Clause
Maintainer
ncrashed@gmail.com
Links
Versions
Installation
Dependencies (16)
- aeson-injector >=1.1 && <1.2
- base >=4.8 && <5
- byteable >=0.1 && <0.2
- bytestring >=0.10 && <0.11
- containers >=0.5 && <0.6
- http-api-data >=0.3.5 && <0.4 Show all…
Dependents (5)
@hackage/servant-auth-token-persistent, @hackage/servant-auth-token-acid, @hackage/pdf-slave-server, @hackage/servant-auth-token-rocksdb, @hackage/servant-auth-token-leveldb
servant-auth-token
The repo contains server implementation of servant-auth-token-api.
How to add to your server
At the moment you have two options for backend storage:
-
persistent backend - persistent backend, simple to integrate with your app.
-
acid-state backend - acid-state backend is light solution for in memory storage, but it is more difficult to integrate it with your app.
-
Possible candidates for other storage backends: VCache, leveldb, JSON files. To see how to implement them, see HasStorage type class.
Now you can use 'guardAuthToken' to check authorization headers in endpoints of your server:
-- | Read a single customer from DB
customerGet :: CustomerId -- ^ Customer unique id
-> MToken '["customer-read"] -- ^ Required permissions for auth token
-> ServerM Customer -- ^ Customer data
customerGet i token = do
guardAuthToken token
runDB404 "customer" $ getCustomer i