def authenticate(self, request): account = Account() login_status, user = account.is_bk_token_valid(request) if not login_status: return None return user
def process_request(self, request): account = Account() # 通过登录态获取用户名 username = account.is_bk_token_valid(request)[1] # 获取登录主页后生成的 session is_login = request.session.get('logined',None) # 如果session & username不存在则直接去请求权限app if is_login is None and username is not None: url = settings.BK_PAAS_HOST + "/o/bkpermission/" + "return_result_b/?app_code=" + settings.APP_ID + "&username="******"/o/bkpermission" + '/return_forbidden/' + "?username=" + str(username) print url res = json.loads(requests.get(url=url).content) if not res['result']: ''' @note: 重定向到403页面 ''' return HttpResponseRedirect(redirect_url)
def authenticate(self, request): account = Account() login_status, user = account.is_bk_token_valid(request) if not login_status: return None return user