Skip to content

Commit

Permalink
Fix for configuring non-default auth plugins properly
Browse files Browse the repository at this point in the history
Make sure we pick up CONF.auth.methods from configuration
files. Added a test case to make sure the we don't regress

Fixes LP# 1157515

Change-Id: I70290c37b2a5378b5247a14e3bfa20d50bf8fe74
  • Loading branch information
Davanum Srinivas authored and openstack-gerrit committed Apr 9, 2013
1 parent c1eac10 commit cbac771
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions keystone/auth/controllers.py
Expand Up @@ -277,6 +277,7 @@ class Auth(controller.V3Controller):
def __init__(self, *args, **kw):
super(Auth, self).__init__(*args, **kw)
self.token_controllers_ref = token.controllers.Auth()
config.setup_authentication()

def authenticate_for_token(self, context, auth=None):
""" Authenticate user and issue a token. """
Expand Down
7 changes: 7 additions & 0 deletions keystone/common/config.py
Expand Up @@ -124,6 +124,13 @@ def setup_logging(conf):
root_logger.addHandler(handler)


def setup_authentication():
# register any non-default auth methods here (used by extensions, etc)
for method_name in CONF.auth.methods:
if method_name not in _DEFAULT_AUTH_METHODS:
register_str(method_name, group="auth")


def register_str(*args, **kw):
conf = kw.pop('conf', CONF)
group = kw.pop('group', None)
Expand Down
1 change: 1 addition & 0 deletions keystone/config.py
Expand Up @@ -30,3 +30,4 @@
register_cli_bool = config.register_cli_bool
register_int = config.register_int
register_cli_int = config.register_cli_int
setup_authentication = config.setup_authentication
8 changes: 8 additions & 0 deletions tests/test_auth.py
Expand Up @@ -790,3 +790,11 @@ def _maintain_token_expiration(self):
def test_maintain_uuid_token_expiration(self):
self.opt_in_group('signing', token_format='UUID')
self._maintain_token_expiration()


class NonDefaultAuthTest(test.TestCase):

def test_add_non_default_auth_method(self):
self.opt_in_group('auth', methods=['password', 'token', 'custom'])
config.setup_authentication()
self.assertTrue(hasattr(CONF.auth, 'custom'))

0 comments on commit cbac771

Please sign in to comment.