Example #1
0
def validate_auth_backend_is_correctly_configured():
    # 1. Verify correct mode is specified
    if cfg.CONF.auth.mode not in VALID_MODES:
        msg = ('Invalid auth mode "%s" specified in the config. Valid modes are: %s' %
               (cfg.CONF.auth.mode, ', '.join(VALID_MODES)))
        raise ValueError(msg)

    # 2. Verify that auth backend used by the user exposes group information
    if cfg.CONF.rbac.enable and cfg.CONF.rbac.sync_remote_groups:
        auth_backend = get_auth_backend_instance(name=cfg.CONF.auth.backend)
        capabilies = getattr(auth_backend, 'CAPABILITIES', ())
        if AuthBackendCapability.HAS_GROUP_INFORMATION not in capabilies:
            msg = ('Configured auth backend doesn\'t expose user group information. Disable '
                   'remote group synchronization or use a different backend which exposes '
                   'user group membership information.')
            raise ValueError(msg)

    return True
Example #2
0
 def __init__(self, *args, **kwargs):
     self._auth_backend = get_auth_backend_instance(name=cfg.CONF.auth.backend)
     super(StandaloneAuthHandler, self).__init__(*args, **kwargs)