我试图重写CheckIsAdmin
类中的CheckIsAdmin
方法。所以我遵循了this的答案。但我总是在打印时得到空的结论self.request.cookies
。在
在某些情况下,我得到了打印self.request.cookies
的值,但它不会。我已经检查了我的服务器是否正在运行,并且我已经登录了。在
remote_api.py
看起来像
import re
import models
from google.appengine.ext.remote_api import handler
from google.appengine.ext import webapp
MY_SECRET_KEY = 'foo@bar.com' # make one up, use the same one in the shell command
class ApiCallHandler(handler.ApiCallHandler):
def CheckIsAdmin(self):
'''
Determine if admin access should be granted based on the
auth cookie passed with the request.
'''
'''
print 'App id ' + models.APPLICATION_ID
print 'on checkIsAdmin'
print 'request.cookies ' + str(self.request.cookies)
login_cookie = self.request.cookies.get('dev_appserver_login', '')
match = login_cookie.split(':')
print 'headers '+ str(self.request.headers)
if match and match[0] == MY_SECRET_KEY \
and 'X-Appcfg-Api-Version' in self.request.headers:
print 'Going to return true'
return True
app = webapp.WSGIApplication([('.*', ApiCallHandler)])
app.yaml
的一部分看起来像
如果我的.py
文件存在于api
文件夹中,这是正确的。。在
当我试过这个命令时
echo "foo@bar.com" | appcfg.py upload_data --email=some@example.org --passin --url=http://localhost:8080/remoteapi --num_threads=4 --db_filename=bulkloader.csv
它显示无效的参数--passin
,如果我把return True
放在CheckIsAdmin
方法的开头,它就可以正常工作了。但它缺乏安全性。。在
看起来他们删除了
passin
,现在完全依赖oauth。在https://code.google.com/p/googleappengine/wiki/SdkReleaseNotes#Version_1.9.24_-_July_20,_2015
passin
是导致cookies设置的标志。看起来您需要降级到低于1.9.24的sdk版本,或者更改命令以使用oauth并删除自定义的ApiCallHandler
代码。在相关问题 更多 >
编程相关推荐