servant-auth-token

Servant based API and server for token based authorisation https://github.com/ncrashed/servant-auth-token#readme

Latest on Hackage:0.4.2.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by NCrashed
Maintained by ncrashed@gmail.com

servant-auth-token

Build Status

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

Changes

0.4.2.0

  • Add implementation for AuthCheckPermissionsMethod and AuthGetUserIdMethod endpoints.

0.4.1.1

  • Relax aeson and opt-parse-applicative bounds.
  • Add monad-control instances.

0.4.1.0

  • Remove persistent dependencies from abstract package.

0.4.0.0

  • Abstract over storage: persistent and acid-state backends.

0.3.2.0

  • Support lts-7.1 (ghc 8 and persistent-0.6)

0.3.0.0

  • Add authorisation by single usage codes.

0.2.0.1

  • Relax boundaries for ghc 8.0.1.

0.2.0.0

  • Implement servant-auth-token-0.2.0.0 API.

0.1.2.0

  • Expose implementation of API for embedding in complex servers.

0.1.1.0

  • Added restoreCodeGenerator to configuration

0.1.0.0

  • Initial publication
comments powered byDisqus