1.1.0 • Published 5 years ago

hapi-oauth2-server v1.1.0

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
5 years ago

hapi-oauth2-server

OAuth2-Server plugin for Hapi.js

npm pipeline status coverage report npm dev dependency version Snyk Vulnerabilities for npm package

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

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago