]> git.parisson.com Git - django-social-auth.git/commitdiff
Add setting to control enabled backends. Closes gh-112
authorMatías Aguirre <matiasaguirre@gmail.com>
Sun, 14 Aug 2011 07:16:03 +0000 (04:16 -0300)
committerMatías Aguirre <matiasaguirre@gmail.com>
Sun, 14 Aug 2011 07:16:03 +0000 (04:16 -0300)
README.rst
doc/configuration.rst
example/settings.py
social_auth/backends/__init__.py

index 4317ccd29d5e2cf251c3a81dc0e747658e8ef2e3..739a846b458989e96a565816d76f20f8cacfe81b 100644 (file)
@@ -128,6 +128,12 @@ Configuration
   Take into account that backends **must** be defined in AUTHENTICATION_BACKENDS_
   or Django won't pick them when trying to authenticate the user.
 
+- Define desired backends for your site::
+
+    SOCIAL_AUTH_ENABLED_BACKENDS = ('google', 'google-oauth', 'facebook', ...)
+
+  All backends are enabled by default.
+
 - Setup needed OAuth keys (see OAuth_ section for details)::
 
     TWITTER_CONSUMER_KEY         = ''
index 08dc90bf5a7589c814e66f4c038466a180f472fe..fc0405d5ac7a6500dff5796ec8cdbe0b3f1db904 100644 (file)
@@ -37,6 +37,12 @@ Configuration
   Take into account that backends **must** be defined in AUTHENTICATION_BACKENDS_
   or Django won't pick them when trying to authenticate the user.
 
+- Define desired backends for your site::
+
+    SOCIAL_AUTH_ENABLED_BACKENDS = ('google', 'google-oauth', 'facebook', ...)
+
+  All backends are enabled by default.
+
 - Setup needed OAuth keys (see OAuth_ section for details)::
 
     TWITTER_CONSUMER_KEY         = ''
index 158e790a6e1792a224f29a0b7cf64a84fef675e6..c55fdfbc1283d06dd6e198cc744ae1b0dbb80bbe 100644 (file)
@@ -74,6 +74,8 @@ AUTHENTICATION_BACKENDS = (
     'django.contrib.auth.backends.ModelBackend',
 )
 
+#SOCIAL_AUTH_ENABLED_BACKENDS = ('google', 'google-oauth', 'facebook')
+
 LOGIN_REDIRECT_URL = '/'
 
 try:
index e1bb5729e5728a241895ab0fa83a4940eb3671aa..ea546fa9cf5880b2c3ca64bfdfcef34f3ba71a8b 100644 (file)
@@ -710,6 +710,7 @@ SOCIAL_AUTH_IMPORT_SOURCES = (
 
 def get_backends():
     backends = {}
+    enabled_backends = _setting('SOCIAL_AUTH_ENABLED_BACKENDS')
 
     for mod_name in SOCIAL_AUTH_IMPORT_SOURCES:
         try:
@@ -725,7 +726,9 @@ def get_backends():
                     # register only enabled backends
                     backends.update(((key, val)
                                         for key, val in sub.BACKENDS.items()
-                                            if val.enabled()))
+                                            if val.enabled() and
+                                               (not enabled_backends or
+                                                key in enabled_backends)))
                 except (ImportError, AttributeError):
                     pass
     return backends