Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-oidc

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-oidc

Hapi authentication strategy for OpenID Connect

  • 1.2.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Hapi-OIDC

OpenID-Connect authentication plugin for hapi.

Configuration

This plugin needs some configuration to discover and connect to the OIDC server:

  • discoverUrl: The discovery URL of your OIDC server
  • clientId: Client ID given by your OIDC server
  • clientSecret: Client secret given by your OIDC server
  • callbackUrl: The full URL that the server will call after the authorization process
  • [cookie]: Name of the cookie that will held the authentication. Defaults to hapi-oidc

When registering the oidc scheme, you'll need to configure the cookie settings if defaults do not suits you:

  • password=uuid4(),
  • [path='/']
  • [ttl= 3600 * 1000]
  • [encoding='iron']
  • [isSecure=true],
  • [clearInvalid=true]

Example

const Hapi = require('hapi');
const uuid4 = require('uuid/v4');
const OIDC = require('hapi-oidc');

const routes = require('./routes');

const server = Hapi.server({
  port: 3000,
});

const init = async () => {
  await server.register([
    {
      plugin: OIDC,
      options: {
        discoverUrl: 'https://oidc-server.com/oauth2/default',
        clientId: 'XXXXXXXXXXXXXXX',
        clientSecret: 'XXXXXXXXXXXXXXXXXXXXXX',
        callbackUrl: 'https://my-server:3000/login_callback',
      },
    }
  ]);

  server.auth.strategy('oidc', 'oidc', {
    password: uuid4(),
  });

  server.route(routes);
  await server.start();
  server.log(['info'], `Server running at: ${server.info.uri}`);
};

init();

module.exports = server;

Keywords

FAQs

Package last updated on 12 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc