OpenID Connect Identity Provider for Sign-In with Ethereum.
Go to file
dependabot[bot] 98f55c93f1
Bump svelte from 3.46.4 to 3.49.0 in /js/ui (#33)
Bumps [svelte](https://github.com/sveltejs/svelte) from 3.46.4 to 3.49.0.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte/compare/v3.46.4...v3.49.0)

---
updated-dependencies:
- dependency-name: svelte
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-18 09:30:52 +01:00
.github/workflows Add Docker CI 2022-05-30 11:19:08 +01:00
example/demo Add basic demo SPA to display claims 2022-02-11 13:54:20 +00:00
js/ui Bump svelte from 3.46.4 to 3.49.0 in /js/ui (#33) 2022-07-18 09:30:52 +01:00
src Remove hardcoded chain ID (#32) 2022-07-05 15:30:28 +01:00
static Update web3modal providers (#26) 2022-04-01 21:13:31 +01:00
.dockerignore Add basic demo SPA to display claims 2022-02-11 13:54:20 +00:00
.gitignore Add basic demo SPA to display claims 2022-02-11 13:54:20 +00:00
Cargo.lock Bump regex from 1.5.4 to 1.5.5 (#30) 2022-06-07 11:32:05 +01:00
Cargo.toml Rework browser sessions 2022-02-21 11:29:37 +00:00
docker-compose.yml Add README (#1) 2021-12-15 15:13:26 +00:00
Dockerfile Temporary fix for Docker (#29) 2022-06-01 10:54:50 +01:00
LICENSE-APACHE Add README (#1) 2021-12-15 15:13:26 +00:00
LICENSE-MIT Add README (#1) 2021-12-15 15:13:26 +00:00
README.md Fix typo in readme for wrangler kv (#19) 2022-03-22 09:32:31 +00:00
siwe-oidc.toml Initial commit 2021-12-13 16:35:10 +00:00
wrangler_example.toml Use underscore for KV namespace 2022-03-08 10:18:07 +00:00

OpenID Connect Identity Provider for Sign-In with Ethereum

Getting Started

Two versions are available, a stand-alone binary (using Axum and Redis) and a Cloudflare Worker. They use the same code base and are selected at compile time (compiling for wasm32 will make the Worker version).

Cloudflare Worker

You will need wrangler.

Then copy the configuration file template:

cp wrangler_example.toml wrangler.toml

Replacing the following fields:

  • account_id: your Cloudflare account ID;
  • zone_id: (Optional) DNS zone ID; and
  • kv_namespaces: a KV namespace ID (created with wrangler kv:namespace create SIWE_OIDC).

At this point, you should be able to create/publish the worker:

wrangler publish

The IdP currently only supports having the frontend under the same subdomain as the API. Here is the configuration for Cloudflare Pages:

  • Build command: cd js/ui && npm install && npm run build;
  • Build output directory: /static; and
  • Root directory: /. And you will need to add some rules to do the routing between the Page and the Worker. Here are the rules for the Worker (the Page being used as the fallback on the subdomain):
siweoidc.example.com/s*
siweoidc.example.com/u*
siweoidc.example.com/r*
siweoidc.example.com/a*
siweoidc.example.com/t*
siweoidc.example.com/j*
siweoidc.example.com/c*
siweoidc.example.com/.w*

Stand-Alone Binary

Dependencies

Redis, or a Redis compatible database (e.g. MemoryDB in AWS), is required.

Starting the IdP

The Docker image is available at ghcr.io/spruceid/siwe_oidc:0.1.0. Here is an example usage:

docker run -p 8000:8000 -e SIWEOIDC_ADDRESS="0.0.0.0" -e SIWEOIDC_REDIS_URL="redis://redis" ghcr.io/spruceid/siwe_oidc:latest

It can be configured either with the siwe-oidc.toml configuration file, or through environment variables:

  • SIWEOIDC_ADDRESS is the IP address to bind to.
  • SIWEOIDC_REDIS_URL is the URL to the Redis instance.
  • SIWEOIDC_BASE_URL is the URL you want to advertise in the OIDC configuration (e.g. https://oidc.example.com).
  • SIWEOIDC_RSA_PEM is the signing key, in PEM format. One will be generated if none is provided.

OIDC Functionalities

The current flow is very basic -- after the user is authenticated you will receive:

  • an Ethereum address as the subject (sub field); and
  • an ENS domain as the preferred_username (with a fallback to the address).

For the core OIDC information, it is available under /.well-known/openid-configuration.

OIDC Conformance Suite:

  • 🟨 (25/29, and 10 skipped) basic (email scope skipped, profile scope partially supported, ACR, prompt=none and request URIs yet to be supported);
  • 🟩 config;
  • 🟧 dynamic code.

TODO Items

  • Additional information, from native projects (e.g. ENS domains profile pictures), to more traditional ones (e.g. email).

Development

Cloudflare Worker

wrangler dev

You can now use http://127.0.0.1:8787/.well-known/openid-configuration.

At the moment it's not possible to use it end-to-end with the frontend as they need to share the same host (i.e. port), unless using a local load-balancer.

Stand Alone Binary

A Docker Compose is available to test the IdP locally with Keycloak.

  1. You will first need to run:
docker-compose up -d
  1. And then edit your /etc/hosts to have siwe-oidc point to 127.0.0.1. This is so both your browser, and Keycloak, can access the IdP.

  2. In Keycloak, you will need to create a new IdP. You can use http://siwe-oidc:8000/.well-known/openid-configuration to fill the settings automatically. As for the client ID/secret, you can use sdf/sdf.

Disclaimer

Our identity provider for Sign-In with Ethereum has not yet undergone a formal security audit. We welcome continued feedback on the usability, architecture, and security of this implementation.