Cloudflare Worker version (#6)
Refactor/generalise API/DB interactions out of OIDC.
This commit is contained in:
61
README.md
61
README.md
@@ -2,11 +2,54 @@
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Dependencies
|
||||
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`](https://github.com/cloudflare/wrangler).
|
||||
|
||||
Then copy the configuration file template:
|
||||
```bash
|
||||
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/.w*
|
||||
```
|
||||
|
||||
### Stand-Alone Binary
|
||||
|
||||
#### Dependencies
|
||||
|
||||
Redis, or a Redis compatible database (e.g. MemoryDB in AWS), is required.
|
||||
|
||||
### Starting the IdP
|
||||
#### Starting the IdP
|
||||
|
||||
The Docker image is available at `ghcr.io/spruceid/siwe_oidc:0.1.0`. Here is an
|
||||
example usage:
|
||||
@@ -35,9 +78,23 @@ For the core OIDC information, it is available under
|
||||
|
||||
* Additional information, from native projects (e.g. ENS domains), to more
|
||||
traditional ones (e.g. email).
|
||||
* PKCE support (code challenge).
|
||||
* Browser session support for the Worker version.
|
||||
|
||||
## Development
|
||||
|
||||
### Cloudflare Worker
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user