README
BA
basic auth
Install
npm install polywoo-ba
Usage
Create auth header
import { BAAuth } from 'polywoo-ba';
const ba = BAAuth(clientId, clientSecret);
const header = ba('post', '/somepath', new Date());
// header example
{
Date: Fri, 29 Mar 2019 23:34:53 GMT
Authorization:POLYWOO abc:frJIzyUNadUthaoUDzLCwozllqg=
}
Verify middleware
import { middleware } from 'polywoo-ba';
// koa app
app.use(
middleware({
includeUriList: ['/auth/*'],
excludeUriList: ['/anoy/*'],
getApp: clientId => {
// find ba app info
return {
client_id: 'abc',
client_secret: 'xxx'
};
}
})
);
// access ba user info
ctx.baUser;