hapi-oauth2-server
v1.1.0
Published
OAuth2-Server plugin for Hapi.js
Downloads
4
Maintainers
Readme
hapi-oauth2-server
OAuth2-Server plugin for Hapi.js
Installation
$ npm install -s hapi-oauth2-server
Quick Start
const OAuthPlugin = require('hapi-oauth2-server');
const server = Hapi.server({
port: 3002,
host: 'localhost',
});
app = {
start: async () => {
await server.register({
OAuthPlugin,
options: {
schemeName: 'test', // Default: oauthSchema
strategyName: 'test', // Default: oauth
model: { // Required
// Read https://oauth2-server.readthedocs.io/en/latest/model/spec.html
},
scheme(oauth) { // Optional
// Read https://hapijs.com/api#-serverauthschemename-scheme
return (serv, opts) => {
// See docs
};
},
handler(oauth) { // Optional
// Read https://hapijs.com/api#server.auth.strategy()
return req => {
// See docs
};
},
},
});
await server.start();
},
stop: async () => {
return server.stop({ timeout: 10000 });
},
server,
};
await app.start();
Globals
const Request = OAuthPlugin.Request;
const Response = OAuthPlugin.Response;