python-dataporten-auth


Namepython-dataporten-auth JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/UNINETT/python-dataporten-auth
SummaryA plugin for python-social-auth to authenticate with dataporten
upload_time2017-06-19 10:37:43
maintainer
docs_urlNone
authorHanne Moa
requires_python
licenseMIT
keywords django oauth2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            python-dataporten-auth
======================

Dataporten_ is an authentication, authorization and API platform
for higher and lower education and research in Norway. Dataporten
offers authentication of users to applications using OAuth 2.0 and
the OpenID Connect.

Dataporten-auth is a client for dataporten that depends on
social-auth-core_.

This library is not compatible with the pre-refactor
python-social-auth_, see any version prior to 2.0.x for that.
Furthermore, this is now a Python 3 based project; No attempts
have been made to make it backwards compatible with Python 2.

If you are using the previous incarnation of ``python-dataporten-auth``:
``dataporten-auth``, see `Upgrading from dataporten-auth`_.


Installation
------------

Install with ``pip install python-dataporten-auth`` or by downloading the
source and running ``setup.py``.



Usage
-----

Set up an application at Dataporten
...................................

There needs to exist an entry for your site/app at dataporten. Log
in to `dataporten's dashboard`_ and create an application. The
entry needs one or more redirect uris.

You can have several redirect-uris, and you will be needing at
least one per plugin used.

The redirect uri is of the form ``<type>://<domainpath>/<suffix>/``,
where ``<type>`` is one of ``http`` or ``https``, ``<domainpath>``
is the domain name of your site and an optional path, and the
``<suffix>`` is plugin-dependent. See the examples under
**Plugins**.

Set up your site
................

You'll need to set the client id and client secret generated by
Dataporten in the settings of your app/site.


Both the name of the settings and the redirect uris depend on the
plugins used. Add at least one of the plugins below.

See `social's documentation`_ for more.

Django
......

In your ``settings.py``:

* Add ``'social_django'`` to ``INSTALLED_APPS``.
* Add one or more of the plugin names below to the start of
  ``AUTHENTICATION_BACKENDS``. If you're also using user-models
  à la Django, ``'django.contrib.auth.backends.ModelBackend'``
  must be in the same list, following the plugins.
* Set ``SOCIAL_AUTH_DATAPORTEN_FEIDE_SSL_PROTOCOL`` to ``True`` to
  use SSL. * ``SOCIAL_AUTH_LOGIN_REDIRECT_URL``,
  ``SOCIAL_AUTH_NEW_USER_REDIRECT_URL`` and
  ``SOCIAL_AUTH_REDIRECT_IS_HTTPS`` will have to be set depending
  on the needs of your site.
* If you use the Django admin, you might want to set
  ``SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS``, for instance to
  ``['username', 'email']``.

Also see the settings in ``src\demosite\settings.py`` in the source.

In your site's ``urls.py``, include:

``url(PREFIX, include('social_django.urls', namespace='social')),``

... where PREFIX is a string to start off the urls with. Empty
string, ``''``, is fine.

Upgrading from dataporten-auth
------------------------------

See `PSA's official migration document`_, here follows a summary.

1. Install ``python-social-auth`` version 0.2.21.
2. Run migrations.
3. Uninstall ``dataporten-auth``
4. Install ``python-dataporten-auth``.
5. Install ``social-auth-app-django``.
6. In your ``urls.py`` rename ``'social.apps.django_app.urls'`` to  ``'social_django.urls'``.
7. In your ``settings.py``, in this order:

  1. Rename ``'social.apps.django_app.default'`` to ``'social_django'``.
  2. Replace all mentions of ``'social.*'`` with ``'social_core.*'``.
  3. Replace all mentions of ``psa`` with ``social``.

8. Run migrations for ``social_django``.
9. Uninstall ``python-social-auth``.

Plugins
-------

dataporten.social.DataportenOAuth2
..................................

Plugin name
    ``dataporten.social.DataportenOAuth2``

Settings
    Client id: ``SOCIAL_AUTH_DATAPORTEN_KEY``

    Client secret: ``SOCIAL_AUTH_DATAPORTEN_SECRET``

Scopes needed
    ``userid`` and ``profile``, this is the default.

