Package: python-dataporten-auth
Dataportenis 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 onsocial-auth-core.This library is not compatible with the pre-refactorpython-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 ofpython-dataporten-auth:dataporten-auth, seeUpgrading from dataporten-auth.InstallationInstall withpip installpython-dataporten-author by downloading the
source and runningsetup.py.UsageSet up an application at DataportenThere needs to exist an entry for your site/app at dataporten. Log
in todataporten’s dashboardand 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 ofhttporhttps,<domainpath>is the domain name of your site and an optional path, and the<suffix>is plugin-dependent. See the examples underPlugins.Set up your siteYou’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.Seesocial’s documentationfor more.DjangoIn yoursettings.py:Add'social_django'toINSTALLED_APPS.Add one or more of the plugin names below to the start ofAUTHENTICATION_BACKENDS. If you’re also using user-models
à la Django,'django.contrib.auth.backends.ModelBackend'must be in the same list, following the plugins.SetSOCIAL_AUTH_DATAPORTEN_FEIDE_SSL_PROTOCOLtoTrueto
use SSL. *SOCIAL_AUTH_LOGIN_REDIRECT_URL,SOCIAL_AUTH_NEW_USER_REDIRECT_URLandSOCIAL_AUTH_REDIRECT_IS_HTTPSwill have to be set depending
on the needs of your site.If you use the Django admin, you might want to setSOCIAL_AUTH_ADMIN_USER_SEARCH_FIELDS, for instance to['username', 'email'].Also see the settings insrc\demosite\settings.pyin the source.In your site’surls.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-authSeePSA’s official migration document, here follows a summary.Installpython-social-authversion 0.2.21.Run migrations.Uninstalldataporten-authInstallpython-dataporten-auth.Installsocial-auth-app-django.In yoururls.pyrename'social.apps.django_app.urls'to'social_django.urls'.In yoursettings.py, in this order:Rename'social.apps.django_app.default'to'social_django'.Replace all mentions of'social.*'with'social_core.*'.Replace all mentions ofpsawithsocial.Run migrations forsocial_django.Uninstallpython-social-auth.Pluginsdataporten.social.DataportenOAuth2Plugin namedataporten.social.DataportenOAuth2SettingsClient id:SOCIAL_AUTH_DATAPORTEN_KEYClient secret:SOCIAL_AUTH_DATAPORTEN_SECRETScopes neededuseridandprofile, 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.DataportenEmailOAuth2Plugin namedataporten.social.DataportenEmailOAuth2SettingsClient id:SOCIAL_AUTH_DATAPORTEN_EMAIL_KEYClient secret:SOCIAL_AUTH_DATAPORTEN_EMAIL_SECRETScopes neededemail, this must be explicitly allowed in the dashboard.Username generated:From email-addressRedirect-uri ends with/complete/dataporten_email/Example redirect uri:https://supersites.example.net/mysite/complete/dataporten_email/dataporten.social.DataportenFeideOAuth2Plugin namedataporten.social.DataportenFeideOAuth2SettingsClient id:SOCIAL_AUTH_DATAPORTEN_FEIDE_KEYClient secret:SOCIAL_AUTH_DATAPORTEN_FEIDE_SECRETScopes neededuserid-feide, this must be explicitly allowed in the dashboard.Username generated:From the Feide attributeeduPersonPrincipalName, which looks
like an email address.Redirect-uri ends with/complete/dataporten_feide/Example redirect uri:https://example.com/cheatsheet/complete/dataporten_feide/DemoThe Demo needs Django 1.8 or newer.Get the source codeInstall dependencies:pip install-rrequirements/demo.txtMake an application at dataportenEdit the settings-file to setSOCIAL_AUTH_DATAPORTEN_KEYandSOCIAL_AUTH_DATAPORTEN_SECRETSet three redirect-uris, all starting withhttp://127.0.0.1:8000Runpython mange.py runserverVisithttp://127.0.0.1:8000in a fresh browser. Log out doesn’t work (yet),
so to reset, delete the filedb.sqlite3and runpython mange.py runserveragainOptionally, you can add othersocialplugins as well.Version:2.0.0