diff options
Diffstat (limited to 'ttun_server/__init__.py')
| -rw-r--r-- | ttun_server/__init__.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ttun_server/__init__.py b/ttun_server/__init__.py index 4af6ca0..f5d6b45 100644 --- a/ttun_server/__init__.py +++ b/ttun_server/__init__.py | |||
| @@ -2,8 +2,10 @@ import logging | |||
| 2 | import os | 2 | import os |
| 3 | 3 | ||
| 4 | from fastapi import FastAPI | 4 | from fastapi import FastAPI |
| 5 | from starlette.middleware.authentication import AuthenticationMiddleware | ||
| 5 | from starlette.routing import Host, Route, WebSocketRoute, Mount | 6 | from starlette.routing import Host, Route, WebSocketRoute, Mount |
| 6 | 7 | ||
| 8 | from authentication.backend import BearerTokenAuthBackend | ||
| 7 | from authentication.endpoints import authentication, oauth | 9 | from authentication.endpoints import authentication, oauth |
| 8 | from proxy import app as proxy_app | 10 | from proxy import app as proxy_app |
| 9 | from ttun_server.endpoints import health | 11 | from ttun_server.endpoints import health |
| @@ -16,12 +18,17 @@ app = FastAPI( | |||
| 16 | routes=[ | 18 | routes=[ |
| 17 | Mount('/auth/', app=authentication), | 19 | Mount('/auth/', app=authentication), |
| 18 | Mount('/oauth/', app=oauth), | 20 | Mount('/oauth/', app=oauth), |
| 19 | WebSocketRoute('/tunnel/', endpoint=tunnel), | 21 | WebSocketRoute( |
| 22 | '/tunnel/', | ||
| 23 | endpoint=tunnel, | ||
| 24 | ), | ||
| 20 | Route('/health/', endpoint=health), | 25 | Route('/health/', endpoint=health), |
| 21 | Host(f'{{subdomain}}.{os.environ['TUNNEL_DOMAIN']}', app=proxy_app) | 26 | Host(f'{{subdomain}}.{os.environ['TUNNEL_DOMAIN']}', app=proxy_app) |
| 22 | ] | 27 | ] |
| 23 | ) | 28 | ) |
| 24 | 29 | ||
| 30 | app.add_middleware(AuthenticationMiddleware, backend=BearerTokenAuthBackend()) | ||
| 31 | |||
| 25 | try: | 32 | try: |
| 26 | from ._version import version | 33 | from ._version import version |
| 27 | __version__ = version | 34 | __version__ = version |
