fix: 静态资源白名单,添加非空判断
This commit is contained in:
parent
f91d44de22
commit
27d8285388
@ -17,7 +17,7 @@ class StaticHeadersMiddleware(MiddlewareMixin):
|
|||||||
if request.path.startswith('/ui/chat/'):
|
if request.path.startswith('/ui/chat/'):
|
||||||
access_token = request.path.replace('/ui/chat/', '')
|
access_token = request.path.replace('/ui/chat/', '')
|
||||||
application_access_token = QuerySet(ApplicationAccessToken).filter(access_token=access_token).first()
|
application_access_token = QuerySet(ApplicationAccessToken).filter(access_token=access_token).first()
|
||||||
if application_access_token.white_active:
|
if application_access_token is not None and application_access_token.white_active:
|
||||||
# 添加自定义的响应头
|
# 添加自定义的响应头
|
||||||
response['Content-Security-Policy'] = f'frame-ancestors {" ".join(application_access_token.white_list)}'
|
response['Content-Security-Policy'] = f'frame-ancestors {" ".join(application_access_token.white_list)}'
|
||||||
return response
|
return response
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user