You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.1 KiB


This is an example SAML SP service written using Flask and pysaml2.


You will also need a development environment capable of compiling Python packages and the "libffi" and "libxmlsec1" development libraries, which are needed by PySAML2.

Instructions for installing these development libraries will differ depending on your host operating system.

Mac OS X

$ brew install libffi libxmlsec1


$ sudo yum install libffi-devel xmlsec1 xmlsec1-openssl


$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements.txt 


$ python 


The fastest way to test this example SAML SP is to use the service.

Here is how:

  1. Edit the "" file and uncomment the line in the "test" line in "metadata_url_for" dictionary.

    $ $EDITOR

    Change this line:

    # 'test': '',                                                                                                

    To this:

    'test': '',
  2. Start the example SAML SP

    $ python
  3. Start ngrok on the port that the example SAML SP is running on. By default, the example SAML SP runs on TCP 5000.

    $ ngrok http 5000

    You will need to install ngrok if you haven't already.

    Here is what it should look like:


  4. Run to test this example SAML SP

Testing the security of your SAML SP

After successfully completing the steps in the "Testing" section above, select the "Run security validation" option to have run an extended series of security tests against your SAML SP.


Updates or corrections to this document are very welcome. Feel free to send pull requests with suggestions.

Additionally, comments or questions can be sent to: