haw*_*ett 10 openid google-app-engine
我最近尝试将我的应用引擎应用切换为使用openID,但我遇到了使用remote_api进行身份验证的问题.remote_api的旧身份验证机制似乎不起作用(这是有道理的) - 我得到一个'urllib2.HTTPError:HTTP错误302:找到',我假设是appengine将我重定向到openid登录页面我已经建立.
我想我错过了一些相当明显的东西.目前我的remote_api脚本中包含以下内容 -
remote_api_stub.ConfigureRemoteDatastore(app_id=app_id, path='/remote_api', auth_func=auth_func, servername=host, secure=secure)
Run Code Online (Sandbox Code Playgroud)
其中auth_func是
def auth_func():
return raw_input('Username:'), getpass.getpass('Password:')
Run Code Online (Sandbox Code Playgroud)
有什么想法我需要提供给remote_api吗?我猜也是会遇到与bulkloader类似的问题.干杯,
科林
这是一个有趣的.
看看remote_api,身份验证的流程似乎是这样的:
auth令牌解析出响应主体ACSID在响应中抓取cookie集ACSID在后续要求授权的请求中传递cookie虽然Nick的博客文章内容丰富,但我找不到关于新OpenID支持的大量文档.
这是我写的测试应用程序,用于查看工作原理:
app.yaml中:
handlers:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
- url: /.*
script: test.py
Run Code Online (Sandbox Code Playgroud)
test.py:
class MainPage(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
if user:
self.response.out.write("Hi, %s!<hr>admin is %s" % (user.user_id(),
users.is_current_user_admin()))
else:
self.redirect(users.create_login_url('/', None,
'https://www.google.com/accounts/o8/id'))
Run Code Online (Sandbox Code Playgroud)
在Google帐户和联合登录之间翻转我的身份验证模式,我注意到以下几点:
ACSID饼干仍然在登录过程结束时产生的,只有它来自/ _ah/openid_verify而不是/ _ah /登录那么使用联合登录时remote_api会发生什么?如果我们使用默认的appengine_rpc.HttpRpcServer,它会尽职尽责地遵循顶部描述的相同Google帐户身份验证过程,只有应用程序不再认为ACSID/ _ah/login返回的cookie有效,因为您仍然未经身份验证,您获得302重定向到OpenID登录页面/ _ah/login_required.
我不知道这里有什么正确的解决方案.似乎它需要API更新.也许尼克或其他一些Google员工可以权衡.
现在,这是一个hacky解决方法:
下次尝试使用remote_api时,它应该在不提示输入凭据的情况下工作.但是,每次cookie过期时,您都必须重复最后4个步骤.您可以在管理控制台中将过期时间从1天提高到最高2周,以最大限度地减少烦恼.玩得开心!
| 归档时间: |
|
| 查看次数: |
2524 次 |
| 最近记录: |