Пример #1
0
 def configure_oauth_provider(**kwargs):
     """ Update the settings for an OAuth2-based third party auth provider """
     kwargs.setdefault('provider_slug', kwargs['backend_name'])
     kwargs.setdefault('slug', kwargs['backend_name'])
     obj = OAuth2ProviderConfig(**kwargs)
     obj.save()
     return obj
Пример #2
0
def get_oauth_provider_config(name):
    """
    Get 'other_settings' from the provider config.
    """
    # Importing module here to avoid circular reference
    from third_party_auth.models import OAuth2ProviderConfig
    provider_config = OAuth2ProviderConfig.current(name)
    settings = json.loads(provider_config.other_settings)
    return settings
Пример #3
0
    def handle(self, name, slug, site, backend_name, *args, **options):
        """
        It can't be executed before a Site exists.
        """
        set_site = Site.objects.get(name=site, domain=site)
        provider = OAuth2ProviderConfig(name=name)
        provider.slug = slug
        provider.Site = set_site
        provider.enabled = True
        provider.visible = True
        provider.backend_name = backend_name
        provider.save()

        LOG.info("Enable third party authentication for '{site_name}'".format(
            site_name=set_site.name))
Пример #4
0
    def setting(self, name, default=None):
        """Return setting value from strategy"""
        try:
            from third_party_auth.models import OAuth2ProviderConfig
        except ImportError:
            OAuth2ProviderConfig = None

        if OAuth2ProviderConfig is not None:
            provider_config = OAuth2ProviderConfig.current(self.name)
            if not provider_config.enabled:
                raise Exception("Can't fetch setting of a disabled backend.")
            try:
                return provider_config.get_setting(name)
            except KeyError:
                pass
        return super(NpoedBackend, self).setting(name, default=default)
    def setting(self, name, default=None):
        """Return setting value from strategy"""
        try:
            from third_party_auth.models import OAuth2ProviderConfig
        except ImportError:
            OAuth2ProviderConfig = None

        if OAuth2ProviderConfig is not None:
            provider_config = OAuth2ProviderConfig.current(self.name)
            if not provider_config.enabled:
                raise Exception("Can't fetch setting of a disabled backend.")
            try:
                return provider_config.get_setting(name)
            except KeyError:
                pass
        return super(WPOAuthBackend, self).setting(name, default=default)
Пример #6
0
 def configure_oauth_provider(**kwargs):
     """ Update the settings for an OAuth2-based third party auth provider """
     obj = OAuth2ProviderConfig(**kwargs)
     obj.save()
     return obj
Пример #7
0
 def _id3_config(self):
     from third_party_auth.models import OAuth2ProviderConfig
     return OAuth2ProviderConfig.current(self.name)