Skip to content

Commit

Permalink
Fix error where consumer is not deleted from sql
Browse files Browse the repository at this point in the history
Looks like when the token sql backend was going through tokens
to delete, it didn't like if the token ref didn't have a token
field. I placed a guard in there now.

fixes bug: #1215493

Change-Id: Ia12f5e4d9af71c322c9230464ae39ec88303b600
  • Loading branch information
Steve Martinelli committed Aug 22, 2013
1 parent b6f6b57 commit f28d9f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion keystone/contrib/oauth1/backends/sql.py
Expand Up @@ -108,7 +108,7 @@ def create_consumer(self, consumer):
return consumer_ref.to_dict()

def _delete_consumer(self, session, consumer_id):
consumer_ref = self._get_consumer(session, consumer_id)
consumer_ref = self._get_consumer(consumer_id)
q = session.query(Consumer)
q = q.filter_by(id=consumer_id)
q.delete(False)
Expand Down
9 changes: 6 additions & 3 deletions keystone/token/backends/sql.py
Expand Up @@ -118,12 +118,15 @@ def _tenant_matches(self, tenant_id, token_ref_dict):
(token_ref_dict.get('tenant') and
token_ref_dict['tenant'].get('id') == tenant_id))

def _consumer_matches(self, consumer_id, token_ref_dict):
def _consumer_matches(self, consumer_id, ref):
if consumer_id is None:
return True
else:
oauth = token_ref_dict['token_data']['token'].get('OS-OAUTH1', {})
return oauth and oauth['consumer_id'] == consumer_id
try:
oauth = ref['token_data']['token'].get('OS-OAUTH1', {})
return oauth and oauth['consumer_id'] == consumer_id
except KeyError:
return False

def _list_tokens_for_trust(self, trust_id):
session = self.get_session()
Expand Down

0 comments on commit f28d9f4

Please sign in to comment.