Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/backends/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Social backends
mailru
mapmyfitness
mendeley
mineid
mixcloud
moves
odnoklassnikiru
Expand Down
25 changes: 25 additions & 0 deletions docs/backends/mineid.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
MineID
======

MineID works similar to Facebook (OAuth).

- Register a new application at `MineID.org`_, set the callback URL to
``http://example.com/complete/mineid/`` replacing ``example.com`` with your
domain.

- Fill ``Client ID`` and ``Client Secret`` values in the settings::

SOCIAL_AUTH_MINEID_KEY = ''
SOCIAL_AUTH_MINEID_SECRET = ''


Self-hosted MineID
------------------

Since MineID is an Open Source software and can be self-hosted, you can
change settings to point to your instance::

SOCIAL_AUTH_MINEID_HOST = 'www.your-mineid-instance.com'
SOCIAL_AUTH_MINEID_SCHEME = 'https' # or 'http'

.. _MineID.org: https://www.mineid.org/
2 changes: 2 additions & 0 deletions docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ or extend current one):
* Live_ OAuth2
* Livejournal_ OpenId
* Mailru_ OAuth2
* MineID_ OAuth2
* Mixcloud_ OAuth2
* `Mozilla Persona`_
* Odnoklassniki_ OAuth2 and Application Auth
Expand Down Expand Up @@ -135,6 +136,7 @@ section.
.. _Live: https://www.live.com
.. _Livejournal: http://livejournal.com
.. _Mailru: https://mail.ru
.. _MineID: https://www.mineid.org
.. _Mixcloud: https://www.mixcloud.com
.. _Mozilla Persona: http://www.mozilla.org/persona/
.. _Odnoklassniki: http://www.odnoklassniki.ru
Expand Down
1 change: 1 addition & 0 deletions examples/cherrypy_example/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<a href="/login/xing">Xing OAuth</a> <br />
<a href="/login/yandex-oauth2">Yandex OAuth2</a> <br />
<a href="/login/podio">Podio OAuth2</a> <br />
<a href="/login/mineid">MineID OAuth2</a> <br />

<form action="/login/openid" method="post">
<div>
Expand Down
1 change: 1 addition & 0 deletions examples/django_example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
'social.backends.mailru.MailruOAuth2',
'social.backends.mendeley.MendeleyOAuth',
'social.backends.mendeley.MendeleyOAuth2',
'social.backends.mineid.MineIDOAuth2',
'social.backends.mixcloud.MixcloudOAuth2',
'social.backends.odnoklassniki.OdnoklassnikiOAuth2',
'social.backends.open_id.OpenIdAuth',
Expand Down
1 change: 1 addition & 0 deletions examples/django_me_example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
'social.backends.xing.XingOAuth',
'social.backends.yandex.YandexOAuth2',
'social.backends.douban.DoubanOAuth2',
'social.backends.mineid.MineIDOAuth2',
'social.backends.mixcloud.MixcloudOAuth2',
'social.backends.rdio.RdioOAuth1',
'social.backends.rdio.RdioOAuth2',
Expand Down
1 change: 1 addition & 0 deletions examples/django_me_example/example/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<a href="{% url 'social:begin' "xing" %}">Xing OAuth</a> <br />
<a href="{% url 'social:begin' "yandex-oauth2" %}">Yandex OAuth2</a> <br />
<a href="{% url 'social:begin' "douban-oauth2" %}">Douban OAuth2</a> <br />
<a href="{% url 'social:begin' "mineid" %}">MineID OAuth2</a> <br />
<a href="{% url 'social:begin' "mixcloud" %}">Mixcloud OAuth2</a> <br />
<a href="{% url 'social:begin' "rdio-oauth2" %}">Rdio OAuth2</a> <br />
<a href="{% url 'social:begin' "rdio-oauth1" %}">Rdio OAuth1</a> <br />
Expand Down
1 change: 1 addition & 0 deletions examples/flask_example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
'social.backends.yandex.YandexOAuth2',
'social.backends.podio.PodioOAuth2',
'social.backends.reddit.RedditOAuth2',
'social.backends.mineid.MineIDOAuth2',
)
1 change: 1 addition & 0 deletions examples/flask_example/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<a href="{{ url_for("social.auth", backend="xing") }}">Xing OAuth</a> <br />
<a href="{{ url_for("social.auth", backend="yandex-oauth2") }}">Yandex OAuth2</a> <br />
<a href="{{ url_for("social.auth", backend="podio") }}">Podio OAuth2</a> <br />
<a href="{{ url_for("social.auth", backend="mineid") }}">MineID OAuth2</a> <br />

