add readme
This commit is contained in:
56
README.md
Normal file
56
README.md
Normal file
@@ -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
|
||||
```
|
||||
Reference in New Issue
Block a user