Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brooksn/koa-hawk
Koa hawk authentication middleware
https://github.com/brooksn/koa-hawk
Last synced: about 2 months ago
JSON representation
Koa hawk authentication middleware
- Host: GitHub
- URL: https://github.com/brooksn/koa-hawk
- Owner: brooksn
- Created: 2015-04-29T18:48:37.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-08T23:01:27.000Z (over 9 years ago)
- Last Synced: 2024-11-11T18:47:04.225Z (about 2 months ago)
- Language: JavaScript
- Size: 148 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# koa-hawk
Koa hawk authentication middleware[![npm version](https://badge.fury.io/js/koa-hawk.svg)](http://badge.fury.io/js/koa-hawk)
[![Build Status](https://travis-ci.org/brooksn/koa-hawk.svg?branch=master)](https://travis-ci.org/brooksn/koa-hawk)## Installation
```js
$ npm install koa-hawk
```## Usage
```js
var koa = require('koa');
var hawk = require('koa-hawk');var app = koa();
var getCredentials = function (id, callback) {
var credentials = {
key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
algorithm: 'sha256',
user: 'Steve'
};
return callback(null, credentials);
};app.use(hawk(getCredentials));
app.use(function* (next){
if (this.hawk.authorized === true) this.response.body = 'Welcome!';
});app.listen(3000);