diff options
| author | Joe Heck <heckj@mac.com> | 2012-02-05 16:24:42 -0800 |
|---|---|---|
| committer | Joe Heck <heckj@mac.com> | 2012-02-06 20:23:04 +0000 |
| commit | fca3e9c0453bc6adeb50c77dd1be79933132fdaf (patch) | |
| tree | 1aafbf311780c7c0ca7236408e5b93d2f25260be | |
| parent | 446b26850d1afa1bd239c3048a23fc818b86c8f0 (diff) | |
adding a token service Driver to define the interface
| -rw-r--r-- | keystone/token/backends/kvs.py | 3 | ||||
| -rw-r--r-- | keystone/token/core.py | 47 |
2 files changed, 49 insertions, 1 deletions
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() |
