Skip to main content

Discourse Single-Sign-on (DSSO) provider client to connect your Django project to a Discourse Single-Sign-On provider server.

See: https://meta.discourse.org/t/official-single-sign-on-for-discourse-sso/

Example usage:

  • Add kleides_dssoclient to INSTALLED_APPS.

  • Create a custom DssoLoginBackend, for example:

    from kleides_dssoclient.backends import DssoLoginBackend
    
    class MyProjectDssoLoginBackend(DssoLoginBackend):
        """
        DssoLoginBackend that rejects anyone without is_superuser, and that
        sets all mapped variables on the newly created User object.
        """
        def authenticate(self, dsso_mapping):
            """
            Check that user is a superuser and pass along to DssoLoginBackend.
            """
            if dsso_mapping.get('is_superuser') not in ('True', 'true', '1'):
                return None
    
            return super(MyProjectDssoLoginBackend, self).authenticate(
                dsso_mapping)
    
        def configure_user(self, user, dsso_mapping):
            """
            We expect username, email, is_superuser in the dsso_mapping.
            """
            user = (
                super(MyProjectDssoLoginBackend, self)
                .configure_user(user, dsso_mapping))
    
            user.email = dsso_mapping.get('email', '')
            is_superuser = (
                dsso_mapping.get('is_superuser') in ('True', 'true', '1'))
            user.is_staff = is_superuser
            user.is_superuser = is_superuser
    
            user.save()
            return user
  • Add this to the Django settings:

    AUTHENTICATION_BACKENDS = (  # the only backend needed
        'myproject.backends.MyProjectDssoLoginBackend',
    )
    MIDDLEWARE_CLASSES += (
        'kleides_dssoclient.middleware.DssoLoginMiddleware',
    )
    KLEIDES_DSSO_ENDPOINT = 'https://DSSOSERVER/sso/'
    KLEIDES_DSSO_SHARED_KEY = 'oh-sso-very-very-secret'
    KLEIDES_DSSO_CREATE_UNKNOWN_USER = True

Changes

v0.9 - 2024-06-13

  • Add setting for automatic user creation.

  • Remove dsso parameters from the return url.

v0.8 - 2020-09-28

  • Allow using the Dsso backend as a mixin.

v0.7 - 2019-07-16

  • Allow bypassing the middleware by setting KLEIDES_DSSO_ENDPOINT to None.

v0.6 - 2019-03-06

  • Add request arg to DssoLoginBackend for Django 2.1.

v0.5 - 2019-03-06

  • Add logging to help investigate problems.

v0.3 - 2018-12-18

  • Add support for Django 1.10 style middleware.

  • Check Django version for is_authenticated usage.

v0.2 - 2018-11-19

  • Replace sso_mapping with dsso_mapping in authenticate argument list.

v0.1 - 2018-11-16

  • Initial release.

Metadata

Release files for kleides-dssoclient 0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kleides-dssoclient 0.9
File Size Uploaded
kleides_dssoclient-0.9.tar.gz 20.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kleides-dssoclient 0.9
File Interpreter ABI Platform
kleides_dssoclient-0.9-py3-none-any.whl Python 3 none any Details

Total release size: 55.0 kB

Release files / kleides_dssoclient-0.9.tar.gz

Download URL kleides_dssoclient-0.9.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5dd8d1d6f49d0a3c16ff52a8823b65c05600672ca4d13cc050863836ac0d3ea1
BLAKE2b-256 checksum
How to use checksums
4330a69f7c1e4efaa84b26eb75d14c29fe6234bc120938e3850becb1fc3d29cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release files / kleides_dssoclient-0.9-py3-none-any.whl

Download URL kleides_dssoclient-0.9-py3-none-any.whl
Size 34.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e5bdd6849d9399cef4243d93c406b53a7edc74d0768f3a3b12128e2ffbde393
BLAKE2b-256 checksum
How to use checksums
9c3f33d699a01c3999a417fdb11d78c6f065d075487b0c7e3dec5bb866892f18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.9 This release

2 release files

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page