Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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);