Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Bk Bcs Saas
Commits
0cc9004a
Unverified
Commit
0cc9004a
authored
4 years ago
by
joelei
Browse files
Options
Download
Email Patches
Plain Diff
finish log stream
parent
a3335450
log-stream
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bcs-app/backend/accounts/middlewares.py
+13
-1
bcs-app/backend/accounts/middlewares.py
bcs-app/backend/container_service/observability/log_stream/views.py
+1
-1
...ckend/container_service/observability/log_stream/views.py
with
14 additions
and
2 deletions
+14
-2
bcs-app/backend/accounts/middlewares.py
+
13
-
1
View file @
0cc9004a
...
...
@@ -12,6 +12,7 @@
# specific language governing permissions and limitations under the License.
#
import
logging
import
re
from
urllib
import
parse
from
channels.auth
import
AuthMiddlewareStack
...
...
@@ -66,9 +67,18 @@ class RequestProvider(object):
class
ChannelSessionAuthMiddleware
:
"""django channel auth middleware"""
CHANNEL_URL_PATTERN
=
re
.
compile
(
r
'/projects/(?P<project_id>\w{32})/clusters/(?P<cluster_id>[\w\-]+)/'
)
def
__init__
(
self
,
inner
):
self
.
inner
=
inner
def
extract_project_and_cluster_id
(
self
,
scope
):
pattern
=
re
.
findall
(
self
.
CHANNEL_URL_PATTERN
,
scope
[
'path'
])
if
len
(
pattern
)
==
0
:
raise
HttpResponseForbidden
(
_
(
"url中project_id或者cluster_id为空"
))
return
pattern
[
0
]
async
def
__call__
(
self
,
scope
,
receive
,
send
):
query_params
=
dict
(
parse
.
parse_qsl
(
scope
[
'query_string'
].
decode
(
'utf8'
)))
...
...
@@ -76,7 +86,9 @@ class ChannelSessionAuthMiddleware:
if
not
session_id
:
raise
HttpResponseForbidden
(
_
(
"session_id为空"
))
session
=
session_mgr
.
create
(
""
,
""
)
project_id
,
cluster_id
=
self
.
extract_project_and_cluster_id
(
scope
)
session
=
session_mgr
.
create
(
project_id
,
cluster_id
)
ctx
=
session
.
get
(
session_id
)
if
not
ctx
:
raise
HttpResponseForbidden
(
_
(
"获取ctx为空, session_id不正确或者已经过期"
))
...
...
This diff is collapsed.
Click to expand it.
bcs-app/backend/container_service/observability/log_stream/views.py
+
1
-
1
View file @
0cc9004a
...
...
@@ -72,7 +72,7 @@ class LogStreamViewSet(SystemViewSet):
'cluster_id'
:
cluster_id
,
}
session
=
session_mgr
.
create
(
""
,
""
)
session
=
session_mgr
.
create
(
project_id
,
cluster_id
)
session_id
=
session
.
set
(
ctx
)
stream_url
=
(
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help