Remove the getUser API call and replace it with channel messages. Close channels when log in/out events occur for security.

This commit is contained in:
Ian Gulliver
2014-05-01 14:55:50 -07:00
parent 64f989e3ca
commit 0369266d60
2 changed files with 29 additions and 21 deletions

30
api.py
View File

@@ -26,20 +26,6 @@ from cosmopolite.lib import utils
import config
class GetUser(webapp2.RequestHandler):
@utils.chaos_monkey
@utils.returns_json
@utils.local_namespace
@security.google_user_xsrf_protection
@security.weak_security_checks
@session.session_required
def post(self):
ret = {}
if self.verified_google_user:
ret['google_user'] = self.verified_google_user.email()
return ret
class SetValue(webapp2.RequestHandler):
@utils.chaos_monkey
@utils.returns_json
@@ -89,15 +75,25 @@ class CreateChannel(webapp2.RequestHandler):
token = channel.create_channel(
client_id=str(self.client.key()),
duration_minutes=config.CHANNEL_DURATION_SECONDS / 60)
messages = [x.ToMessage()
for x in self.client.parent().GetStateEntries()]
if self.verified_google_user:
messages.append({
'message_type': 'login',
'google_user': self.verified_google_user.email(),
})
else:
messages.append({
'message_type': 'logout',
})
return {
'token': token,
'messages': [x.ToMessage()
for x in self.client.parent().GetStateEntries()],
'messages': messages,
}
app = webapp2.WSGIApplication([
(config.URL_PREFIX + '/api/createChannel', CreateChannel),
(config.URL_PREFIX + '/api/getUser', GetUser),
(config.URL_PREFIX + '/api/setValue', SetValue),
])