def load_auth_methods(): global AUTH_PLUGINS_LOADED if AUTH_PLUGINS_LOADED: # Only try and load methods a single time. return # config.setup_authentication should be idempotent, call it to ensure we # have setup all the appropriate configuration options we may need. config.setup_authentication() for plugin in CONF.auth.methods: if '.' in plugin: # NOTE(morganfainberg): if '.' is in the plugin name, it should be # imported rather than used as a plugin identifier. plugin_class = plugin driver = importutils.import_object(plugin) if not hasattr(driver, 'method'): raise ValueError(_('Cannot load an auth-plugin by class-name ' 'without a "method" attribute defined: %s'), plugin_class) LOG.info(_LI('Loading auth-plugins by class-name is deprecated.')) plugin_name = driver.method else: plugin_name = plugin plugin_class = CONF.auth.get(plugin) driver = importutils.import_object(plugin_class) if plugin_name in AUTH_METHODS: raise ValueError(_('Auth plugin %(plugin)s is requesting ' 'previously registered method %(method)s') % {'plugin': plugin_class, 'method': driver.method}) AUTH_METHODS[plugin_name] = driver AUTH_PLUGINS_LOADED = True
def load_auth_methods(): global AUTH_PLUGINS_LOADED if AUTH_PLUGINS_LOADED: # Only try and load methods a single time. return # config.setup_authentication should be idempotent, call it to ensure we # have setup all the appropriate configuration options we may need. config.setup_authentication() for plugin in set(CONF.auth.methods): AUTH_METHODS[plugin] = load_auth_method(plugin) AUTH_PLUGINS_LOADED = True
def load_auth_methods(): global AUTH_PLUGINS_LOADED if AUTH_PLUGINS_LOADED: # Only try and load methods a single time. return # config.setup_authentication should be idempotent, call it to ensure we # have setup all the appropriate configuration options we may need. config.setup_authentication() for plugin in CONF.auth.methods: if "." in plugin: # NOTE(morganfainberg): if '.' is in the plugin name, it should be # imported rather than used as a plugin identifier. plugin_class = plugin driver = importutils.import_object(plugin) if not hasattr(driver, "method"): raise ValueError( _("Cannot load an auth-plugin by class-name " 'without a "method" attribute defined: %s'), plugin_class, ) else: plugin_class = CONF.auth.get(plugin) driver = importutils.import_object(plugin_class) if hasattr(driver, "method"): if driver.method != plugin: raise ValueError( _("Driver requested method %(req)s does " "not match plugin name %(plugin)s.") % {"req": driver.method, "plugin": plugin} ) else: LOG.warning(_('Auth Plugin %s does not have a "method" ' "attribute."), plugin) setattr(driver, "method", plugin) if driver.method in AUTH_METHODS: raise ValueError( _("Auth plugin %(plugin)s is requesting " "previously registered method %(method)s") % {"plugin": plugin_class, "method": driver.method} ) AUTH_METHODS[driver.method] = driver AUTH_PLUGINS_LOADED = True
def __init__(self, *args, **kw): super(Auth, self).__init__(*args, **kw) config.setup_authentication()
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'))
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"))
def test_add_non_default_auth_method(self): self.config_fixture.config(group='auth', methods=['password', 'token', 'custom']) config.setup_authentication() self.assertTrue(hasattr(CONF.auth, 'custom'))
def __init__(self, *args, **kw): super(Auth, self).__init__(*args, **kw) self.token_controllers_ref = token.controllers.Auth() config.setup_authentication()