Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oakfang/oompa-token
An authentication middleware for Oompa
https://github.com/oakfang/oompa-token
Last synced: 6 days ago
JSON representation
An authentication middleware for Oompa
- Host: GitHub
- URL: https://github.com/oakfang/oompa-token
- Owner: oakfang
- License: mit
- Created: 2016-07-10T12:53:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-10T21:16:45.000Z (over 8 years ago)
- Last Synced: 2024-11-09T18:19:13.091Z (2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# oompa-token
An authentication middleware for Oompa## Usage
```js
const Oompa = require('oompa');
const tokenize = require('oompa-token');
const schema = require('./schema');const SECRET = 'foobar';
const server = new Oompa(schema);
server.use(tokenize(SECRET, 'LOGIN'));server.listen(9000);
```## Why?
Using `oompa-token` allows you to utilize JWT to cache expensive authentication procedures.### `require('oompa-token')(secret:String, login:String, expiration:Optional)`
- **secret** is the application secret used to sign and verify the JWT tokens. Keep it safe.
- **login** is the task type you use to authenticate users. This task should actually authenticate a user, and return the user object on a successful authentication.
- **expiration** is the optional expiration, in *seconds*, of a created token, after which authentication will fail.### Side Effects
Every task that requires authentication must have a `token` key in its payload. Should the token be verified, the request will gain a `user` key with the user object.