Username generated:
    Unique, alphanumeric string. You might want to let users
    change this generated username. The plugin only cares that a
    username exists and won't change the username back.

Redirect-uri ends with
    /complete/dataporten/

Example redirect uri:
    http://127.0.0.1/complete/dataporten/

dataporten.social.DataportenEmailOAuth2
.......................................

Plugin name
    ``dataporten.social.DataportenEmailOAuth2``

Settings
    Client id: ``SOCIAL_AUTH_DATAPORTEN_EMAIL_KEY``

    Client secret: ``SOCIAL_AUTH_DATAPORTEN_EMAIL_SECRET``

Scopes needed
    ``email``, this must be explicitly allowed in the dashboard.

Username generated:
    From email-address

Redirect-uri ends with
    /complete/dataporten_email/

Example redirect uri:
    https://supersites.example.net/mysite/complete/dataporten_email/

dataporten.social.DataportenFeideOAuth2
.......................................

Plugin name
    ``dataporten.social.DataportenFeideOAuth2``

Settings
    Client id: ``SOCIAL_AUTH_DATAPORTEN_FEIDE_KEY``

    Client secret: ``SOCIAL_AUTH_DATAPORTEN_FEIDE_SECRET``

Scopes needed
    ``userid-feide``, this must be explicitly allowed in the dashboard.

Username generated:
    From the Feide attribute ``eduPersonPrincipalName``, which looks
    like an email address.

Redirect-uri ends with
    /complete/dataporten_feide/

Example redirect uri:
    https://example.com/cheatsheet/complete/dataporten_feide/



Demo
----

The Demo needs Django 1.8 or newer.

1. Get the source code
2. Install dependencies: ``pip install -r requirements/demo.txt``
3. Make an application at dataporten
4. Edit the settings-file to set ``SOCIAL_AUTH_DATAPORTEN_KEY`` and ``SOCIAL_AUTH_DATAPORTEN_SECRET``
5. Set three redirect-uris, all starting with ``http://127.0.0.1:8000``
6. Run ``python mange.py runserver``
7. Visit http://127.0.0.1:8000 in a fresh browser. Log out doesn't work (yet),
   so to reset, delete the file ``db.sqlite3`` and run ``python mange.py runserver`` again

Optionally, you can add other ``social`` plugins as well.


.. _Dataporten: https://docs.dataporten.no/
.. _social-auth-core: https://python-social-auth.readthedocs.io/en/latest/
.. _`dataporten's dashboard`: https://dashboard.dataporten.no/
.. _social's documentation: https://python-social-auth.readthedocs.io/en/latest/
.. _python-social-auth: https://pypi.python.org/pypi/python-social-auth
.. _`PSA's official migration document`: https://github.com/omab/python-social-auth/blob/master/MIGRATING_TO_SOCIAL.md



