|
45 | 45 |
|
46 | 46 |
|
47 | 47 | if TYPE_CHECKING: |
| 48 | + from os import PathLike |
| 49 | + |
48 | 50 | from starlette.requests import Request |
49 | 51 |
|
50 | 52 | from ..authentication import AuthorizationURLPayload, UserTokenPayload, ValidateTokenPayload |
@@ -105,6 +107,12 @@ class StarletteAdapter(BaseAdapter, Starlette): |
105 | 107 | An optional :class:`str` passed to use as the EventSub secret. It is recommended you pass this parameter when using |
106 | 108 | an adapter for EventSub, as it will reset upon restarting otherwise. You can generate token safe secrets with the |
107 | 109 | :mod:`secrets` module. |
| 110 | + ssl_keyfile: str | PathLike[str] | None |
| 111 | + An optional SSL key file passed to Uvicorn. |
| 112 | + ssl_keyfile_password: str | None |
| 113 | + An optional password to decrypt the ssl key, passed to Uvicorn. |
| 114 | + ssl_certfile: str | PathLike[str] | None |
| 115 | + An optional SSL certificate file, passed to Uvicorn. |
108 | 116 |
|
109 | 117 | Examples |
110 | 118 | -------- |
@@ -143,6 +151,9 @@ def __init__( |
143 | 151 | domain: str | None = None, |
144 | 152 | eventsub_path: str | None = None, |
145 | 153 | eventsub_secret: str | None = None, |
| 154 | + ssl_keyfile: str | PathLike[str] | None = None, |
| 155 | + ssl_keyfile_password: str | None = None, |
| 156 | + ssl_certfile: str | PathLike[str] | None = None, |
146 | 157 | ) -> None: |
147 | 158 | self._host: str = host or "localhost" |
148 | 159 | self._port: int = port or 4343 |
@@ -177,6 +188,10 @@ def __init__( |
177 | 188 | self._server: uvicorn.Server | None = None |
178 | 189 | self._running: bool = False |
179 | 190 |
|
| 191 | + self.__certfile = ssl_certfile |
| 192 | + self.__keyfile = ssl_keyfile |
| 193 | + self.__keypass = ssl_keyfile_password |
| 194 | + |
180 | 195 | def __repr__(self) -> str: |
181 | 196 | return f'{self.__class__.__name__}(host="{self._host}", port={self._port})' |
182 | 197 |
|
@@ -250,6 +265,9 @@ async def run(self, host: str | None = None, port: int | None = None) -> None: |
250 | 265 | log_level="critical", |
251 | 266 | workers=0, |
252 | 267 | timeout_graceful_shutdown=3, |
| 268 | + ssl_keyfile=self.__keyfile, |
| 269 | + ssl_keyfile_password=self.__keypass, |
| 270 | + ssl_certfile=self.__certfile, |
253 | 271 | ) |
254 | 272 |
|
255 | 273 | self._server = uvicorn.Server(config) |
|
0 commit comments