<form action="{{ url_for("social.auth", backend="openid") }}" method="post">
<div>
Expand Down
1 change: 1 addition & 0 deletions examples/flask_me_example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@
'social.backends.yandex.YandexOAuth2',
'social.backends.podio.PodioOAuth2',
'social.backends.reddit.RedditOAuth2',
'social.backends.mineid.MineIDOAuth2',
)
1 change: 1 addition & 0 deletions examples/pyramid_example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'social.backends.yandex.YandexOAuth2',
'social.backends.podio.PodioOAuth2',
'social.backends.reddit.RedditOAuth2',
'social.backends.mineid.MineIDOAuth2',
)
}

Expand Down
1 change: 1 addition & 0 deletions examples/tornado_example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'social.backends.yandex.YandexOAuth2',
'social.backends.podio.PodioOAuth2',
'social.backends.reddit.RedditOAuth2',
'social.backends.mineid.MineIDOAuth2',
)

from local_settings import *
1 change: 1 addition & 0 deletions examples/tornado_example/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<a href="/login/xing">Xing OAuth</a> <br />
<a href="/login/yandex-oauth2">Yandex OAuth2</a> <br />
<a href="/login/podio">Podio OAuth2</a> <br />
<a href="/login/mineid">MineID OAuth2</a> <br />

<form action="/login/openid" method="post">
<div>
Expand Down
1 change: 1 addition & 0 deletions examples/webpy_example/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'social.backends.xing.XingOAuth',
'social.backends.yandex.YandexOAuth2',
'social.backends.podio.PodioOAuth2',
'social.backends.mineid.MineIDOAuth2',
)
web.config[setting_name('LOGIN_REDIRECT_URL')] = '/done/'

Expand Down
1 change: 1 addition & 0 deletions examples/webpy_example/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<a href="/login/xing/">Xing OAuth</a> <br />
<a href="/login/yandex-oauth2/">Yandex OAuth2</a> <br />
<a href="/login/podio/">Podio OAuth2</a> <br />
<a href="/login/mineid/">MineID OAuth2</a> <br />

<form action="/login/openid/" method="post">
<div>
Expand Down
41 changes: 41 additions & 0 deletions social/backends/mineid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import json
import urllib

from social.backends.oauth import BaseOAuth2


class MineIDOAuth2(BaseOAuth2):
"""MineID OAuth2 authentication backend"""
name = 'mineid'
_AUTHORIZATION_URL = '%(scheme)s://%(host)s/oauth/authorize'
_ACCESS_TOKEN_URL = '%(scheme)s://%(host)s/oauth/access_token'
ACCESS_TOKEN_METHOD = 'POST'
SCOPE_SEPARATOR = ','
EXTRA_DATA = [
]

def get_user_details(self, response):
"""Return user details"""
return {'email': response.get('email'),
'username': response.get('email')}

def user_data(self, access_token, *args, **kwargs):
return self._user_data(access_token)

def _user_data(self, access_token, path=None):
url = '%(scheme)s://%(host)s/api/user' % self.get_mineid_url_params()
return self.get_json(url, params={'access_token': access_token})

@property
def AUTHORIZATION_URL(self):
return self._AUTHORIZATION_URL % self.get_mineid_url_params()

@property
def ACCESS_TOKEN_URL(self):
return self._ACCESS_TOKEN_URL % self.get_mineid_url_params()

def get_mineid_url_params(self):
return {
'host': self.setting('HOST', 'www.mineid.org'),
'scheme': self.setting('SCHEME', 'https'),
}
26 changes: 26 additions & 0 deletions social/tests/backends/test_mineid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import json

from social.p3 import urlencode
from social.exceptions import AuthUnknownError

from social.tests.backends.oauth import OAuth2Test


class MineIDOAuth2Test(OAuth2Test):
backend_path = 'social.backends.mineid.MineIDOAuth2'
user_data_url = 'https://www.mineid.org/api/user'
expected_username = 'foo@bar.com'
access_token_body = json.dumps({
'access_token': 'foobar',
'token_type': 'bearer'
})
user_data_body = json.dumps({
'email': 'foo@bar.com',
'primary_profile': None,
})

def test_login(self):
self.do_login()

def test_partial_pipeline(self):
self.do_partial_pipeline()