:Version: 2.0.0
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/UNINETT/python-dataporten-auth",
    "name": "python-dataporten-auth",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,oauth2",
    "author": "Hanne Moa",
    "author_email": "hanne.moa@uninett.no",
    "download_url": "https://files.pythonhosted.org/packages/6d/d1/d07d332826f071a43dc573fafee03104c4d02bbac6bbf53c1e1378c7ea12/python-dataporten-auth-2.0.0.tar.gz",
    "platform": "any",
    "description": "python-dataporten-auth\n======================\n\nDataporten_ is an authentication, authorization and API platform\nfor higher and lower education and research in Norway. Dataporten\noffers authentication of users to applications using OAuth 2.0 and\nthe OpenID Connect.\n\nDataporten-auth is a client for dataporten that depends on\nsocial-auth-core_.\n\nThis library is not compatible with the pre-refactor\npython-social-auth_, see any version prior to 2.0.x for that.\nFurthermore, this is now a Python 3 based project; No attempts\nhave been made to make it backwards compatible with Python 2.\n\nIf you are using the previous incarnation of ``python-dataporten-auth``:\n``dataporten-auth``, see `Upgrading from dataporten-auth`_.\n\n\nInstallation\n------------\n\nInstall with ``pip install python-dataporten-auth`` or by downloading the\nsource and running ``setup.py``.\n\n\n\nUsage\n-----\n\nSet up an application at Dataporten\n...................................\n\nThere needs to exist an entry for your site/app at dataporten. Log\nin to `dataporten's dashboard`_ and create an application. The\nentry needs one or more redirect uris.\n\nYou can have several redirect-uris, and you will be needing at\nleast one per plugin used.\n\nThe redirect uri is of the form ``<type>://<domainpath>/<suffix>/``,\nwhere ``<type>`` is one of ``http`` or ``https``, ``<domainpath>``\nis the domain name of your site and an optional path, and the\n``<suffix>`` is plugin-dependent. See the examples under\n**Plugins**.\n\nSet up your site\n................\n\nYou'll need to set the client id and client secret generated by\nDataporten in the settings of your app/site.\n\n\nBoth the name of the settings and the redirect uris depend on the\nplugins used. Add at least one of the plugins below.\n\nSee `social's documentation`_ for more.\n\nDjango\n......\n\nIn your ``settings.py``:\n\n* Add ``'social_django'`` to ``INSTALLED_APPS``.\n* Add one or more of the plugin names below to the start of\n  ``AUTHENTICATION_BACKENDS``. If you're also using user-models\n  \u00e0 la Django, ``'django.contrib.auth.backends.ModelBackend'``\n  must be in the same list, following the plugins.\n* Set ``SOCIAL_AUTH_DATAPORTEN_FEIDE_SSL_PROTOCOL`` to ``True`` to\n  use SSL. * ``SOCIAL_AUTH_LOGIN_REDIRECT_URL``,\n  ``SOCIAL_AUTH_NEW_USER_REDIRECT_URL`` and\n  ``SOCIAL_AUTH_REDIRECT_IS_HTTPS`` will have to be set depending\n  on the needs of your site.\n* If you use the Django admin, you might want to set\n  ``SOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS``, for instance to\n  ``['username', 'email']``.\n\nAlso see the settings in ``src\\demosite\\settings.py`` in the source.\n\nIn your site's ``urls.py``, include:\n\n``url(PREFIX, include('social_django.urls', namespace='social')),``\n\n... where PREFIX is a string to start off the urls with. Empty\nstring, ``''``, is fine.\n\nUpgrading from dataporten-auth\n------------------------------\n\nSee `PSA's official migration document`_, here follows a summary.\n\n1. Install ``python-social-auth`` version 0.2.21.\n2. Run migrations.\n3. Uninstall ``dataporten-auth``\n4. Install ``python-dataporten-auth``.\n5. Install ``social-auth-app-django``.\n6. In your ``urls.py`` rename ``'social.apps.django_app.urls'`` to  ``'social_django.urls'``.\n7. In your ``settings.py``, in this order:\n\n  1. Rename ``'social.apps.django_app.default'`` to ``'social_django'``.\n  2. Replace all mentions of ``'social.*'`` with ``'social_core.*'``.\n  3. Replace all mentions of ``psa`` with ``social``.\n\n8. Run migrations for ``social_django``.\n9. Uninstall ``python-social-auth``.\n\nPlugins\n-------\n\ndataporten.social.DataportenOAuth2\n..................................\n\nPlugin name\n    ``dataporten.social.DataportenOAuth2``\n\nSettings\n    Client id: ``SOCIAL_AUTH_DATAPORTEN_KEY``\n\n    Client secret: ``SOCIAL_AUTH_DATAPORTEN_SECRET``\n\nScopes needed\n    ``userid`` and ``profile``, this is the default.\n\nUsername generated:\n    Unique, alphanumeric string. You might want to let users\n    change this generated username. The plugin only cares that a\n    username exists and won't change the username back.\n\nRedirect-uri ends with\n    /complete/dataporten/\n\nExample redirect uri:\n    http://127.0.0.1/complete/dataporten/\n\ndataporten.social.DataportenEmailOAuth2\n.......................................\n\nPlugin name\n    ``dataporten.social.DataportenEmailOAuth2``\n\nSettings\n    Client id: ``SOCIAL_AUTH_DATAPORTEN_EMAIL_KEY``\n\n    Client secret: ``SOCIAL_AUTH_DATAPORTEN_EMAIL_SECRET``\n\nScopes needed\n    ``email``, this must be explicitly allowed in the dashboard.\n\nUsername generated:\n    From email-address\n\nRedirect-uri ends with\n    /complete/dataporten_email/\n\nExample redirect uri:\n    https://supersites.example.net/mysite/complete/dataporten_email/\n\ndataporten.social.DataportenFeideOAuth2\n.......................................\n\nPlugin name\n    ``dataporten.social.DataportenFeideOAuth2``\n\nSettings\n    Client id: ``SOCIAL_AUTH_DATAPORTEN_FEIDE_KEY``\n\n    Client secret: ``SOCIAL_AUTH_DATAPORTEN_FEIDE_SECRET``\n\nScopes needed\n    ``userid-feide``, this must be explicitly allowed in the dashboard.\n\nUsername generated:\n    From the Feide attribute ``eduPersonPrincipalName``, which looks\n    like an email address.\n\nRedirect-uri ends with\n    /complete/dataporten_feide/\n\nExample redirect uri:\n    https://example.com/cheatsheet/complete/dataporten_feide/\n\n\n\nDemo\n----\n\nThe Demo needs Django 1.8 or newer.\n\n1. Get the source code\n2. Install dependencies: ``pip install -r requirements/demo.txt``\n3. Make an application at dataporten\n4. Edit the settings-file to set ``SOCIAL_AUTH_DATAPORTEN_KEY`` and ``SOCIAL_AUTH_DATAPORTEN_SECRET``\n5. Set three redirect-uris, all starting with ``http://127.0.0.1:8000``\n6. Run ``python mange.py runserver``\n7. Visit http://127.0.0.1:8000 in a fresh browser. Log out doesn't work (yet),\n   so to reset, delete the file ``db.sqlite3`` and run ``python mange.py runserver`` again\n\nOptionally, you can add other ``social`` plugins as well.\n\n\n.. _Dataporten: https://docs.dataporten.no/\n.. _social-auth-core: https://python-social-auth.readthedocs.io/en/latest/\n.. _`dataporten's dashboard`: https://dashboard.dataporten.no/\n.. _social's documentation: https://python-social-auth.readthedocs.io/en/latest/\n.. _python-social-auth: https://pypi.python.org/pypi/python-social-auth\n.. _`PSA's official migration document`: https://github.com/omab/python-social-auth/blob/master/MIGRATING_TO_SOCIAL.md\n\n\n\n:Version: 2.0.0",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A plugin for python-social-auth to authenticate with dataporten",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/UNINETT/python-dataporten-auth"
    },
    "split_keywords": [
        "django",
        "oauth2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "344636d973cb02f8af6f248dd2ca06532459185cec14bcb69982280d0fb711a5",
                "md5": "7b5d350ced91eaed8098edb4a47e7b7d",
                "sha256": "fff2e6416a7fc924fd58d1c682dced0bac4c86be3ab35727a4d75c2a1a036ee7"
            },
            "downloads": -1,
            "filename": "python_dataporten_auth-2.0.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7b5d350ced91eaed8098edb4a47e7b7d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 8625,
            "upload_time": "2017-06-19T10:37:41",
            "upload_time_iso_8601": "2017-06-19T10:37:41.311376Z",
            "url": "https://files.pythonhosted.org/packages/34/46/36d973cb02f8af6f248dd2ca06532459185cec14bcb69982280d0fb711a5/python_dataporten_auth-2.0.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6dd1d07d332826f071a43dc573fafee03104c4d02bbac6bbf53c1e1378c7ea12",
                "md5": "330d327984e1ce7a78a05233583476a6",
                "sha256": "2a4d9651ac008195133480e83e895d888bc1f9a68abc118601d21c41f8f90e73"
            },
            "downloads": -1,
            "filename": "python-dataporten-auth-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "330d327984e1ce7a78a05233583476a6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6223,
            "upload_time": "2017-06-19T10:37:43",
            "upload_time_iso_8601": "2017-06-19T10:37:43.510572Z",
            "url": "https://files.pythonhosted.org/packages/6d/d1/d07d332826f071a43dc573fafee03104c4d02bbac6bbf53c1e1378c7ea12/python-dataporten-auth-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2017-06-19 10:37:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "UNINETT",
    "github_project": "python-dataporten-auth",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "python-dataporten-auth"
}
        
Elapsed time: 0.62733s