mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-08 02:39:22 +00:00
服务账号注册机制更改 (#2079)
* [Update] 服务账号注册 * [Update] 修改settings配置 * [Update] 修改settings * [Update] 整理terminal api * [Update] 修改terminal api * [Update] 修改terminal注册机制
This commit is contained in:
@@ -5,6 +5,7 @@ from rest_framework import permissions
|
||||
from django.contrib.auth.mixins import UserPassesTestMixin
|
||||
from django.shortcuts import redirect
|
||||
from django.http.response import HttpResponseForbidden
|
||||
from django.conf import settings
|
||||
|
||||
from orgs.utils import current_org
|
||||
|
||||
@@ -96,3 +97,12 @@ class SuperUserRequiredMixin(UserPassesTestMixin):
|
||||
def test_func(self):
|
||||
if self.request.user.is_authenticated and self.request.user.is_superuser:
|
||||
return True
|
||||
|
||||
|
||||
class WithBootstrapToken(permissions.BasePermission):
|
||||
def has_permission(self, request, view):
|
||||
authorization = request.META.get('HTTP_AUTHORIZATION', '')
|
||||
if not authorization:
|
||||
return False
|
||||
request_bootstrap_token = authorization.split()[-1]
|
||||
return settings.BOOTSTRAP_TOKEN == request_bootstrap_token
|
||||
|
Reference in New Issue
Block a user