Skip to content

Commit 2ce3794

Browse files
committed
Merge branch 'master' of github.com:ASKBOT/askbot-devel
2 parents 59c177e + 31c4ab6 commit 2ce3794

File tree

6 files changed

+54
-2
lines changed

6 files changed

+54
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
fetch
66
push
77
propagate
8+
askbot/media/style/.sass-cache/
9+
.sass-cache
810
db
911
rebuild-locales.pl
1012
/src

askbot/conf/external_keys.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,24 @@
244244
description=_('Windows Live secret key'),
245245
)
246246
)
247+
248+
settings.register(
249+
livesettings.StringValue(
250+
EXTERNAL_KEYS,
251+
'MICROSOFT_AZURE_KEY',
252+
description=_('Microsoft Azure client id'),
253+
help_text=_(
254+
'Please register your client application at <a href="%(url)s">'
255+
'windows applications site</a>'
256+
) % {'url': const.DEPENDENCY_URLS['microsoft-azure-apps']},
257+
258+
)
259+
)
260+
261+
settings.register(
262+
livesettings.StringValue(
263+
EXTERNAL_KEYS,
264+
'MICROSOFT_AZURE_SECRET',
265+
description=_('Microsoft Azure secret key'),
266+
)
267+
)

askbot/conf/login_providers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,13 @@
222222
'OpenStackID',
223223
'Yammer',
224224
'Windows Live',
225+
'Microsoft Azure',
225226
)
226227

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

229230
NEED_EXTRA_SETUP = ('Google Plus', 'Twitter', 'MediaWiki', 'Facebook',
230-
'LinkedIn', 'identi.ca', 'Yammer', 'Windows Live',)
231+
'LinkedIn', 'identi.ca', 'Yammer', 'Windows Live', 'Microsoft Azure',)
231232

232233
for provider in providers:
233234
if provider == 'local':

askbot/const/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@
523523
'mediawiki-oauth-extension': 'https://www.mediawiki.org/wiki/Extension:OAuth',
524524
'yammer-apps': 'https://www.yammer.com/client_applications',
525525
'windows-live-apps': 'https://apps.dev.microsoft.com/#/appList',
526+
'microsoft-azure-apps': 'https://apps.dev.microsoft.com/#/appList',
526527
}
527528

528529
PASSWORD_MIN_LENGTH = 8

askbot/deps/django_authopenid/util.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ def get_facebook_user_id(client):
484484
'response_parser': lambda data: simplejson.loads(data),
485485
}
486486

487-
488487
if askbot_settings.WINDOWS_LIVE_KEY and askbot_settings.WINDOWS_LIVE_SECRET:
489488
data['windows-live'] = {
490489
'name': 'windows-live',
@@ -499,6 +498,31 @@ def get_facebook_user_id(client):
499498
'extra_auth_params': {'scope': ('wl.basic',)},
500499
}
501500

501+
def get_microsoft_azure_user_id(client):
502+
conn = httplib.HTTPSConnection('graph.microsoft.com')
503+
headers = {
504+
'Authorization' : 'Bearer {0}'.format(client.access_token),
505+
'Accept' : 'application/json',
506+
}
507+
conn.request('GET', '/v1.0/me', '', headers)
508+
response = conn.getresponse()
509+
profile = simplejson.loads(response.read())
510+
return profile['id']
511+
512+
if askbot_settings.MICROSOFT_AZURE_KEY and askbot_settings.MICROSOFT_AZURE_SECRET:
513+
data['microsoft-azure'] = {
514+
'name': 'microsoft-azure',
515+
'display_name': 'Microsoft Azure',
516+
'type': 'oauth2',
517+
'auth_endpoint': 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
518+
'token_endpoint': 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
519+
'resource_endpoint': 'https://graph.microsoft.com/v1.0/',
520+
'icon_media_path': 'images/jquery-openid/microsoft-azure.png',
521+
'get_user_id_function': get_microsoft_azure_user_id,
522+
'response_parser': lambda data: simplejson.loads(data),
523+
'extra_auth_params': {'scope': ('User.Read',),},
524+
}
525+
502526
if askbot_settings.SIGNIN_FEDORA_ENABLED:
503527
data['fedora'] = {
504528
'name': 'fedora',
@@ -854,6 +878,9 @@ def get_oauth_parameters(provider_name):
854878
elif provider_name == 'windows-live':
855879
consumer_key = askbot_settings.WINDOWS_LIVE_KEY
856880
consumer_secret = askbot_settings.WINDOWS_LIVE_SECRET
881+
elif provider_name == 'microsoft-azure':
882+
consumer_key = askbot_settings.MICROSOFT_AZURE_KEY
883+
consumer_secret = askbot_settings.MICROSOFT_AZURE_SECRET
857884
elif provider_name != 'mediawiki':
858885
raise ValueError('unexpected oauth provider %s' % provider_name)
859886

Loading

0 commit comments

Comments
 (0)