Giter Site home page Giter Site logo

vsumner / django-saml-service-provider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kristianoellegaard/django-saml-service-provider

0.0 0.0 0.0 148 KB

Easily let users sign in via SAML 2.0 to your django app. Based on python-saml

Python 100.00%

django-saml-service-provider's Introduction

django-saml-service-provider

Easily let users sign in via SAML 2.0 to your django app. Based on python-saml and comes with a Onelogin.com provider, so you need to do very little work to get started.

Get started

You need to extend the three default views provided by this library and use your own settings. It can be done easily with a single mixin. Consider the following simple example, using the Onelogin provider. You can also do the same with the regular SAMLServiceProvider - you just need to provide all the urls manually.

class SettingsMixin(object):
    def get_onelogin_settings(self):
        return OneloginServiceProviderSettings(
            onelogin_connector_id=1234,
            onelogin_x509_cert="""-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----""",

            sp_metadata_url="http://localhost:8000%s" % reverse("saml_metadata"),
            sp_login_url="http://localhost:8000%s" % reverse("saml_login_complete"),
            sp_logout_url="http://localhost:8000%s" % reverse("logout"),

            debug=settings.DEBUG,
            strict=not settings.DEBUG,

            sp_x509cert="""-----BEGIN CERTIFICATE-----
        -----END CERTIFICATE-----""",
            sp_private_key="""-----BEGIN RSA PRIVATE KEY-----
        -----END RSA PRIVATE KEY-----"""
            ).settings
            
class LoginView(SettingsMixin, InitiateAuthenticationView):
    pass
    
class Authenticateview(SettingsMixin, CompleteAuthenticationView):
    pass
    
class XMLMetadataView(SettingsMixin, MetadataView):
    pass

Django authentication backend

This project conveniently ships with an authentication backend - just add it to AUTHENTICATION_BACKENDS in settings and you're good to go - e.g.:

AUTHENTICATION_BACKENDS = (
    # 'django.contrib.auth.backends.ModelBackend',
    'saml_service_provider.auth_backend.SAMLServiceProviderBackend',
)

django-saml-service-provider's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.