
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
python-dataporten-auth
Advanced tools
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
_.
Install with pip install python-dataporten-auth
or by downloading the
source and running setup.py
.
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
:
'social_django'
to INSTALLED_APPS
.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.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.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.
See PSA's official migration document
_, here follows a summary.
Install python-social-auth
version 0.2.21.
Run migrations.
Uninstall dataporten-auth
Install python-dataporten-auth
.
Install social-auth-app-django
.
In your urls.py
rename 'social.apps.django_app.urls'
to 'social_django.urls'
.
In your settings.py
, in this order:
Rename 'social.apps.django_app.default'
to 'social_django'
.
Replace all mentions of 'social.*'
with 'social_core.*'
.
Replace all mentions of psa
with social
.
Run migrations for social_django
.
Uninstall python-social-auth
.
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/
The Demo needs Django 1.8 or newer.
pip install -r requirements/demo.txt
SOCIAL_AUTH_DATAPORTEN_KEY
and SOCIAL_AUTH_DATAPORTEN_SECRET
http://127.0.0.1:8000
python mange.py runserver
db.sqlite3
and run python mange.py runserver
againOptionally, 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
FAQs
A plugin for python-social-auth to authenticate with dataporten
We found that python-dataporten-auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.