Skip to content

Commit

Permalink
feat: secure API
Browse files Browse the repository at this point in the history
  • Loading branch information
tanguynicolas committed Jun 28, 2024
1 parent 74ed588 commit 2f8f796
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions infra/nginx/configurations/ctf-manager.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ server {
include includes/allow-cloudflare-ips;
deny all;

# Exception for /team/*/flag
location ~* ^/team/.*/flag$ {
proxy_pass http://api:80;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

# Default location with Bearer token check
location / {
if ($http_authorization != "Bearer $bearer_token") {
return 401;
Expand Down
6 changes: 4 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from fastapi.responses import RedirectResponse

from .database import init as init_db
from .config import database_settings
from .config import database_settings, kafka_settings
from .organization.router import router as organization_router
from .players.router import router as players_router

Expand All @@ -24,7 +24,9 @@ def alive():
@app.get("/info")
def info():
return{
"Database URL": database_settings.url
"Database DB name": database_settings.db_name,
"Kafka enablement": kafka_settings.enable,
"Kafka topic name": kafka_settings.topic
}

app.include_router(organization_router, prefix="/team", tags=["organization"])
Expand Down

0 comments on commit 2f8f796

Please sign in to comment.