Skip to content

Commit

Permalink
Correctly use X-Forwarded-* headers
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOrangeOne committed May 14, 2024
1 parent 7b1e044 commit 61c52bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions calmerge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
from pathlib import Path

import aiohttp_jinja2
import aiohttp_remotes
from aiohttp import web
from jinja2 import FileSystemLoader

Expand All @@ -22,6 +24,12 @@ def get_aiohttp_app(config: Config) -> web.Application:
],
)

app.middlewares.append(
aiohttp_remotes.XForwardedRelaxed(
num=int(os.environ.get("X_FORWARDED_NUM", 1))
).middleware
)

jinja2_env.filters["calendar_url"] = templates.calendar_url

app["config"] = config
Expand Down
17 changes: 16 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ icalendar = "^5.0.11"
aiocache = "^0.12.2"
aiohttp-jinja2 = "^1.6"

aiohttp-remotes = "^1.2.0"
[tool.poetry.group.dev.dependencies]
ruff = "^0.3.2"
pytest = "^8.1.1"
Expand Down

0 comments on commit 61c52bd

Please sign in to comment.