Skip to main content

SAML 2.0 IdP and SP for Flask and Python 3

Project description

https://travis-ci.com/timheap/flask-saml2.svg?branch=master https://badge.fury.io/py/flask-saml2.svg https://readthedocs.org/projects/flask-saml2/badge/?version=latest

This Flask plugin provides functionality for creating both SAML Service Providers and Identity Providers. Applications can implement one or both of these providers.

flask-saml2 works with Flask 1.0+ and Python 3.6+.

This is a heavily modified fork of NoodleMarkets/dj-saml-idp which in turn is a fork of deforestg/dj-saml-idp which in turn is a fork of novapost/django-saml2-idp.

Terminology

For a full description of how SAML works, please seek guides elsewhere on the internet. For a quick introduction, and a run through of some of the terminology used in this package, read on.

The SAML protocal is a conversation between two parties: Identity Providers (IdP) and Service Providers (SP). When an unauthenticated client (usually a browser) accesses a Service Provider, the Service Provider will make an authentication request (AuthnRequest), sign it using its private key, and then forward this request via the client to the Identity Provider. Once the client logs in at the central Identity Provider, the Identity Provider makes a response, signs it, and forwards this response via the client to the requesting Service Provider. The client is then authenticated on the Service Provider via the central Identity Provider, without the Service Provider having to know anything about the authentication method, or any passwords involved.

Example implementations

A minimal but functional example implementation of both a Service Provider and an Identity Provider can be found in the examples/ directory of this repository. To get the examples running, first clone the repository and install the dependencies:

$ git clone https://github.com/timheap/flask-saml2
$ cd flask-saml2
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -e .
$ pip install -r tests/requirements.txt

Next, run the IdP and the SP in separate terminal windows:

$ cd flask-saml2
$ source venv/bin/activate
$ ./examples/idp.py
$ cd flask-saml2
$ source venv/bin/activate
$ ./examples/sp.py

Finally, navigate to http://localhost:9000/ to access the Service Provider landing page.

Testing

The test runner is pytest and we are using tox to run tests against different versions of Flask and Python. The test can be run locally using tox directly (preferably in a virtual environment):

$ pip install tox
$ tox

License

Distributed under the MIT License.

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

flask-saml2-fork-0.3.1.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_saml2_fork-0.3.1-py2.py3-none-any.whl (40.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file flask-saml2-fork-0.3.1.tar.gz.

File metadata

  • Download URL: flask-saml2-fork-0.3.1.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for flask-saml2-fork-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2d4a2522ee1dfa6d7c08145d1b64966d85430ca5254bb11cc2f3893fcb2cf676
MD5 db4f9411303d191c1afe47e03b5b8994
BLAKE2b-256 3af5cabeceda450041c7f07ad336471b43eee8cb669a80776b618cbd9880f9f7

See more details on using hashes here.

File details

Details for the file flask_saml2_fork-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: flask_saml2_fork-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for flask_saml2_fork-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 04fa7e8b02a2e86561b288c792592683bdb7e38e8b90223b0bf04317158f53fa
MD5 35f9cd8c58f112da617429866bcf70e6
BLAKE2b-256 0418d9fe71643ef787858c316bcaa3f6db9448417425bc4e3f0406610007e8d2

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 Pingdom Monitoring Sentry Error logging StatusPage Status page