Jazzy Authenticate
Fast and versatile authentication middleware for Express.js.
Jazzy Authenticate is a flexible and dynamic authentication middleware for express.js. It has been designed to be easy to use, modular, unopinionated and take the complexities out of building authentication into server apps.
While Jazzy Authenticate aims to simplify and speed up the process of adding authentication layers to express apps, it also leaves all of the underlying logic up to the developer, allowing bespoke authentication models to be easily built without hacking the library or using workarounds.
Installation
Ensure you have installed Express.js
$ npm install express
Install jazzy-authenticate
$ npm install jazzy-authenticate
Usage
Use the defineModel function to define an Authentication Model.
defineModel;
The first arguement is the model name. The second the model options. And the third option is whether to set this model to default (meaning it will not have to be refernced in the middleware). If the third arguement is ommited it defaults to false.
Authentication Model Defaults:
The init() middleware must be called at the start of the request straight after the session and parsing middleware.
app.use;app.use;app.use;
Use the authenticate() middleware to authenticate a client.
app.use
You can block routes by using the checkAuthenticated() or checkUnauthenticated() middleware.
app.use
Sometimes you may need different fail, error or success responses to those set in the Authentication Model, for example this api expects a json response.
const overrides =
You can use multiple authentication models in your app.
When you want to use a Model that is not set to default, pass the model name as the first argument to the middleware.
app.post;
For working examples and usage, please refer to the examples section on project Github
Meta
Jazz Brown – jazzbrown200@gmail.com
Distributed under the MIT license. See LICENSE
for more information.
https://github.com/jazzbrown1/jazzy-authenticate
Contributing
- Fork it (https://github.com/jazzbrown1/jazzy-authenticate/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request