npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@watchmen/oidc-proxy

v3.4.1

Published

a pattern using express for server side [openid-connect](https://openid.net/connect/) (oidc) support.

Downloads

7

Readme

node-oidc-proxy

a pattern using express for server side openid-connect (oidc) support.

XO code style styled with prettier Build Status npm (scoped)

details include:

  • an auth grant flow
  • storing tokens in session
  • a proxy for decorating api calls with a token obtained from session

testing against oidc compliant idp

  1. set up an appropriate config in the config folder, for example:

    keycloak.js

    module.exports = {
    	oauth: {
    		issuer: {
    			url: `https://keycloak.something.com/auth/realms/realm-1`
    		},
    		client: {
    			id: 'client-1',
    			secret: 's3cret'
    		}
    	}
    }
  2. add the following to list of allowed redirects for client specified in config:

    • http://localhost:3000/auth/cb
    • http://localhost:3000/logout/cb
  3. start server and redirect listener

    env DEBUG=dbg:*,app:*,lib:*,test:* NODE_ENV=keycloak npx babel-node test/shared/run-proxy-and-redirect
  4. hit localhost:3000/login

  5. if configuration is valid, this should forward you to the authentication page of the idp

  6. enter valid credentials

  7. if credentials are valid, you should see a response delivered to the browser from the redirect listener, something like:

    {
      "id_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJqR1k3YU1aYjVqMDlqWmJzTlpneDRra0dKd3BvaUFRNmdMUTVybmlVYzdZIn0.eyJqdGkiOiI2MGI5ZDc5Ny1jNDIzLTRmNjItYjQyYi1kYWVjYWVmY2NhNmYiLCJleHAiOjE1NTgzMDAzNzIsIm5iZiI6MCwiaWF0IjoxNTU4Mjk4NTcyLCJpc3MiOiJodHRwczovL2tleWNsb2FrLmxhYi5oY2kuYWV0bmEuY29tL2F1dGgvcmVhbG1zL21hc3RlciIsImF1ZCI6InBpbmVhcHBsZS1jbGllbnQiLCJzdWIiOiI0OWRmMDVjZi1kODFkLTRkODMtOTZlNS0zMzI2OWY2ZWM2NGUiLCJ0eXAiOiJJRCIsImF6cCI6InBpbmVhcHBsZS1jbGllbnQiLCJub25jZSI6InR5VXpvakhQVFhGMzNmemFIRU1SeUpmVDRpZGFnR2VLSFBsbVpDdjZLbXMiLCJhdXRoX3RpbWUiOjE1NTgyOTg1NzIsInNlc3Npb25fc3RhdGUiOiI3YjdiMDQ3ZC01YmQ5LTQyOTMtYThjYS1kNzllYzI5ZWE0OTgiLCJhY3IiOiIxIiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJuYW1lIjoiTk9FTCBDVVRDSElOUyIsInByZWZlcnJlZF91c2VybmFtZSI6IjE3b3lhenBuanI5OXZiYm43enA4QGFldG5hZS5jb20iLCJwcm94eV9pZCI6IkY5NlYyMTExQlBYWSIsImdpdmVuX25hbWUiOiJOT0VMIiwiZmFtaWx5X25hbWUiOiJDVVRDSElOUyIsImhlYWx0aF9jbG91ZF9pZCI6ImU5M2ZhOWU5LWY5ZTYtNGYxYy05ZGU5LTY0OWE2MTA0ZjI3ZCJ9.DrBrZK8Z_QUsBKs-5VjeI1hE4-nTqg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NzIsIm5iZiI6MCwiaWF0IjoxNTU4Mjk4NTcyLCJpc3MiOiJodHRwczovL2tleWNsb2FrLmxhYi5oY2kuYWV0bmEuY29tL2F1dGgvcmVhbG1zL21hc3RlciIsImF1ZCI6Imh0dHBzOi8va2V5Y2xvYWsubGFiLmhjaS5hZXRuYS5jb20vYXV0aC9yZWFsbXMvbWFzdGVyIiwic3ViIjoiNDlkZjA1Y2YtZDgxZC00ZDgzLTk2ZTUtMzMyNjlmNmVjNjRlIiwidHlwIjoiUmVmcmVzaCIsImF6cCI6InBpbmVhcHBsZS1jbGllbnQiLCJub25jZSI6InR5VXpvakhQVFhGMzNmemFIRU1SeUpmVDRpZGFnR2VLSFBsbVpDdjZLbXMiLCJhdXRoX3RpbWUiOjAsInNlc3Npb25fc3RhdGUiOiI3YjdiMDQ3ZC01YmQ5LTQyOTMtYThjYS1kNzllYzI5ZWE0OTgiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsib2ZmbGluZV9hY2Nlc3MiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImJyb2tlciI6eyJyb2xlcyI6WyJyZWFkLXRva2VuIl19LCJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGVtYWlsIn0.PamBr4K_-D9Y-befP2o2bUS4YguNDLFlXtfbmIFLDmU"
    }
  8. to call a service decorated with a header like:

    Authentication: Bearer {the-access-token}

    use:

    http://localhost:3000/proxy/{the-route-of-the-target-service}

    for example:

    http://localhost:3000/proxy/express-js-scratch-dev
  9. to logout from the session with the identity-provider, use:

    http://localhost:3000/logout