summaryrefslogtreecommitdiffstats
path: root/nova/auth
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-08-17 17:58:52 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-08-17 17:58:52 -0700
commitcdcbd516f62290697643eecc56550460bd48ff14 (patch)
tree798d4da90b8025b041a3f2b5efe86f3e33e8ef53 /nova/auth
parent1cd448f907e132c451d6b27c64d16c17b7530952 (diff)
parent018ce9abbfb7047eff1e99379fba098a365e89eb (diff)
downloadnova-cdcbd516f62290697643eecc56550460bd48ff14.tar.gz
nova-cdcbd516f62290697643eecc56550460bd48ff14.tar.xz
nova-cdcbd516f62290697643eecc56550460bd48ff14.zip
merged trunk
Diffstat (limited to 'nova/auth')
-rw-r--r--nova/auth/fakeldap.py1
-rw-r--r--nova/auth/ldapdriver.py1
-rw-r--r--nova/auth/manager.py12
-rw-r--r--nova/auth/rbac.py2
-rw-r--r--nova/auth/signer.py10
5 files changed, 17 insertions, 9 deletions
diff --git a/nova/auth/fakeldap.py b/nova/auth/fakeldap.py
index b420924af..bc744fa01 100644
--- a/nova/auth/fakeldap.py
+++ b/nova/auth/fakeldap.py
@@ -219,7 +219,6 @@ class FakeLDAP(object):
raise NO_SUCH_OBJECT()
return objects
-
@property
def __redis_prefix(self):
return 'ldap:'
diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py
index 453fa196c..6bf7fcd1e 100644
--- a/nova/auth/ldapdriver.py
+++ b/nova/auth/ldapdriver.py
@@ -30,6 +30,7 @@ import sys
from nova import exception
from nova import flags
+
FLAGS = flags.FLAGS
flags.DEFINE_string('ldap_url', 'ldap://localhost',
'Point this at your ldap server')
diff --git a/nova/auth/manager.py b/nova/auth/manager.py
index 4a813c861..c16eb0c3c 100644
--- a/nova/auth/manager.py
+++ b/nova/auth/manager.py
@@ -38,7 +38,6 @@ from nova.network import vpn
FLAGS = flags.FLAGS
-
flags.DEFINE_list('allowed_roles',
['cloudadmin', 'itsec', 'sysadmin', 'netadmin', 'developer'],
'Allowed roles for project')
@@ -53,7 +52,6 @@ flags.DEFINE_list('superuser_roles', ['cloudadmin'],
flags.DEFINE_list('global_roles', ['cloudadmin', 'itsec'],
'Roles that apply to all projects')
-
flags.DEFINE_string('credentials_template',
utils.abspath('auth/novarc.template'),
'Template for creating users rc file')
@@ -68,15 +66,14 @@ flags.DEFINE_string('credential_cert_file', 'cert.pem',
'Filename of certificate in credentials zip')
flags.DEFINE_string('credential_rc_file', 'novarc',
'Filename of rc in credentials zip')
-
flags.DEFINE_string('credential_cert_subject',
'/C=US/ST=California/L=MountainView/O=AnsoLabs/'
'OU=NovaDev/CN=%s-%s',
'Subject for certificate for users')
-
flags.DEFINE_string('auth_driver', 'nova.auth.ldapdriver.FakeLdapDriver',
'Driver that auth manager uses')
+
class AuthBase(object):
"""Base class for objects relating to auth
@@ -84,6 +81,7 @@ class AuthBase(object):
an id member. They may optionally contain methods that delegate to
AuthManager, but should not implement logic themselves.
"""
+
@classmethod
def safe_id(cls, obj):
"""Safe get object id
@@ -101,6 +99,7 @@ class AuthBase(object):
class User(AuthBase):
"""Object representing a user"""
+
def __init__(self, id, name, access, secret, admin):
AuthBase.__init__(self)
self.id = id
@@ -162,6 +161,7 @@ class KeyPair(AuthBase):
Even though this object is named KeyPair, only the public key and
fingerprint is stored. The user's private key is not saved.
"""
+
def __init__(self, id, name, owner_id, public_key, fingerprint):
AuthBase.__init__(self)
self.id = id
@@ -180,6 +180,7 @@ class KeyPair(AuthBase):
class Project(AuthBase):
"""Represents a Project returned from the datastore"""
+
def __init__(self, id, name, project_manager_id, description, member_ids):
AuthBase.__init__(self)
self.id = id
@@ -233,7 +234,6 @@ class Project(AuthBase):
self.member_ids)
-
class AuthManager(object):
"""Manager Singleton for dealing with Users, Projects, and Keypairs
@@ -245,7 +245,9 @@ class AuthManager(object):
AuthManager also manages associated data related to Auth objects that
need to be more accessible, such as vpn ips and ports.
"""
+
_instance = None
+
def __new__(cls, *args, **kwargs):
"""Returns the AuthManager singleton"""
if not cls._instance:
diff --git a/nova/auth/rbac.py b/nova/auth/rbac.py
index 7fab9419f..1446e4e27 100644
--- a/nova/auth/rbac.py
+++ b/nova/auth/rbac.py
@@ -32,6 +32,7 @@ def allow(*roles):
return wrapped_f
return wrap
+
def deny(*roles):
def wrap(f):
def wrapped_f(self, context, *args, **kwargs):
@@ -44,6 +45,7 @@ def deny(*roles):
return wrapped_f
return wrap
+
def __matches_role(context, role):
if role == 'all':
return True
diff --git a/nova/auth/signer.py b/nova/auth/signer.py
index 634f22f0d..8334806d2 100644
--- a/nova/auth/signer.py
+++ b/nova/auth/signer.py
@@ -48,11 +48,15 @@ import hashlib
import hmac
import logging
import urllib
-import boto # NOTE(vish): for new boto
-import boto.utils # NOTE(vish): for old boto
+
+# NOTE(vish): for new boto
+import boto
+# NOTE(vish): for old boto
+import boto.utils
from nova.exception import Error
+
class Signer(object):
""" hacked up code from boto/connection.py """
@@ -77,7 +81,6 @@ class Signer(object):
return self._calc_signature_2(params, verb, server_string, path)
raise Error('Unknown Signature Version: %s' % self.SignatureVersion)
-
def _get_utf8_value(self, value):
if not isinstance(value, str) and not isinstance(value, unicode):
value = str(value)
@@ -133,5 +136,6 @@ class Signer(object):
logging.debug('base64 encoded digest: %s' % b64)
return b64
+
if __name__ == '__main__':
print Signer('foo').generate({"SignatureMethod": 'HmacSHA256', 'SignatureVersion': '2'}, "get", "server", "/foo")