summaryrefslogtreecommitdiffstats
path: root/askbot/deps/django_authopenid/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'askbot/deps/django_authopenid/util.py')
-rw-r--r--askbot/deps/django_authopenid/util.py46
1 files changed, 34 insertions, 12 deletions
diff --git a/askbot/deps/django_authopenid/util.py b/askbot/deps/django_authopenid/util.py
index f05aba31..b1c67b3d 100644
--- a/askbot/deps/django_authopenid/util.py
+++ b/askbot/deps/django_authopenid/util.py
@@ -176,6 +176,19 @@ def use_password_login():
return True
return False
+def is_login_method_enabled(name):
+ name_key = name.upper().replace('-', '_')
+ setting = getattr(askbot_settings, 'SIGNIN_' + name_key + '_ENABLED', None)
+ if setting is not None:
+ return setting
+
+ google_method = askbot_settings.SIGNIN_GOOGLE_METHOD
+ if name == 'google':
+ return google_method == 'openid'
+ elif name == 'google-plus':
+ return google_method == 'google-plus'
+ return False
+
def filter_enabled_providers(data):
"""deletes data about disabled providers from
the input dictionary
@@ -183,9 +196,7 @@ def filter_enabled_providers(data):
delete_list = list()
for provider_key, provider_settings in data.items():
name = provider_settings['name']
- name_key = name.upper().replace('-', '_')
- is_enabled = getattr(askbot_settings, 'SIGNIN_' + name_key + '_ENABLED')
- if is_enabled == False:
+ if not is_login_method_enabled(name):
delete_list.append(provider_key)
for provider_key in delete_list:
@@ -499,18 +510,29 @@ def get_enabled_major_login_providers():
def get_google_user_id(client):
return client.request('me')['id']
- if askbot_settings.GOOGLE_PLUS_KEY and askbot_settings.GOOGLE_PLUS_SECRET:
- data['google-plus'] = {
- 'name': 'google-plus',
+ google_method = askbot_settings.SIGNIN_GOOGLE_METHOD
+ if google_method == 'google-plus':
+ if askbot_settings.GOOGLE_PLUS_KEY and askbot_settings.GOOGLE_PLUS_SECRET:
+ data['google-plus'] = {
+ 'name': 'google-plus',
+ 'display_name': 'Google',
+ 'type': 'oauth2',
+ 'auth_endpoint': 'https://accounts.google.com/o/oauth2/auth',
+ 'token_endpoint': 'https://accounts.google.com/o/oauth2/token',
+ 'resource_endpoint': 'https://www.googleapis.com/plus/v1/people/',
+ 'icon_media_path': '/jquery-openid/images/google.gif',
+ 'get_user_id_function': get_google_user_id,
+ 'extra_auth_params': {'scope': ('profile', 'email', 'openid'), 'openid.realm': askbot_settings.APP_URL}
+ }
+ elif google_method == 'openid':
+ data['google'] = {
+ 'name': 'google',
'display_name': 'Google',
- 'type': 'oauth2',
- 'auth_endpoint': 'https://accounts.google.com/o/oauth2/auth',
- 'token_endpoint': 'https://accounts.google.com/o/oauth2/token',
- 'resource_endpoint': 'https://www.googleapis.com/plus/v1/people/',
+ 'type': 'openid-direct',
'icon_media_path': '/jquery-openid/images/google.gif',
- 'get_user_id_function': get_google_user_id,
- 'extra_auth_params': {'scope': ('profile', 'email', 'openid'), 'openid.realm': askbot_settings.APP_URL}
+ 'openid_endpoint': 'https://www.google.com/accounts/o8/id',
}
+
data['mozilla-persona'] = {
'name': 'mozilla-persona',
'display_name': 'Mozilla Persona',