From 7af9d9f8a46b3fa1ff1e7f7a3befa7377adf31c1 Mon Sep 17 00:00:00 2001 From: tumillanino Date: Tue, 28 Oct 2025 12:31:29 +1100 Subject: [PATCH] add readme --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2fbc141 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# How To + +## Authentication Setup (Ory) + +### Prerequisites +1. Copy `.env.example` to `.env` and configure: + - `PORT=3000` (your app port) + - `TUNNEL_PORT=4000` (Ory tunnel port) + +### Running the Application with Ory + +1. Start the database and services: +```bash +docker-compose up +``` + +2. Apply the Ory identity migration: +```bash +docker exec -i $(docker ps -q -f name=db) psql -U party -d partydb < migrations/010_add_ory_identity_id.sql +``` + +3. In one terminal, start your Go server: +```bash +go run cmd/server/main.go +``` + +4. In another terminal, start the Ory tunnel: +```bash +npx @ory/cli tunnel --dev http://localhost:3000 +``` + +5. Access your app through the tunnel URL (typically `http://localhost:4000`) + +### How It Works +- Users authenticate through Ory's hosted UI +- On first login, a user record is created in your database with their Ory identity ID +- Protected routes (`/profile`, `/api/bookings`) require authentication +- User context is available in handlers via `auth.GetUser(r.Context())` + +### Amending postgres table + +```bash +docker exec -i $(docker ps -q -f name=db) psql -U party -d partydb < migrations/002_add_service_image_url.sql +``` + +### Entering Postgres CLI + +```bash +docker exec -it $(docker ps -q -f name=db) psql -U party -d partydb +``` + +### Run Ory in Docker + +```bash +docker run --rm -it oryd/ory help +```