Skip to content

OpenID Provider(OP) implementation for node.js servers. It provides a mountable or standalone implementation of the specifications including a plenty optional features.

License

Notifications You must be signed in to change notification settings

stavros-wb/node-oidc-provider

 
 

Repository files navigation

oidc-provider

build codecov snyk

oidc-provider is an OpenID Provider implementation of OpenID Connect. It allows to export a complete mountable or standalone OpenID Provider implementation. This implementation does not dictate a fixed data model or persistence store, instead, you must provide adapters for these. A generic in-memory adapter is available to get you started as well as feature-less dev-only views to be able to get off the ground.

Table of Contents

Implemented specs & features

The following specifications are implemented by oidc-provider. Note that not all features are enabled by default, check the configuration section on how to enable them.

The following drafts/experimental specifications are implemented by oidc-provider.

Updates to draft and experimental specification versions are released as MINOR library versions, if you utilize these specification implementations consider using the tilde ~ operator in your package.json since breaking changes may be introduced as part of these version updates.

Certification

OpenID Certification
Filip Skokan has certified that oidc-provider conforms to the OP Basic, OP Implicit, OP Hybrid, OP Config and OP Dynamic profiles of the OpenID Connect™ protocol.

build

Sponsor

auth0-logo If you want to quickly add OpenID Connect authentication to Node.js apps, feel free to check out Auth0's Node.js SDK and free plan at auth0.com/overview.

Get started

You may follow an example step by step setup (recommended), or run and experiment with an example server that's part of the repo (if you can follow the structure, if not check the step by step).

The example bundled in this repo's codebase is available for you to experiment with here. Dynamic Registration is open, you can literally register any client you want there.
An example client using this provider is available here (uses openid-client).

Configuration and Initialization

oidc-provider allows to be extended and configured in various ways to fit a variety of uses. See the available configuration.

const Provider = require('oidc-provider');
const configuration = {
  // ... see available options /docs/configuration.md
};
const clients = [{
  client_id: 'foo',
  client_secret: 'bar',
  redirect_uris: ['http://lvh.me:8080/cb'],
  // + other client properties
}];

const oidc = new Provider('http://localhost:3000', configuration);

(async () => {
  await oidc.initialize({ clients });
  // oidc.callback => express/nodejs style application callback (req, res)
  // oidc.app => koa2.x application
  oidc.listen(3000);
  console.log('oidc-provider listening on port 3000, check http://localhost:3000/.well-known/openid-configuration');
})().catch((err) => {
  console.error(err);
  process.exitCode = 1;
});

Debugging

oidc-provider uses the debug module internally to log information about various states of authentication requests, errors and grants. To see all these set the DEBUG environment variable to oidc-provider:* when launching your app.

There is no filter on what is included in the debug output, since it may end-user Personally identifiable information or client credentials it's use is only advised for debugging, not regular logging. Use emitted events to cherry pick the one's of interest to your flows and form your own logs aware of what should and should not be a part of a logged message.

Events

Your oidc-provider instance is an event emitter, using event handlers you can hook into the various actions and i.e. emit metrics or that react to specific triggers. In some scenarios you can even change the defined behavior.
See the list of available emitted event names and their description.

About

OpenID Provider(OP) implementation for node.js servers. It provides a mountable or standalone implementation of the specifications including a plenty optional features.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.3%
  • HTML 0.7%