From fca3e9c0453bc6adeb50c77dd1be79933132fdaf Mon Sep 17 00:00:00 2001 From: Joe Heck Date: Sun, 5 Feb 2012 16:24:42 -0800 Subject: adding a token service Driver to define the interface --- keystone/token/backends/kvs.py | 3 ++- keystone/token/core.py | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/keystone/token/backends/kvs.py b/keystone/token/backends/kvs.py index b7c25fb7..c19bcc79 100644 --- a/keystone/token/backends/kvs.py +++ b/keystone/token/backends/kvs.py @@ -1,9 +1,10 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 +from keystone import token from keystone.common import kvs -class Token(kvs.Base): +class Token(kvs.Base, token.Driver): # Public interface def get_token(self, token_id): return self.db.get('token-%s' % token_id) diff --git a/keystone/token/core.py b/keystone/token/core.py index e7827696..47dadcea 100644 --- a/keystone/token/core.py +++ b/keystone/token/core.py @@ -19,3 +19,50 @@ class Manager(manager.Manager): def __init__(self): super(Manager, self).__init__(CONF.token.driver) + + +class Driver(object): + """Interface description for a Token driver.""" + + def get_token(self, token_id): + """Get a token by id. + + :param token_id: identity of the token + :type token_id: string + :returns: token_ref or None. + + """ + raise NotImplementedError() + + def create_token(self, token_id, data): + """Create a token by id and data. + + :param token_id: identity of the token + :type token_id: string + :param data: dictionary with additional reference information + + :: + + { + expires='' + id=token_id, + user=user_ref, + tenant=tenant_ref, + metadata=metadata_ref + } + + :type data: dict + :returns: token_ref or None. + + """ + raise NotImplementedError() + + def delete_token(self, token_id): + """Deletes a token by id. + + :param token_id: identity of the token + :type token_id: string + :returns: None. + + """ + raise NotImplementedError() -- cgit