mirror of https://github.com/jumpserver/jumpserver
parent
7ae52eb941
commit
86a17b9955
@ -1,7 +1,21 @@
|
||||
import os
|
||||
import django
|
||||
from channels.routing import get_default_application
|
||||
|
||||
from channels.auth import AuthMiddlewareStack
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
from channels.security.websocket import AllowedHostsOriginValidator
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
from .routing import urlpatterns
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jumpserver.settings")
|
||||
django.setup()
|
||||
application = get_default_application()
|
||||
application = ProtocolTypeRouter({
|
||||
# Django's ASGI application to handle traditional HTTP requests
|
||||
"http": get_asgi_application(),
|
||||
|
||||
# WebSocket chat handler
|
||||
"websocket": AllowedHostsOriginValidator(
|
||||
AuthMiddlewareStack(
|
||||
URLRouter(urlpatterns)
|
||||
)
|
||||
),
|
||||
})
|
||||
|
@ -1,27 +1,9 @@
|
||||
from channels.auth import AuthMiddlewareStack
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
from channels.security.websocket import AllowedHostsOriginValidator
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
from notifications.urls.ws_urls import urlpatterns as notifications_urlpatterns
|
||||
from ops.urls.ws_urls import urlpatterns as ops_urlpatterns
|
||||
from settings.urls.ws_urls import urlpatterns as setting_urlpatterns
|
||||
from terminal.urls.ws_urls import urlpatterns as terminal_urlpatterns
|
||||
from .middleware import WsSignatureAuthMiddleware
|
||||
|
||||
urlpatterns = []
|
||||
urlpatterns += ops_urlpatterns + \
|
||||
notifications_urlpatterns + \
|
||||
setting_urlpatterns + \
|
||||
terminal_urlpatterns
|
||||
|
||||
application = ProtocolTypeRouter({
|
||||
"http": get_asgi_application(),
|
||||
'websocket': AllowedHostsOriginValidator(
|
||||
WsSignatureAuthMiddleware(
|
||||
AuthMiddlewareStack(
|
||||
URLRouter(urlpatterns)
|
||||
)
|
||||
)
|
||||
),
|
||||
})
|
||||
urlpatterns = ops_urlpatterns + \
|
||||
notifications_urlpatterns + \
|
||||
setting_urlpatterns + \
|
||||
terminal_urlpatterns
|
||||
|
Loading…
Reference in new issue