Update Copyright header point to COPYING file
[cascardo/ipsilon.git] / ipsilon / providers / persona / auth.py
index f713347..09c73a1 100644 (file)
@@ -1,8 +1,8 @@
-# Copyright (C) 2014  Ipsilon project Contributors, for licensee see COPYING
+# Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING
 
 from ipsilon.providers.common import ProviderPageBase
-from ipsilon.util.trans import Transaction
 from ipsilon.util.user import UserSession
+from ipsilon.util.endpoint import allow_iframe
 
 import base64
 import cherrypy
@@ -18,15 +18,7 @@ class AuthenticateRequest(ProviderPageBase):
         self.trans = None
 
     def _preop(self, *args, **kwargs):
-        try:
-            # generate a new id or get current one
-            self.trans = Transaction('persona', **kwargs)
-            if self.trans.cookie.value != self.trans.provider:
-                self.debug('Invalid transaction, %s != %s' % (
-                           self.trans.cookie.value, self.trans.provider))
-        except Exception, e:  # pylint: disable=broad-except
-            self.debug('Transaction initialization failed: %s' % repr(e))
-            raise cherrypy.HTTPError(400, 'Invalid transaction id')
+        self.trans = self.get_valid_transaction('persona', **kwargs)
 
     def pre_GET(self, *args, **kwargs):
         self._preop(*args, **kwargs)
@@ -80,6 +72,7 @@ class Sign(AuthenticateRequest):
                 return True
         return False
 
+    @allow_iframe
     def POST(self, *args, **kwargs):
         if 'email' not in kwargs or 'publicKey' not in kwargs \
                 or 'certDuration' not in kwargs or '@' not in kwargs['email']:
@@ -102,6 +95,7 @@ class Sign(AuthenticateRequest):
 
 
 class SignInResult(AuthenticateRequest):
+    @allow_iframe
     def GET(self, *args, **kwargs):
         user = UserSession().get_user()
 
@@ -115,6 +109,7 @@ class SignIn(AuthenticateRequest):
         self.result = SignInResult(*args, **kwargs)
         self.trans = None
 
+    @allow_iframe
     def GET(self, *args, **kwargs):
         username = None
         domain = None
@@ -144,6 +139,7 @@ class Persona(AuthenticateRequest):
         self.SignIn = SignIn(*args, **kwargs)
         self.trans = None
 
+    @allow_iframe
     def GET(self, *args, **kwargs):
         user = UserSession().get_user()
         return self._template('persona/provisioning.html',