Authentication in Snap
In this recipe, we will work with authentication with help of the built-in authentication manager in snap. Snap provides a framework that can be tied to HTML templates to provide a customizable authentication mechanism. In this recipe, we will have a few routes requiring authentication, and a few without it. We will see how transitioning from one route to another requiring authentication kicks in the authentication framework.
We will also work with the SQLite backend for storing user credentials.
How to do it...
- Create a new project,
auth-in-snap
, with asimple
stack template:
stack new auth-in-snap simple
- Add a dependency on the
snap-core
library in thebuild-depends
subsection of theexecutable
section.
executable auth-in-snap hs-source-dirs: src main-is: Main.hs default-language: Haskell2010 build-depends: base >= 4.7 && < 5 , snap-core , snap-server ...