{"id":18539085,"url":"https://github.com/simov/grant-oidc","last_synced_at":"2025-04-09T17:38:09.128Z","repository":{"id":57253094,"uuid":"156364246","full_name":"simov/grant-oidc","owner":"simov","description":"OpenID Connect middleware for Grant","archived":false,"fork":false,"pushed_at":"2019-10-28T14:01:48.000Z","size":20,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T09:47:00.376Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-06T10:10:04.000Z","updated_at":"2020-04-30T14:24:45.000Z","dependencies_parsed_at":"2022-08-31T22:11:19.614Z","dependency_job_id":null,"html_url":"https://github.com/simov/grant-oidc","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-oidc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-oidc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-oidc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-oidc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simov","download_url":"https://codeload.github.com/simov/grant-oidc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248078604,"owners_count":21044141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T19:46:10.108Z","updated_at":"2025-04-09T17:38:08.813Z","avatar_url":"https://github.com/simov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# grant-oidc\n\n[![npm-version]][npm] [![travis-ci]][travis]\n\n\u003e *`id_token` validation middleware for [Grant][grant]*\n\n- IdP configuration discovery *(no caching)*\n- IdP public keys discovery *(no caching)*\n- `id_token` validation including its signature\n\n## Configuration\n\n\u003e **grant-oidc accepts your Grant [configuration][grant-config]**\n\n## Middlewares\n\nFor Express and Koa grant-oidc needs to be mounted after Grant, and before any of the callback URLs defined in your Grant configuration.\n\n## Express\n\n```js\nvar express = require('express')\nvar session = require('express-session')\nvar grant = require('grant-express') // or require('grant').express()\nvar oidc = require('grant-oidc').express()\nvar config = require('./config.json')\n\nexpress()\n  .use(session({name: 'grant', secret: 'grant', saveUninitialized: true}))\n  .use(grant(config))\n  .use(oidc(config))\n  .get('/hi', (req, res) =\u003e {\n    res.end(JSON.stringify(req.session.grant.response, null, 2))\n  })\n  .listen(3000)\n```\n\n## Koa\n\n```js\nvar Koa = require('koa')\nvar session = require('koa-session')\nvar grant = require('grant-koa') // or require('grant').koa()\nvar oidc = require('grant-oidc').koa()\nvar config = require('./config.json')\n\nvar app = new Koa()\napp.keys = ['grant']\napp.use(session(app))\napp.use(grant(config))\napp.use(oidc(config))\napp.use((ctx, next) =\u003e {\n  if (ctx.path === '/hi') {\n    ctx.body = JSON.stringify(ctx.session.grant.response, null, 2)\n  }\n})\napp.listen(3000)\n```\n\n## Hapi\n\n```js\nvar Hapi = require('hapi')\nvar yar = require('yar')\nvar grant = require('grant-hapi') // or require('grant').hapi()\nvar oidc = require('grant-oidc').hapi()\nvar config = require('./config.json')\n\nvar server = new Hapi.Server({host: 'localhost', port: 3000})\n\nserver.route({method: 'GET', path: '/hi', handler: (req, res) =\u003e {\n  return res.response(JSON.stringify(req.yar.get('grant').response, null, 2))\n    .header('content-type', 'text/plain')\n}})\n\nserver.register([\n  {plugin: grant(), options: config},\n  {plugin: oidc(), options: config},\n  {plugin: yar, options: {cookieOptions: {password: '01234567890123456789012345678912', isSecure: false}}},\n])\n.then(() =\u003e server.start())\n```\n\n## Example\n\n```json\n{\n  \"defaults\": {\n    \"protocol\": \"http\",\n    \"host\": \"localhost:3000\",\n    \"transport\": \"session\",\n    \"state\": true,\n    \"nonce\": true,\n    \"scope\": [\n      \"openid\"\n    ],\n    \"callback\": \"/hi\"\n  },\n  \"asana\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"auth0\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"authentiq\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"google\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"ibm\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"line\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"microsoft\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"okta\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"onelogin\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"paypal\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"phantauth\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"salesforce\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"twitch\": {\"key\": \"...\", \"secret\": \"...\"},\n  \"yahoo\": {\"key\": \"...\", \"secret\": \"...\" }\n}\n```\n\n## Quirks\n\n- Google issuer URL doesn't have protocol\n\n- Paypal issuer have different domain than the configuration URL\n- Paypal returns the `idp` configuration JSON with wrong _content-type_\n\n- Asana doesn't return `kid` in the header, and a single key is found in `jwks_uri` that should be picked\n- Asana doesn't honor the `nonce` parameter and doesn't embed it in the `id_token`\n\n\n  [npm-version]: https://img.shields.io/npm/v/grant-oidc.svg?style=flat-square (NPM Version)\n  [travis-ci]: https://img.shields.io/travis/simov/grant-oidc/master.svg?style=flat-square (Build Status)\n  [coveralls-status]: https://img.shields.io/coveralls/simov/grant-oidc.svg?style=flat-square (Test Coverage)\n\n  [npm]: https://www.npmjs.com/package/grant-oidc\n  [travis]: https://travis-ci.org/simov/grant-oidc\n  [coveralls]: https://coveralls.io/r/simov/grant-oidc?branch=master\n\n  [grant]: https://github.com/simov/grant\n  [grant-config]: https://github.com/simov/grant#configuration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimov%2Fgrant-oidc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimov%2Fgrant-oidc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimov%2Fgrant-oidc/lists"}