quali-chat / siwe-oidc

OpenID Connect Identity Provider for Sign-In with Ethereum.
https://oidc.login.xyz
Apache License 2.0
0 stars 0 forks source link

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).

The front-end depends on WalletConnect, meaning you will need to create a project with them and have the environment variable VITE_PROJECT_ID set when you build the front-end.

This is achieved by copying the .env.example to .env and filling it out for the docker build.

Cloudflare Worker

You will need wrangler.

First, copy the configuration file template:

cp wrangler_example.toml wrangler.toml

Then replace the following fields:

You will also need to add a secret RSA key in PEM format:

wrangler secret put RSA_PEM

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:

Stand-Alone Binary

WARNING - Due to the reliance on WalletConnect, and the project ID being loaded at compile-time, the current version of the Docker image won't have a working web app.

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_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:

OIDC Functionalities

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

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

OIDC Conformance Suite:

TODO Items

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 -f test/docker-compose.yml up -d
  2. 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.

  3. 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.