15

I am looking for a Python library which can be used to implement SAML2 based service provider and identity provider. The core library should not depend on any particular web-framework. I am looking for something which is more feature complete and preferably easy to use. Also the library should have more permissive license (non-GPL). After searching I found few links, I have pasted it here:

http://wiki.python.org/moin/SAML

Any suggestion ?

baijum
  • 1,609
  • 2
  • 20
  • 25

2 Answers2

16

You can also take a look on https://github.com/onelogin/python-saml

Is also open source and the toolkit contains 2 demos: A django application and a Flask application.

Right now only works on Python 2.X

Edited 13/05/2015: There is a python 3.X version (beta, I'm still testing it): https://github.com/pitbulk/python3-saml (thanks bgaifullin for contributing it)

Edited 13/04/2016: Python 3.X version is stable and tested.

AbdealiLoKo
  • 3,261
  • 2
  • 20
  • 36
smartin
  • 2,957
  • 2
  • 23
  • 33
  • 2
    I'd recommend accepting this answer, as the onelogin.com solution appears to be the current "best" solution available as of this writing ... – Sam Rose Sep 29 '16 at 13:42
  • 1
    Can Onelogin's python-saml be used as IDP ? – Mukesh Yadav Mar 04 '17 at 11:28
  • 1
    As the general description section of the toolkit says: "OneLogin's SAML Python toolkit lets you turn your Python application into a SP (Service Provider) that can connect to an IdP (Identity Provider)." so no, only works as SP. – smartin Mar 06 '17 at 19:45
  • Does it support the IdP-initiated flow where the SP (our app) receives the samlp:Response from the IdP directly as a first interaction? – Simeon Leyzerzon Apr 10 '18 at 00:01
  • @SimeonLeyzerzon Yes. – smartin May 30 '18 at 11:35
  • OneLogin has [an official Python3-supporting project](https://github.com/onelogin/python3-saml) now. – Xiong Chiamiov Aug 08 '19 at 17:26
12

The pysaml2 project at launchpad is pretty active now. I think that you were sprinting on it at PyCon 2011. The pysaml2 package is included in Python package index (PyPi) and installable with easy_install / pip. The docs can be found at: https://pypi.python.org/pypi/pysaml2

There is a related project for Django which can be found at PyPi: djangosaml2

The other project, python-saml2 on google code, seems to be a bit older and not so active.

I don't have any experience with the other ones.

I found another one: https://github.com/tachang/PySAML

The abbreviations pysaml2, PySAML and python-saml2, which refer to three different projects, are a bit confusing.

Update: 2020 Sep 29 (on behalf of @Umognog, thx)

Update: 2019 Apr 27 - Current status of the projects:

  • PySAML - Not updated since 2009.
  • pysaml2 - Is Python3 compatible and taken under the https://idpy.org/ project
  • python-saml2 - Does not seem to exist on pypi. No references found
erny
  • 1,296
  • 1
  • 13
  • 28