Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSLContext arg to aiohttp adapter #483

Merged
merged 8 commits into from
Feb 7, 2025
7 changes: 6 additions & 1 deletion twitchio/web/aio_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
An optional :class:`str` passed to use as the EventSub secret. It is recommended you pass this parameter when using
an adapter for EventSub, as it will reset upon restarting otherwise. You can generate token safe secrets with the
:mod:`secrets` module.
ssl_context: SSLContext | None
An optional :class:`ssl.SSLContext` passed to the adapter, configuring SSL encryption for the HTTP routes.
EvieePy marked this conversation as resolved.
Show resolved Hide resolved

Examples
--------
Expand Down Expand Up @@ -139,6 +141,7 @@
domain: str | None = None,
eventsub_path: str | None = None,
eventsub_secret: str | None = None,
ssl_context: SSLContext | None = None,

Check failure on line 144 in twitchio/web/aio_adapter.py

View workflow job for this annotation

GitHub Actions / Type Coverage and Linting @ 3.11

Type of parameter "ssl_context" is partially unknown   Parameter type is "Unknown | None" (reportUnknownParameterType)

Check failure on line 144 in twitchio/web/aio_adapter.py

View workflow job for this annotation

GitHub Actions / Type Coverage and Linting @ 3.11

"SSLContext" is not defined (reportUndefinedVariable)
) -> None:
super().__init__()
self._runner: web.AppRunner | None = None
Expand All @@ -160,6 +163,8 @@
path: str = eventsub_path.removeprefix("/").removesuffix("/") if eventsub_path else "callback"
self._eventsub_path: str = f"/{path}"

self._ssl_context: SSLContext = ssl_context

Check failure on line 166 in twitchio/web/aio_adapter.py

View workflow job for this annotation

GitHub Actions / Type Coverage and Linting @ 3.11

"SSLContext" is not defined (reportUndefinedVariable)

self._runner_task: asyncio.Task[None] | None = None
self.startup = self.event_startup
self.shutdown = self.event_shutdown
Expand Down Expand Up @@ -210,7 +215,7 @@
self._runner = web.AppRunner(self, access_log=None, handle_signals=True)
await self._runner.setup()

site: web.TCPSite = web.TCPSite(self._runner, host or self._host, port or self._port)
site: web.TCPSite = web.TCPSite(self._runner, host or self._host, port or self._port, ssl_context=self._ssl_context)

Check failure on line 218 in twitchio/web/aio_adapter.py

View workflow job for this annotation

GitHub Actions / Type Coverage and Linting @ 3.11

Type of "_ssl_context" is unknown (reportUnknownMemberType)

Check failure on line 218 in twitchio/web/aio_adapter.py

View workflow job for this annotation

GitHub Actions / Type Coverage and Linting @ 3.11

Argument type is unknown   Argument corresponds to parameter "ssl_context" in function "__init__" (reportUnknownArgumentType)
self._runner_task = asyncio.create_task(site.start(), name=f"twitchio-web-adapter:{self.__class__.__qualname__}")

async def eventsub_callback(self, request: web.Request) -> web.Response:
Expand Down
Loading