mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 11:26:24 +00:00
e6ddcf9e4b
* Add RobotTokenSHA256 middleware for in-the-fly robot generation/login * Add RobotView, fix middleware, upgrade frontend * Token header as base91 * Add OAS schema of RobotView * Use RobotView on new fetchRobot(), mimick old fetchRobot() functionality * Upgrade websockets for token based authentication * Small fixes * Add frontend token entropy checks, add token on route /robot/<token> * Rename admin panel * Collect phrases
30 lines
900 B
Python
30 lines
900 B
Python
import os
|
|
|
|
from channels.auth import AuthMiddlewareStack
|
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
|
from decouple import config
|
|
from django.core.asgi import get_asgi_application
|
|
|
|
import chat.routing
|
|
from robosats.middleware import TokenAuthMiddleware
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "robosats.settings")
|
|
# Initialize Django ASGI application early to ensure the AppRegistry
|
|
# is populated before importing code that may import ORM models.
|
|
django_asgi_app = get_asgi_application()
|
|
|
|
protocols = {}
|
|
protocols["websocket"] = AuthMiddlewareStack(
|
|
TokenAuthMiddleware(
|
|
URLRouter(
|
|
chat.routing.websocket_urlpatterns,
|
|
# add api.routing.websocket_urlpatterns when Order page works with websocket
|
|
)
|
|
)
|
|
)
|
|
|
|
if config("DEVELOPMENT", default=False):
|
|
protocols["http"] = django_asgi_app
|
|
|
|
application = ProtocolTypeRouter(protocols)
|