如何使用密码保护Google App Engine应用程序?

时间:2010-09-27 16:57:24

标签: python security google-app-engine passwords

您如何在Google App Engine应用程序上实现简单的密码保护?没有用户身份验证,只需要输入密码就可以打开特定页面。另一个要求是,如果直接输入目标页面,则不应显示目标页面。

我正在寻找使用Python的解决方案。

2 个答案:

答案 0 :(得分:5)

如果您要保护单个页面而不需要会话持久性。

class MainPage(webapp.RequestHandler):
    def post(self):
        if self.request.get('user') == 'admin' and self.request.get('pass') == 'soopersecure':
            self.response.out.write('authorized');
        else:
            self.response.out.write("""
<form method="post">
<input type="text" name="user"/>
<input type="password" name="pass"/>
<input type="submit" value="login"/>
</form>""")

否则,您可以对用户名+ salt进行哈希处理,并将其作为cookie中的会话ID传递给用户,并将该会话ID存储到数据存储区中。但是使用Google帐户要简单得多。

http://code.google.com/appengine/docs/python/gettingstarted/usingusers.html

答案 1 :(得分:1)

如果您想限制整个应用的访问权限,请使用带有“登录”设置的网址处理程序

检查 - User and Administrator Login