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, sso_mapping):
            """
            Check that user is a superuser and pass along to DssoLoginBackend.
            """
            if sso_mapping.get('is_superuser') not in ('True', 'true', '1'):
                return None
    
            return super(MyProjectDssoLoginBackend, self).authenticate(
                sso_mapping)
    
        def configure_user(self, user, sso_mapping):
            """
            We expect username, email, is_superuser in the sso_mapping.
            """
            user = (
                super(MyProjectDssoLoginBackend, self)
                .configure_user(user, sso_mapping))
    
            user.email = sso_mapping.get('email', '')
            is_superuser = (
                sso_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_DSSOCLIENT_ENDPOINT = 'https://SSO_SERVER/sso/'
    KLEIDES_DSSOCLIENT_SHARED_KEY = 'oh-sso-very-very-secret'

Changes

v0.1 - 2018-11-16

  • Initial release.

Download files

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

Source Distribution

kleides_dssoclient-0.1.tar.gz (18.9 kB view details)

Uploaded Source

File details

Details for the file kleides_dssoclient-0.1.tar.gz.

File metadata

  • Download URL: kleides_dssoclient-0.1.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/37.0.0 requests-toolbelt/0.8.0 tqdm/4.19.4 CPython/2.7.12

File hashes

Hashes for kleides_dssoclient-0.1.tar.gz
Algorithm Hash digest
SHA256 2693bbbcdf03b1195e0affb806c0c6b342998ba494c03df1c56ecb3fc22db36a
MD5 548b09cbd9a5770b123a718b1c0a5861
BLAKE2b-256 655db6aff478d56a4736ec088e798f706c0ab88d534386ce4ceba1a6774391b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page