Skip to content

Commit 2c51475

Browse files
authored
Merge pull request #242 from benavlabs/oauth
Oauth Docs
2 parents fd11216 + caf666f commit 2c51475

File tree

24 files changed

+1827
-793
lines changed

24 files changed

+1827
-793
lines changed

docs/user-guide/authentication/oauth.md

Lines changed: 413 additions & 0 deletions
Large diffs are not rendered by default.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ nav:
7575
- Authentication:
7676
- Overview: user-guide/authentication/index.md
7777
- JWT Tokens: user-guide/authentication/jwt-tokens.md
78+
- OAuth: user-guide/authentication/oauth.md
7879
- User Management: user-guide/authentication/user-management.md
7980
- Permissions: user-guide/authentication/permissions.md
8081
- Admin Panel:

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies = [
3333
"gunicorn>=23.0.0",
3434
"ruff>=0.11.13",
3535
"mypy>=1.16.0",
36+
"fastapi-sso>=0.18.0",
3637
]
3738

3839
[project.optional-dependencies]
@@ -107,6 +108,7 @@ filterwarnings = [
107108
dev = [
108109
"pre-commit>=4.3.0",
109110
"pytest-asyncio>=1.0.0",
111+
"watchfiles>=1.1.1",
110112
]
111113

112114
[tool.mypy]

scripts/gunicorn_managing_uvicorn_workers/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file contains example values for development/testing purposes only.
55
#
66
# SECURITY CRITICAL: Before deploying to production, you MUST:
7-
# 1. Copy this file to src/.env
7+
# 1. Copy this file to a .env file at the project root
88
# 2. Generate a new SECRET_KEY using: openssl rand -hex 32
99
# 3. Change all passwords (POSTGRES_PASSWORD, ADMIN_PASSWORD, etc.)
1010
# 4. Update all sensitive configuration values
@@ -20,7 +20,7 @@ CONTACT_NAME="Me"
2020
CONTACT_EMAIL="my.email@example.com"
2121
LICENSE_NAME="MIT"
2222

23-
# ------------- database -------------
23+
# ------------- database -------------
2424
POSTGRES_USER="postgres"
2525
POSTGRES_PASSWORD=1234
2626
POSTGRES_SERVER="db"

scripts/gunicorn_managing_uvicorn_workers/docker-compose.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
web:
3-
build:
3+
build:
44
context: .
55
dockerfile: Dockerfile
66
# -------- Both of the following commands should be commented to run with nginx --------
@@ -9,7 +9,7 @@ services:
99
# command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
1010
command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
1111
env_file:
12-
- ./src/.env
12+
- .env
1313
# -------- replace with expose if you are using nginx --------
1414
ports:
1515
- "8000:8000"
@@ -20,26 +20,26 @@ services:
2020
- redis
2121
volumes:
2222
- ./src/app:/code/app
23-
- ./src/.env:/code/.env
23+
- .env:/.env
2424

2525
worker:
26-
build:
26+
build:
2727
context: .
2828
dockerfile: Dockerfile
2929
command: arq app.core.worker.settings.WorkerSettings
3030
env_file:
31-
- ./src/.env
31+
- .env
3232
depends_on:
3333
- db
3434
- redis
3535
volumes:
3636
- ./src/app:/code/app
37-
- ./src/.env:/code/.env
37+
- .env:/.env
3838

3939
db:
4040
image: postgres:13
4141
env_file:
42-
- ./src/.env
42+
- .env
4343
volumes:
4444
- postgres-data:/var/lib/postgresql/data
4545
expose:
@@ -64,11 +64,11 @@ services:
6464

6565
#-------- uncomment to create first superuser --------
6666
create_superuser:
67-
build:
67+
build:
6868
context: .
6969
dockerfile: Dockerfile
7070
env_file:
71-
- ./src/.env
71+
- .env
7272
depends_on:
7373
- db
7474
- web
@@ -78,11 +78,11 @@ services:
7878

7979
#-------- uncomment to run tests --------
8080
# pytest:
81-
# build:
81+
# build:
8282
# context: .
83-
# dockerfile: Dockerfile
83+
# dockerfile: Dockerfile
8484
# env_file:
85-
# - ./src/.env
85+
# - .env
8686
# depends_on:
8787
# - db
8888
# - create_superuser
@@ -93,11 +93,11 @@ services:
9393

9494
#-------- uncomment to create first tier --------
9595
# create_tier:
96-
# build:
96+
# build:
9797
# context: .
9898
# dockerfile: Dockerfile
9999
# env_file:
100-
# - ./src/.env
100+
# - .env
101101
# depends_on:
102102
# - create_superuser
103103
# - db
@@ -109,4 +109,3 @@ services:
109109
volumes:
110110
postgres-data:
111111
redis-data:
112-

scripts/local_with_uvicorn/.env.example

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file contains example values for development/testing purposes only.
55
#
66
# SECURITY CRITICAL: Before deploying to production, you MUST:
7-
# 1. Copy this file to src/.env
7+
# 1. Copy this file to a .env file at the project root
88
# 2. Generate a new SECRET_KEY using: openssl rand -hex 32
99
# 3. Change all passwords (POSTGRES_PASSWORD, ADMIN_PASSWORD, etc.)
1010
# 4. Update all sensitive configuration values
@@ -16,6 +16,8 @@
1616
APP_NAME="My Project"
1717
APP_DESCRIPTION="My Project Description"
1818
APP_VERSION="0.1"
19+
APP_BACKEND_HOST="http://localhost:8000"
20+
APP_FRONTEND_HOST="http://localhost:3000"
1921
CONTACT_NAME="Me"
2022
CONTACT_EMAIL="my.email@example.com"
2123
LICENSE_NAME="MIT"
@@ -70,3 +72,13 @@ ENVIRONMENT="local"
7072

7173
# ------------- first tier -------------
7274
TIER_NAME="free"
75+
76+
# ------------- auth settings -------------
77+
# ENABLE_PASSWORD_AUTH=true
78+
# GOOGLE_CLIENT_ID=
79+
# GOOGLE_CLIENT_SECRET=
80+
# MICROSOFT_CLIENT_ID=
81+
# MICROSOFT_CLIENT_SECRET=
82+
# MICROSOFT_TENANT=
83+
# GITHUB_CLIENT_ID=
84+
# GITHUB_CLIENT_SECRET=

scripts/local_with_uvicorn/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ COPY --from=builder --chown=app:app /app/.venv /app/.venv
3333
# Ensure the virtual environment is in the PATH
3434
ENV PATH="/app/.venv/bin:$PATH"
3535

36+
# Force file watching to use polling, which is more reliable in some Docker environments (like WSL/macOS)
37+
ENV WATCHFILES_FORCE_POLLING=true
38+
3639
# Switch to the non-root user
3740
USER app
3841

3942
# Set the working directory
4043
WORKDIR /code
4144

4245
# -------- replace with comment to run with gunicorn --------
43-
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
46+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload", "--reload-include", ".env"]
4447
# CMD ["gunicorn", "app.main:app", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000"]

scripts/local_with_uvicorn/docker-compose.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,38 @@
11
services:
22
web:
3-
build:
3+
build:
44
context: .
55
dockerfile: Dockerfile
6-
# -------- Both of the following commands should be commented to run with nginx --------
7-
8-
# -------- replace with comment to run with gunicorn --------
9-
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
10-
# command: gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000
11-
env_file:
12-
- ./src/.env
13-
# -------- replace with expose if you are using nginx --------
6+
environment:
7+
# Enable polling for file changes on macOS/Windows Docker Desktop
8+
- WATCHFILES_FORCE_POLLING=true
149
ports:
1510
- "8000:8000"
16-
# expose:
17-
# - "8000"
1811
depends_on:
1912
- db
2013
- redis
2114
volumes:
2215
- ./src/app:/code/app
23-
- ./src/.env:/code/.env
16+
- .env:/code/.env
2417

2518
worker:
26-
build:
19+
build:
2720
context: .
2821
dockerfile: Dockerfile
2922
command: arq app.core.worker.settings.WorkerSettings
3023
env_file:
31-
- ./src/.env
24+
- .env
3225
depends_on:
3326
- db
3427
- redis
3528
volumes:
3629
- ./src/app:/code/app
37-
- ./src/.env:/code/.env
30+
- .env:/code/.env
3831

3932
db:
4033
image: postgres:13
4134
env_file:
42-
- ./src/.env
35+
- .env
4336
volumes:
4437
- postgres-data:/var/lib/postgresql/data
4538
expose:
@@ -64,11 +57,11 @@ services:
6457

6558
#-------- uncomment to create first superuser --------
6659
create_superuser:
67-
build:
60+
build:
6861
context: .
6962
dockerfile: Dockerfile
7063
env_file:
71-
- ./src/.env
64+
- .env
7265
depends_on:
7366
- db
7467
- web
@@ -78,11 +71,11 @@ services:
7871

7972
#-------- uncomment to run tests --------
8073
pytest:
81-
build:
74+
build:
8275
context: .
83-
dockerfile: Dockerfile
76+
dockerfile: Dockerfile
8477
env_file:
85-
- ./src/.env
78+
- .env
8679
depends_on:
8780
- db
8881
- create_superuser
@@ -93,11 +86,11 @@ services:
9386

9487
#-------- uncomment to create first tier --------
9588
# create_tier:
96-
# build:
89+
# build:
9790
# context: .
9891
# dockerfile: Dockerfile
9992
# env_file:
100-
# - ./src/.env
93+
# - .env
10194
# depends_on:
10295
# - create_superuser
10396
# - db
@@ -109,4 +102,3 @@ services:
109102
volumes:
110103
postgres-data:
111104
redis-data:
112-

scripts/production_with_nginx/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file contains example values for development/testing purposes only.
55
#
66
# SECURITY CRITICAL: Before deploying to production, you MUST:
7-
# 1. Copy this file to src/.env
7+
# 1. Copy this file to a .env file at the project root
88
# 2. Generate a new SECRET_KEY using: openssl rand -hex 32
99
# 3. Change all passwords (POSTGRES_PASSWORD, ADMIN_PASSWORD, etc.)
1010
# 4. Update all sensitive configuration values
@@ -20,7 +20,7 @@ CONTACT_NAME="Me"
2020
CONTACT_EMAIL="my.email@example.com"
2121
LICENSE_NAME="MIT"
2222

23-
# ------------- database -------------
23+
# ------------- database -------------
2424
POSTGRES_USER="postgres"
2525
POSTGRES_PASSWORD=1234
2626
POSTGRES_SERVER="db"

0 commit comments

Comments
 (0)