'Load the setting from a ConfigurationModel if possible, or fall back to the normal
Django settings lookup.
OAuthAuth subclasses will call this method for every setting they want to look up.
SAMLAuthBackend subclasses will call this method only after first checking if the
setting \'name\' is configured via SAMLProviderConfig.
LTIAuthBackend subclasses will call this method only after first checking if the
setting \'name\' is configured via LTIProviderConfig.'

def setting(self, name, default=None, backend=None):

    if isinstance(backend, OAuthAuth):
        provider_config = OAuth2ProviderConfig.current(backend.name)
        if (not provider_config.enabled_for_current_site):
            raise Exception("Can't    fetch    setting    of    a    disabled    backend/provider.")
        try:
            return provider_config.get_setting(name)
        except KeyError:
            pass
    if (name == 'LOGIN_ERROR_URL'):
        auth_entry = self.request.session.get('auth_entry')
        if (auth_entry and (auth_entry in AUTH_ENTRY_CUSTOM)):
            error_url = AUTH_ENTRY_CUSTOM[auth_entry].get('error_url')
            if error_url:
                return error_url
    if (name == 'MAX_SESSION_LENGTH'):
        running_pipeline = (get_pipeline_from_request(self.request) if self.request else None)
        if (running_pipeline is not None):
            provider_config = Registry.get_from_pipeline(running_pipeline)
            if provider_config:
                return provider_config.max_session_length
    return super(ConfigurationModelStrategy, self).setting(name, default, backend)
