Coder Social home page Coder Social logo

sperand-io / link-oidc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eidam/cf-access-workers-oidc

0.0 0.0 0.0 188 KB

OpenID Connect provider completely running on top of Stripe Link and built using Cloudflare Developer Platform (Workers, Durable Objects, etc..)

Home Page: https://workers-oidc-example.eidam.workers.dev

JavaScript 32.38% TypeScript 67.62%

link-oidc's Introduction

Cloudflare Access+Workers OIDC provider

Almost stateless OpenID Connect provider completely running on top of Cloudflare for Teams (Access) and Cloudflare Developers platform (Workers, Durable Objects)

Why its awesome

  • OIDC private key is created on-demand and persisted only in Durable Object memory. The private key automatically rotates with Durable Object scale up/down events.
  • Only OIDC public keys (jwks) are persisted in Durable Object storage for signature verification purposes. Public keys are automatically cleaned up using CRON Triggers once they are no longer needed.
  • Cloudflare Access API is used to fetch and filter user's Access groups, then passed within the ID token as group claims. Applications can scope user permissions based on their groups.

There are some example applications using this OIDC provider, feel free to try them out!

Worker example app

Deployment

Prerequisites

  • Cloudflare account with Workers Paid plan (becuase of Durable Objects) and enabled Cloudflare for Teams
  • Wrangler CLI installed

Cloudflare Access

Cloudflare Access application needs to be deployed to /authorize endpoints (other endpoints are public, 3rd party applications need to be able to fetch JWK keys in order to verify JWTs).

Cloudflare Access Application

Config file

The only file you need to edit in order to deploy your own OIDC provider is config.yml

Following configuration is used and deployed to https://oidc.eidam.dev

cf_account_id: fbbebdb1eed350f2a05f517e1d80915f # Cloudflare Account ID
cf_access_team: eidam # Cloudflare for Teams name
cf_access_aud: d27389ecd9bdc9c651bdadea01b6d9f835269f94fa3be1a9f9a4a5c755a1a0f9 # Cloudflare Access application AUD

jwt_ttl: 600 # TTL of the generated JWT tokens, in seconds

clients:
  - name: 'Workers oidc example'
    client_id: b78f6b19-50ca-4bab-85bf-93e6c51ff8fb # should not be guessable, e.g. you can use uuidv4 from https://uuid.rocks/plain
    client_secret_key: SECRET_WORKERS_OIDC_EXAMPLE # should be set with 'wragler secret put SECRET_SOMETHING_SOMETHING' (could be also uuid)
    redirect_uris:
      - https://workers-oidc-example.eidam.workers.dev/auth
    cors_origins:
      - https://workers-oidc-example.eidam.workers.dev

  - name: 'HashiCorp Vault'
    client_id: 3006081d-4f08-47b3-a9fb-23707dcae95b # should not be guessable, e.g. you can use uuidv4 from https://uuid.rocks/plain
    client_secret_key: SECRET_VAULT # should be set with 'wragler secret put SECRET_VAULT' (could be also uuid)
    redirect_uris:
      - https://vault.eidam.dev/ui/vault/auth/oidc/oidc/callback
      - http://localhost:8250/oidc/callback
      - http://127.0.0.1:8250/oidc/callback

Build & Deploy

  • export CF_ACCOUNT_ID= (Cloudflare Account ID to deploy OIDC provider to)
  • export CF_API_TOKEN= (Cloudflare API Token with Workers permissions)
  • wrangler secret put CF_SECRET_API_TOKEN (Cloudflare API Token with Account.Teams read-only permissions, used to fetch user's Access groups)
  • yarn
  • wrangler publish

Worker routes & endpoints

The Worker is not deployed to any domain by default, feel free to configure wrangler.toml to expose it on one of your domains (or use the Workers UI).

Profit

Once deployed your OIDC provider is up and ready, with following endpoints are available

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.