Skip to content

Commit

Permalink
implement 'Yammer' oauth2 authentication method
Browse files Browse the repository at this point in the history
  • Loading branch information
fonar committed Sep 24, 2017
1 parent 3842acc commit ebf544f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion askbot/conf/login_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,13 @@
'identi.ca',
'LaunchPad',
'OpenStackID',
'Yammer',
)

DISABLED_BY_DEFAULT = ('LaunchPad', 'Mozilla Persona', 'OpenStackID')

NEED_EXTRA_SETUP = ('Google Plus', 'Twitter', 'MediaWiki', 'Facebook',
'LinkedIn', 'identi.ca')
'LinkedIn', 'identi.ca', 'Yammer',)

for provider in providers:
if provider == 'local':
Expand Down
3 changes: 2 additions & 1 deletion askbot/const/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@
'mathjax': 'http://www.mathjax.org/resources/docs/?installation.html',
'recaptcha': 'http://google.com/recaptcha',
'twitter-apps': 'http://dev.twitter.com/apps/',
'mediawiki-oauth-extension': 'https://www.mediawiki.org/wiki/Extension:OAuth'
'mediawiki-oauth-extension': 'https://www.mediawiki.org/wiki/Extension:OAuth',
'yammer-apps': 'https://www.yammer.com/client_applications',
}

PASSWORD_MIN_LENGTH = 8
Expand Down
16 changes: 16 additions & 0 deletions askbot/deps/django_authopenid/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,19 @@ def get_facebook_user_id(client):
'scope': ['email',],
}

if askbot_settings.YAMMER_KEY and askbot_settings.YAMMER_SECRET:
data['yammer'] = {
'name': 'yammer',
'display_name': 'Yammer',
'type': 'oauth2',
'auth_endpoint': 'https://www.yammer.com/dialog/oauth',
'token_endpoint': 'https://www.yammer.com/oauth2/access_token',
'resource_endpoint': 'https://www.yammer.com/api/v1/users/current.json',
'icon_media_path': 'images/jquery-openid/yammer.png',
'get_user_id_function': lambda data: data.user['id'],
'response_parser': lambda data: simplejson.loads(data),
}

if askbot_settings.SIGNIN_FEDORA_ENABLED:
data['fedora'] = {
'name': 'fedora',
Expand Down Expand Up @@ -820,6 +833,9 @@ def get_oauth_parameters(provider_name):
elif provider_name == 'facebook':
consumer_key = askbot_settings.FACEBOOK_KEY
consumer_secret = askbot_settings.FACEBOOK_SECRET
elif provider_name == 'yammer':
consumer_key = askbot_settings.YAMMER_KEY
consumer_secret = askbot_settings.YAMMER_SECRET
elif provider_name != 'mediawiki':
raise ValueError('unexpected oauth provider %s' % provider_name)

Expand Down
Binary file added askbot/media/images/jquery-openid/yammer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ebf544f

Please sign in to comment.