Skip to main content

Plugin OIDC (OpenID Connect) into Django CMS.

Project description

Build Status Coverage Pypi package status Python versions license

DjangoCMS OIDC (OpenID Connect)

Plugins for user authentication via OpenID, based on Mozilla Django OIDC.

Installation

$ pip install djangocms-oidc

Caution! If you are using project django-python3-ldap, you must use version higher than 0.11.3.

Example in requirements.txt:

django-python3-ldap @ git+https://github.com/etianen/django-python3-ldap.git@759d3483d9e656fef2b6a2e669101bca3021d9d5

Add settings to settings.py

Start by making the following changes to your settings.py file.

# Add 'mozilla_django_oidc' and 'djangocms_oidc' to INSTALLED_APPS
INSTALLED_APPS = [
    # ...
    'multiselectfield',
    'django_countries',
    'mozilla_django_oidc',  # place after auth (django.contrib.auth)
    'djangocms_oidc',
]

AUTHENTICATION_BACKENDS = [
    # ...
    'djangocms_oidc.auth.DjangocmsOIDCAuthenticationBackend',
]

MIDDLEWARE = [
    # ...
    'djangocms_oidc.middleware.OIDCSessionRefresh',
]

# Define OIDC classes
OIDC_AUTHENTICATE_CLASS = "djangocms_oidc.views.DjangocmsOIDCAuthenticationRequestView"
OIDC_CALLBACK_CLASS = "djangocms_oidc.views.DjangocmsOIDCAuthenticationCallbackView"
OIDC_OP_AUTHORIZATION_ENDPOINT = "https://example.com/authorization-endpoint"
OIDC_RP_CLIENT_ID = "myClientId"

Add OIDC urls to urls.py

Modify your project urls.py file.

urlpatterns = [
    # ....
    path('oidc/', include('mozilla_django_oidc.urls')),
    path('djangocms-oidc/', include('djangocms_oidc.urls')),
]

Settings

Most settings are the same as the project Mozilla Django OIDC.

The following values are defined in the plugins. It is therefore not necessary to set them in the project settings. They have no effect.

  • OIDC_RP_CLIENT_ID

  • OIDC_RP_CLIENT_SECRET

  • OIDC_OP_AUTHORIZATION_ENDPOINT

  • OIDC_OP_TOKEN_ENDPOINT

  • OIDC_OP_USER_ENDPOINT

The OIDC_RP_SCOPES parameter behaves differently from the parameter in mozilla-django-oidc due to overloaded function verify_claims. The parameter contains a string of claim names. If at least one of them is present in the response from the provider, the handover of the data is verified. Default value of parameter is 'openid2_id openid email'. One of these data must be handovered, otherwise the response from the provider is dismissed.

Usage in administration

These plugins are available to the editor in the administration:

  • OIDC Handover data

  • OIDC Login

  • OIDC List identifiers

  • OIDC Display dedicated content

  • OIDC Show attribute

  • OIDC Show attribute Country

How to use provider MojeID

Home › Djangocms_Oidc › Oidc register consumers › oidc register consumer: Add

Name: MojeID Test

Home › Djangocms_Oidc › Oidc providers › oidc provider: add

Name: MojeID Test
Code: mojeid
Register consumer: MojeID Test

Page structure: Add

OpenID Connect: OIDC Handover data
Provider: MojeID Test
Claims: {…} (copy from the example below) For mojeid see list “claims_supported” in .well-known openid-configuration.
Verified by names: … (copy from the example below)

How to run an example

Run the example in Docker. Install as follows:

$ git clone https://github.com/CZ-NIC/djangocms-oidc-form-fields.git
$ cd djangocms-oidc-form-fields/example
$ docker-compose build web
$ docker-compose run --user $(id -u):$(id -g) web python manage.py migrate
$ docker-compose run --user $(id -u):$(id -g) web python manage.py loaddata site.json

Start the webserver:

$ docker-compose up -d

Open in your browser: http://localhost:8000/. To log in to the administrations use admin:password at http://localhost:8000/admin.

Stop the webserver:

$ docker-compose down

License

This software is licensed under the GNU GPL license. For more info check the LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangocms_oidc-4.2.0.tar.gz (60.6 kB view details)

Uploaded Source

Built Distribution

djangocms_oidc-4.2.0-py3-none-any.whl (75.7 kB view details)

Uploaded Python 3

File details

Details for the file djangocms_oidc-4.2.0.tar.gz.

File metadata

  • Download URL: djangocms_oidc-4.2.0.tar.gz
  • Upload date:
  • Size: 60.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for djangocms_oidc-4.2.0.tar.gz
Algorithm Hash digest
SHA256 fa8809e8be6d7a9f097616d807949905d2559a4a45f1c7ae45f8d09842715393
MD5 6d1693437882ed400ef7926d965c1ac1
BLAKE2b-256 e69a30d91a8cdaad260e7e0039d6c077a269728ecef3d3b406999bc700fcaf07

See more details on using hashes here.

File details

Details for the file djangocms_oidc-4.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for djangocms_oidc-4.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79cf13a14465e8ef5310a40d296f65b1d46266d64a3e6bef326c24a2d0598d18
MD5 1fc3f72885964f3b73b7f19143307f67
BLAKE2b-256 d232b6ec9589d5c49e6eb328d878f72230824627661c7be0d0aeb0e00a28eb87

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page