mtintes / openid-client-server

An OpenId Relying Party (RP, Client) application server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

openid-client-server

An OpenId Relying Party (RP, Client) application server.

This module leverages the openid-client module to implement a web server that secures any Web UI framework that can be hosted by Node.js with Authorization Code Flow (optional Proof Key), Implicit Flow or Hybrid Flow. The module also provides configurable proxy endpoints that include the user token automatically in requests to API endpoints, as well a session management making it easier to create Web UI's that are "secure by default".

Install

with npm

$ npm install @optum/openid-client-server

with yarn

$ yarn add @ooptum/openid-client-server

Usage

Options

The resolveOptions function will leverage environmental variables to auto-build all options with defaults. It can be required in the server setup module via import {resolveOptions} from '@optum/openid-client-server.

For more info see the .env.example file

RequestListener

Use the createRequestListener function to create a http module RequestListener. It can be required in the server setup module via import {createRequestListener} from '@optum/openid-client-server.

For more info see the examples folder

Background

The original goal of this module was to provide as easy way to implement OpenID flows with Next.js applications via a custom Next.js server. There were issues leveraging frameworks like Koa.js for "easy wins" in session management and out-of-the-box middleware, so tides turned to using Node's core http module. The result ended up working for any Web UI that could be served by Node.js, so here we are.

Development

Environment

  • Node.js is required to develop this module. Please install the latest LTS version if you haven't already.
  • Module dependencies are managed with Yarn. Please install it if you haven't already.
    $ npm i -g yarn

Editors

VS Code

extensions

settings.json

{
    "xo.enable": true,
    "xo.format.enable": true,
    "javascript.format.enable": false,
    "javascript.validate.enable": false,
    "prettier.tabWidth": 4,
    "prettier.singleQuote": true,
    "editor.formatOnSave": true,
    "sort-imports.on-save": true,
    "sort-imports.cache-package-json-config-checks": true,
    "[typescriptreact]": {
        "editor.defaultFormatter": "samverschueren.linter-xo"
    },
    "[typescript]": {
        "editor.defaultFormatter": "samverschueren.linter-xo"
    },
    "[javascript]": {
        "editor.defaultFormatter": "samverschueren.linter-xo"
    },
    "[json]": {
        "editor.defaultFormatter": "euskadi31.json-pretty-printer"
    }
}

About

An OpenId Relying Party (RP, Client) application server.

License:Apache License 2.0


Languages

Language:TypeScript 100.0%