Fix for configuring non-default auth plugins properly

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
This commit is contained in:
Davanum Srinivas 2013-03-20 14:22:36 -04:00 committed by Dolph Mathews
parent ec9115b67a
commit 9446a999c5
4 changed files with 17 additions and 0 deletions

View File

@ -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. """

View File

@ -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)

View File

@ -30,3 +30,4 @@ register_bool = config.register_bool
register_cli_bool = config.register_cli_bool
register_int = config.register_int
register_cli_int = config.register_cli_int
setup_authentication = config.setup_authentication

View File

@ -789,3 +789,11 @@ class TokenExpirationTest(AuthTest):
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'))