Fix transaction handling in providers
authorSimo Sorce <simo@redhat.com>
Sun, 5 Oct 2014 18:00:25 +0000 (14:00 -0400)
committerPatrick Uiterwijk <puiterwijk@redhat.com>
Mon, 6 Oct 2014 17:53:22 +0000 (19:53 +0200)
When a provider redirects to the login code, it must retain 'ownership'
of the transaction, otherwise the login code will wipe the transaction
data as sson as the authentication is completed but before the provider
has completed its part of the transaction.
Make sure the transaction code retrieves the 'owner' from the data for
pre-existing transactions.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
ipsilon/login/common.py
ipsilon/util/trans.py

index 3f44c15..2fee357 100755 (executable)
@@ -79,6 +79,7 @@ class LoginManagerBase(PluginObject, Log):
         # on direct login the UI (ie not redirected by a provider) we ned to
         # remove the transaction cookie as it won't be needed anymore
         if trans.provider == 'login':
         # on direct login the UI (ie not redirected by a provider) we ned to
         # remove the transaction cookie as it won't be needed anymore
         if trans.provider == 'login':
+            self.debug('Wiping transaction data')
             trans.wipe()
         raise cherrypy.HTTPRedirect(redirect)
 
             trans.wipe()
         raise cherrypy.HTTPRedirect(redirect)
 
index 4d2f887..8208d4a 100755 (executable)
@@ -15,7 +15,6 @@ TRANSID = "ipsilon_transaction_id"
 class Transaction(Log):
 
     def __init__(self, provider, **kwargs):
 class Transaction(Log):
 
     def __init__(self, provider, **kwargs):
-        self.debug('Transaction: %s' % repr(kwargs))
         self.provider = provider
         self.transaction_id = None
         self._ts = TranStore()
         self.provider = provider
         self.transaction_id = None
         self._ts = TranStore()
@@ -23,14 +22,17 @@ class Transaction(Log):
         tid = kwargs.get(TRANSID)
         if tid:
             self.transaction_id = tid
         tid = kwargs.get(TRANSID)
         if tid:
             self.transaction_id = tid
-            data = self._ts.get_unique_data(TRANSTABLE, tid)
+            data = self.retrieve()
+            if data and 'provider' in data:
+                self.provider = data['provider']
             self._get_cookie()
         else:
             data = {'provider': self.provider,
                     'origintime': str(datetime.now())}
             self.transaction_id = self._ts.new_unique_data(TRANSTABLE, data)
             self._set_cookie()
             self._get_cookie()
         else:
             data = {'provider': self.provider,
                     'origintime': str(datetime.now())}
             self.transaction_id = self._ts.new_unique_data(TRANSTABLE, data)
             self._set_cookie()
-        self.debug('Transaction id: %s' % self.transaction_id)
+        self.debug('Transaction: %s %s' % (self.provider,
+                                           self.transaction_id))
 
     def _set_cookie(self):
         self.cookie = SecureCookie(name=None, value=self.provider)
 
     def _set_cookie(self):
         self.cookie = SecureCookie(name=None, value=self.provider)