Following Lucia Getting Started in Express tutorial
Node >=20 required (or see notes about Oslo installation for Node <20 here)
npm install;
To get your Client ID and Client Secret, go to https://recurse.com/settings/apps, and click 'Create OAuth Application'. Use http://localhost:3001/myOauth2RedirectUri
as the Redirect URI.
Then make a copy of config.env.template
named config.env
and fill in the secrets there. For PostgreSQL, see the Neon section below.
node --env-file=config.env index.js
OAUTH_CLIENT_ID
, OAUTH_CLIENT_SECRET
and POSTGRES_CONNECTION
are set as Secrets inside the Fly App.
When you update those values, you'll need to run fly deploy
to use the new versions.
Sign up for a new account with Neon. Make a new database. Save the PostgreSQL connection string into the config.env
variable POSTGRES_CONNECTION
as well as in the Secrets section of your Fly App.
Create two tables. Run these two queries separately in the Neon "SQL Editor":
CREATE TABLE auth_user (
id TEXT PRIMARY KEY
)
and this one. Note it's different from the Lucia tutorial here in that it includes a refresh_token
field:
CREATE TABLE user_session (
id TEXT PRIMARY KEY,
expires_at TIMESTAMPTZ NOT NULL,
user_id TEXT NOT NULL REFERENCES auth_user(id),
refresh_token TEXT
)