summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2018-07-04 11:25:27 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2018-07-04 11:25:27 +0300
commit2a5a6ee47b9db3a37ee6eda6eb3c40af076760e5 (patch)
tree196635c26886060c07aa58c919cd54da75a7b9da /docs
parent1909ad49b6679d50ece19ed901d304bb17d249c6 (diff)
downloadpysaml2-2a5a6ee47b9db3a37ee6eda6eb3c40af076760e5.tar.gz
Move documentation from directory doc to docs
Diffstat (limited to 'docs')
-rw-r--r--docs/Makefile153
-rw-r--r--docs/_static/ViewmeonGitHub.pngbin0 -> 6160 bytes
-rw-r--r--docs/conf.py202
-rw-r--r--docs/examples/idp.rst38
-rw-r--r--docs/examples/index.rst18
-rw-r--r--docs/examples/sp.rst229
-rw-r--r--docs/howto/config.rst834
-rw-r--r--docs/howto/index.rst40
-rw-r--r--docs/index.rst64
-rw-r--r--docs/install.rst57
-rw-r--r--docs/make.bat112
-rwxr-xr-xdocs/make.sh5
-rw-r--r--docs/sp_test/internal.rst149
13 files changed, 1901 insertions, 0 deletions
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 00000000..462e0de6
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,153 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/SAML2test.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/SAML2test.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/SAML2test"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/SAML2test"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/_static/ViewmeonGitHub.png b/docs/_static/ViewmeonGitHub.png
new file mode 100644
index 00000000..44da44c9
--- /dev/null
+++ b/docs/_static/ViewmeonGitHub.png
Binary files differ
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 00000000..6bb2bb81
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,202 @@
+# -*- coding: utf-8 -*-
+#
+# pysaml2 documentation build configuration file, created by
+# sphinx-quickstart on Mon Aug 24 08:13:41 2009.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+import alabaster
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.coverage']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'pysaml2'
+copyright = u'2010-2011, Roland Hedberg'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = ''
+# The full version, including alpha/beta/rc tags.
+release = ''
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme_path = [alabaster.get_path()]
+html_theme = 'alabaster'
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if on_rtd: # only import and set the theme if we're building docs locally
+ html_theme = 'sphinx_rtd_theme'
+
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'pysaml2doc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'pysaml2.tex', u'pysaml2 Documentation',
+ u'Roland Hedberg', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True
diff --git a/docs/examples/idp.rst b/docs/examples/idp.rst
new file mode 100644
index 00000000..fcb636a6
--- /dev/null
+++ b/docs/examples/idp.rst
@@ -0,0 +1,38 @@
+.. _example_idp:
+
+An extremly simple example of a SAML2 identity provider.
+========================================================
+
+There are 2 example IDPs in the project's example directory:
+* idp2 has a static definition of users:
+ * user attributes are defined in idp_user.py
+ * the password is defined in the PASSWD dict in idp.py
+* idp2_repoze is using repoze.who middleware to perform authentication and attribute retrieval
+
+Configuration
+-------------
+Entity configuration is described in "Configuration of pysaml2 entities"
+Server parameters like host and port and various command line parameters are
+defined in the main part of idp.py
+
+Setup:
+******
+
+The folder [your path]/pysaml2/example/idp2 contains a file named idp_conf.py.example
+
+Take the file named idp_conf.py.example and rename it idp_conf.py
+
+Generate a metadata file based in the configuration file (idp_conf.py) by using the command::
+
+ make_metadata.py idp_conf.py > idp.xml
+
+
+Run IDP:
+********
+
+Open a Terminal::
+
+ cd [your path]/pysaml2/example/idp2
+ python idp.py idp_conf
+
+Note that you should not have the .py extension on the idp_conf.py while running the program
diff --git a/docs/examples/index.rst b/docs/examples/index.rst
new file mode 100644
index 00000000..19c26a40
--- /dev/null
+++ b/docs/examples/index.rst
@@ -0,0 +1,18 @@
+.. _example_index:
+
+Quick pysaml2 example
+=====================
+
+:Release: |version|
+:Date: |today|
+
+In order to confirm that pysaml2 has been installed correctly and are ready to use you could run this basic example
+
+Contents:
+
+.. toctree::
+ :maxdepth: 1
+
+ sp
+ idp
+
diff --git a/docs/examples/sp.rst b/docs/examples/sp.rst
new file mode 100644
index 00000000..7d392257
--- /dev/null
+++ b/docs/examples/sp.rst
@@ -0,0 +1,229 @@
+.. _example_sp:
+
+An extremely simple example of a SAML2 service provider.
+=======================================================
+
+How it works
+************
+
+A SP works with authentication and possibly attribute aggregation.
+Both of these functions can be seen as parts of the normal Repoze.who
+setup. Namely the Challenger, Identifier and MetadataProvider parts.
+
+Normal for Repoze.who Identifier and MetadataProvider plugins are that
+they place information in environment variables. The convention is to place
+identity information in environ["repoze.who.identity"].
+This is a dictionary with keys like 'login', and 'repoze.who.userid'.
+
+The SP follows this pattern and places the information gathered from
+the IdP that handled the authentication and possible extra information
+received from attribute authorities in the above mentioned dictionary under
+the key 'user'.
+
+So in environ["repoze.who.identity"] you will find a dictionary with
+attributes and values, the attribute names used depends on what's returned
+from the IdP/AA. If there exists both a name and a friendly name, for
+instance, the friendly name is used as the key.
+
+Setup
+*****
+
+**sp-wsgi:**
+
+* Go to the folder and copy the example files::
+
+ cd [your path]/pysaml2/example/sp-wsgi
+ cp service_conf.py.example service_conf.py
+ cp sp_conf.py.example sp_conf.py
+
+sp_conf.py is configured to run on localhost on port 8087. If you want to you could make the necessary changes before proceeding to the next step.
+
+* In order to generate the metadata file open a terminal::
+
+ cd [your path]/pysaml2/example/sp-wsgi
+ make_metadata.py sp_conf.py > sp.xml
+
+
+**sp-repoze:**
+
+* Go to the folder:
+[your path]/pysaml2/example/sp-repoze
+
+* Take the file named sp_conf.py.example and rename it sp_conf.py
+
+sp_conf.py is configured to run on localhost on port 8087. If you want to you could make the necessary changes before proceeding to the next step.
+
+* In order to generate the metadata file open a terminal::
+
+ cd [your path]/pysaml2/example/sp-repoze
+ make_metadata.py sp_conf.py > sp.xml
+
+Important files:
+
+sp_conf.py
+ The SPs configuration
+
+who.ini
+ The repoze.who configuration file
+
+Inside the folder named pki there are two files with certificates, mykey.pem with the private
+certificate and mycert.pem with the public part.
+
+I'll go through these step by step.
+
+sp_conf.py
+----------
+
+The configuration is written as described in :ref:`howto_config`. It means among other
+things that it's easily testable as to the correct syntax.
+
+You can see the whole file in example/sp/sp_conf.py, here I will go through
+it line by line::
+
+ "service": ["sp"],
+
+Tells the software what type of services the software is supposed to
+supply. It is used to check for the
+completeness of the configuration and also when constructing metadata from
+the configuration. More about that later. Allowed values are: "sp"
+(service provider), "idp" (identity provider) and "aa" (attribute authority).
+::
+
+ "entityid" : "urn:mace:example.com:saml:sp",
+ "service_url" : "http://example.com:8087/",
+
+The ID of the entity and the URL on which it is listening.::
+
+ "idp_url" : "https://example.com/saml2/idp/SSOService.php",
+
+Since this is a very simple SP it only needs to know about one IdP, therefore there
+is really no need for a metadata file or a WAYF-function or anything like that.
+It needs the URL of the IdP and that's all.::
+
+ "my_name" : "My first SP",
+
+This is just for informal purposes, not really needed but nice to do::
+
+ "debug" : 1,
+
+Well, at this point in time you'd really like to have as much information
+as possible as to what's going on, right ? ::
+
+ "key_file" : "./mykey.pem",
+ "cert_file" : "./mycert.pem",
+
+The necessary certificates.::
+
+ "xmlsec_binary" : "/opt/local/bin/xmlsec1",
+
+Right now the software is built to use xmlsec binaries and not the python
+xmlsec package. There are reasons for this but I won't go into them here.::
+
+ "organization": {
+ "name": "Example Co",
+ #display_name
+ "url":"http://www.example.com/",
+ },
+
+Information about the organization that is behind this SP, only used when
+building metadata. ::
+
+ "contact": [{
+ "given_name":"John",
+ "sur_name": "Smith",
+ "email_address": "john.smith@example.com",
+ #contact_type
+ #company
+ #telephone_number
+ }]
+
+Another piece of information that only matters if you build and distribute
+metadata.
+
+So, now to that part. In order to allow the IdP to talk to you, you may have
+to provide the one running the IdP with a metadata file.
+If you have a SP configuration file similar to the one I've walked you
+through here, but with your information, you can make the metadata file
+by running the make_metadata script you can find in the tools directory.
+
+Change directory to where you have the configuration file and do ::
+
+ make_metadata.py sp_conf.py > metadata.xml
+
+
+
+who.ini
+-------
+The file named ``who.ini`` is the ``sp-repoze`` folder
+
+I'm not going through the INI file format here. You should read
+`Middleware Responsibilities <http://docs.repoze.org/who/2.0/middleware.html>`_
+to get a good introduction to the concept.
+
+The configuration of the pysaml2 part in the applications middleware are
+first the special module configuration, namely::
+
+ [plugin:saml2auth]
+ use = s2repoze.plugins.sp:make_plugin
+ saml_conf = sp_conf.py
+ rememberer_name = auth_tkt
+ debug = 1
+ path_logout = .*/logout.*
+
+Which contains a specification ("use") of which function in which module
+should be used to initialize the part. After that comes the name of the
+file ("saml_conf") that contains the PySaml2 configuration. The third line
+("rememberer_name") points at the plugin that should be used to
+remember the user information.
+
+After this, the plugin is referenced in a couple of places::
+
+ [identifiers]
+ plugins =
+ saml2auth
+ auth_tkt
+
+ [authenticators]
+ plugins = saml2auth
+
+ [challengers]
+ plugins = saml2auth
+
+ [mdproviders]
+ plugins = saml2auth
+
+Which means that the plugin is used in all phases.
+
+Run SP:
+*******
+
+Open a Terminal::
+
+ cd [your path]/pysaml2/example/sp-wsgi
+ python sp.py sp_conf
+
+Note that you should not have the .py extension on the sp_conf.py while running the program
+
+Now you should be able to open a web browser and go to to service provider (if you didn't change sp_conf.py it should be: http://localhost:8087)
+
+You should be redirected to the IDP and presented with a login screen.
+
+You could enter Username:roland and Password:dianakra
+All users are specified in idp.py in a dictionary named PASSWD
+
+The application
+---------------
+
+The app is, as said before, extremely simple. The only thing that is connected to
+the PySaml2 configuration is at the bottom, namely where the server is.
+You have to ascertain that this coincides with what is specified in the
+PySaml2 configuration. Apart from that there really is nothing in
+application.py that demands that you use PySaml2 as middleware. If you
+switched to using the LDAP or CAS plugins nothing would change in the
+application. In the application configuration yes! But not in the application.
+And that is really how it should be done.
+
+There is one assumption, and that is that the middleware plugin that gathers
+information about the user places the extra information in as a value on the
+"user" property in the dictionary found under the key "repoze.who.identity"
+in the environment.
diff --git a/docs/howto/config.rst b/docs/howto/config.rst
new file mode 100644
index 00000000..c1691119
--- /dev/null
+++ b/docs/howto/config.rst
@@ -0,0 +1,834 @@
+.. _howto_config:
+
+Configuration of pySAML2 entities
+=================================
+
+Whether you plan to run a pySAML2 Service Provider, Identity Provider or an
+attribute authority you have to configure it. The format of the configuration
+file is the same regardless of which type of service you plan to run.
+What differs are some of the directives.
+Below you will find a list of all the used directives in alphabetical order.
+The configuration is written as a python module which contains a named
+dictionary ("CONFIG") that contains the configuration directives.
+
+The basic structure of the configuration file is therefore like this::
+
+ from saml2 import BINDING_HTTP_REDIRECT
+
+ CONFIG = {
+ "entityid" : "http://saml.example.com:saml/idp.xml",
+ "name" : "Rolands IdP",
+ "service": {
+ "idp": {
+ "endpoints" : {
+ "single_sign_on_service" : [
+ ("http://saml.example.com:saml:8088/sso",
+ BINDING_HTTP_REDIRECT)],
+ "single_logout_service": [
+ ("http://saml.example.com:saml:8088/slo",
+ BINDING_HTTP_REDIRECT)]
+ },
+ ...
+ }
+ },
+ "key_file" : "my.key",
+ "cert_file" : "ca.pem",
+ "xmlsec_binary" : "/usr/local/bin/xmlsec1",
+ "metadata": {
+ "local": ["edugain.xml"],
+ },
+ "attribute_map_dir" : "attributemaps",
+ ...
+ }
+
+.. note:: You can build the metadata file for your services directly from the
+ configuration.The make_metadata.py script in the pySAML2 tools directory
+ will do that for you.
+
+Configuration directives
+::::::::::::::::::::::::
+
+.. contents::
+ :local:
+ :backlinks: entry
+
+General directives
+------------------
+
+attribute_map_dir
+^^^^^^^^^^^^^^^^^
+
+Format::
+
+ "attribute_map_dir": "attribute-maps"
+
+Points to a directory which has the attribute maps in Python modules.
+A typical map file will looks like this::
+
+ MAP = {
+ "identifier": "urn:oasis:names:tc:SAML:2.0:attrname-format:basic",
+ "fro": {
+ 'urn:mace:dir:attribute-def:aRecord': 'aRecord',
+ 'urn:mace:dir:attribute-def:aliasedEntryName': 'aliasedEntryName',
+ 'urn:mace:dir:attribute-def:aliasedObjectName': 'aliasedObjectName',
+ 'urn:mace:dir:attribute-def:associatedDomain': 'associatedDomain',
+ 'urn:mace:dir:attribute-def:associatedName': 'associatedName',
+ ...
+ },
+ "to": {
+ 'aRecord': 'urn:mace:dir:attribute-def:aRecord',
+ 'aliasedEntryName': 'urn:mace:dir:attribute-def:aliasedEntryName',
+ 'aliasedObjectName': 'urn:mace:dir:attribute-def:aliasedObjectName',
+ 'associatedDomain': 'urn:mace:dir:attribute-def:associatedDomain',
+ 'associatedName': 'urn:mace:dir:attribute-def:associatedName',
+ ...
+ }
+ }
+
+The attribute map module contains a MAP dictionary with three items. The
+`identifier` item is the name-format you expect to support.
+The *to* and *fro* sub-dictionaries then contain the mapping between the names.
+
+As you see the format is again a python dictionary where the key is the
+name to convert from, and the value is the name to convert to.
+
+Since *to* in most cases is the inverse of the *fro* file, the
+software allowes you to only specify one of them and it will
+automatically create the other.
+
+cert_file
+^^^^^^^^^
+
+Format::
+
+ cert_file: "cert.pem"
+
+This is the public part of the service private/public key pair.
+*cert_file* must be a PEM formatted certificate chain file.
+
+contact_person
+^^^^^^^^^^^^^^
+
+This is only used by *make_metadata.py* when it constructs the metadata for
+the service described by the configuration file.
+This is where you describe who can be contacted if questions arise
+about the service or if support is needed. The possible types are according to
+the standard **technical**, **support**, **administrative**, **billing**
+and **other**.::
+
+ contact_person: [{
+ "givenname": "Derek",
+ "surname": "Jeter",
+ "company": "Example Co.",
+ "mail": ["jeter@example.com"],
+ "type": "technical",
+ },{
+ "givenname": "Joe",
+ "surname": "Girardi",
+ "company": "Example Co.",
+ "mail": "girardi@example.com",
+ "type": "administrative",
+ }]
+
+debug
+^^^^^
+
+Format::
+
+ debug: 1
+
+Whether debug information should be sent to the log file.
+
+entityid
+^^^^^^^^
+
+Format::
+
+ entityid: "http://saml.example.com/sp"
+
+The globally unique identifier of the entity.
+
+.. note:: It is recommended that the entityid should point to a real
+ webpage where the metadata for the entity can be found.
+
+key_file
+^^^^^^^^
+
+Format::
+
+ key_file: "key.pem"
+
+*key_file* is the name of a PEM formatted file that contains the private key
+of the service. This is presently used both to encrypt/sign assertions and as
+the client key in an HTTPS session.
+
+metadata
+^^^^^^^^
+
+Contains a list of places where metadata can be found. This can be either
+a file accessible on the server the service runs on, or somewhere on the net.::
+
+ "metadata" : {
+ "local": [
+ "metadata.xml", "vo_metadata.xml"
+ ],
+ "remote": [
+ {
+ "url":"https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
+ "cert":"kalmar2.cert"
+ }],
+ },
+
+The above configuration means that the service should read two local
+metadata files, and on top of that load one from the net. To verify the
+authenticity of the file downloaded from the net, the local copy of the
+public key should be used.
+This public key must be acquired by some out-of-band method.
+
+organization
+^^^^^^^^^^^^
+
+Only used by *make_metadata.py*.
+Where you describe the organization responsible for the service.::
+
+ "organization": {
+ "name": [("Example Company","en"), ("Exempel AB","se")],
+ "display_name": ["Exempel AB"],
+ "url": [("http://example.com","en"),("http://exempel.se","se")],
+ }
+
+.. note:: You can specify the language of the name, or the language used on
+ the webpage, by entering a tuple, instead of a simple string,
+ where the second part is the language code. If you don't specify a
+ language the default is "en" (English).
+
+preferred_binding
+^^^^^^^^^^^^^^^^^
+
+Which binding should be prefered for a service.
+Example configuration::
+
+ "preferred_binding" = {
+ "single_sign_on_service": [
+ 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
+ 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
+ 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
+ ],
+ "single_logout_service": [
+ 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP',
+ 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
+ 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
+ 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
+ ],
+ }
+
+The available services are:
+
+* manage_name_id_service
+* assertion_consumer_service
+* name_id_mapping_service
+* authn_query_service
+* attribute_service
+* authz_service
+* assertion_id_request_service
+* artifact_resolution_service
+* attribute_consuming_service
+
+
+service
+^^^^^^^
+
+Which services the server will provide; those are combinations of "idp", "sp"
+and "aa".
+So if a server is a Service Provider (SP) then the configuration
+could look something like this::
+
+ "service": {
+ "sp":{
+ "name" : "Rolands SP",
+ "endpoints":{
+ "assertion_consumer_service": ["http://localhost:8087/"],
+ "single_logout_service" : [("http://localhost:8087/slo",
+ 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect')],
+ },
+ "required_attributes": ["surname", "givenname", "edupersonaffiliation"],
+ "optional_attributes": ["title"],
+ "idp": {
+ "urn:mace:umu.se:saml:roland:idp": None,
+ },
+ }
+ },
+
+There are two options common to all services: 'name' and 'endpoints'.
+The remaining options are specific to one or the other of the service types.
+Which one is specified along side the name of the option.
+
+accepted_time_diff
+^^^^^^^^^^^^^^^^^^
+
+If your computer and another computer that you are communicating with are not
+in synch regarding the computer clock, then here you can state how big a
+difference you are prepared to accept.
+
+.. note:: This will indiscriminately effect all time comparisons.
+ Hence your server my accept a statement that in fact is to old.
+
+xmlsec_binary
+^^^^^^^^^^^^^
+
+Presently xmlsec1 binaries are used for all the signing and encryption stuff.
+This option defines where the binary is situated.
+
+Example::
+
+ "xmlsec_binary": "/usr/local/bin/xmlsec1",
+
+valid_for
+^^^^^^^^^
+
+How many *hours* this configuration is expected to be accurate.::
+
+ "valid_for": 24
+
+This of course is only used by *make_metadata.py*.
+The server will not stop working when this amount of time has elapsed :-).
+
+Specific directives
+-------------------
+
+Directives that are specific to a certain type of service.
+
+idp/aa
+^^^^^^
+
+Directives that are specific to an IdP or AA service instance
+
+sign_assertion
+""""""""""""""
+
+Specifies if the IdP should sign the assertion in an authentication response
+or not. Can be True or False. Default is False.
+
+sign_response
+"""""""""""""
+
+Specifies if the IdP should sign the authentication response or not. Can be
+True or False. Default is False.
+
+
+policy
+""""""
+
+If the server is an IdP and/or an AA then there might be reasons to do things
+differently depending on who is asking; this is where that is specified.
+The keys are 'default' and SP entity identifiers. Default is used whenever
+there is no entry for a specific SP. The reasoning is also that if there is
+no default and only SP entity identifiers as keys, then the server will only
+except connections from the specified SPs.
+An example might be::
+
+ "service": {
+ "idp": {
+ "policy": {
+ "default": {
+ "lifetime": {"minutes":15},
+ "attribute_restrictions": None, # means all I have
+ "name_form": "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
+ },
+ "urn:mace:example.com:saml:roland:sp": {
+ "lifetime": {"minutes": 5},
+ "attribute_restrictions":{
+ "givenName": None,
+ "surName": None,
+ }
+ }
+ }
+ }
+ }
+
+*lifetime*
+ This is the maximum amount of time before the information should be
+ regarded as stale. In an Assertion this is represented in the NotOnOrAfter
+ attribute.
+*attribute_restrictions*
+ By default there is no restrictions as to which attributes should be
+ return. Instead all the attributes and values that are gathered by the
+ database backends will be returned if nothing else is stated.
+ In the example above the SP with the entity identifier
+ "urn:mace:umu.se:saml:roland:sp"
+ has an attribute restriction: only the attributes
+ 'givenName' and 'surName' are to be returned. There is no limitations as to
+ what values on these attributes that can be returned.
+*name_form*
+ Which name-form that should be used when sending assertions.
+ Using this information the attribute name in the data source will be mapped to
+ the friendly name, and the saml attribute name will be taken from the uri/oid
+ defined in the attribute map.
+
+If restrictions on values are deemed necessary those are represented by
+regular expressions.::
+
+ "service": {
+ "aa": {
+ "policy": {
+ "urn:mace:umu.se:saml:roland:sp": {
+ "lifetime": {"minutes": 5},
+ "attribute_restrictions":{
+ "mail": [".*\.umu\.se$"],
+ }
+ }
+ }
+ }
+ }
+
+Here only mail addresses that end with ".umu.se" will be returned.
+
+sp
+^^
+
+Directives specific to SP instances
+
+authn_requests_signed
+"""""""""""""""""""""
+
+Indicates if the Authentication Requests sent by this SP should be signed
+by default. This can be overriden by application code for a specific call.
+
+This sets the AuthnRequestsSigned attribute of the SPSSODescriptor node
+of the metadata so the IdP will know this SP preference.
+
+Valid values are True or False. Default value is True.
+
+Example::
+
+ "service": {
+ "sp": {
+ "authn_requests_signed": True,
+ }
+ }
+
+
+want_response_signed
+""""""""""""""""""""
+
+Indicates that Authentication Responses to this SP must be signed. If set to
+True, the SP will not consume any SAML Responses that are not signed.
+
+Example::
+
+ "service": {
+ "sp": {
+ "want_response_signed": True,
+ }
+ }
+
+
+force_authn
+"""""""""""
+
+Mandates that the identity provider MUST authenticate the presenter directly
+rather than rely on a previous security context.
+
+Example::
+
+ "service": {
+ "sp": {
+ "force_authn": True,
+ }
+ }
+
+
+allow_unsolicited
+"""""""""""""""""
+
+When set to true, the SP will consume unsolicited SAML Responses, i.e. SAML
+Responses for which it has not sent a respective SAML Authentication Request.
+
+Example::
+
+ "service": {
+ "sp": {
+ "allow_unsolicited": True,
+ }
+ }
+
+
+hide_assertion_consumer_service
+"""""""""""""""""""""""""""""""
+
+When set to true the AuthnRequest will not include the
+AssertionConsumerServiceURL and ProtocolBinding attributes.
+
+Example::
+
+ "service": {
+ "sp": {
+ "hide_assertion_consumer_service": True,
+ }
+ }
+
+This kind of functionality is required for the eIDAS SAML profile
+
+> eIDAS-Connectors SHOULD NOT provide AssertionConsumerServiceURL.
+
+.. note::
+ This is relevant only for the eIDAS SAML profile.
+
+
+sp_type
+"""""""
+
+Sets the value for the eIDAS SPType node. By the eIDAS specification the value
+can be one of *public* and *private*.
+
+Example::
+
+ "service": {
+ "sp": {
+ "sp_type": "private",
+ }
+ }
+
+.. note::
+ This is relevant only for the eIDAS SAML profile.
+
+
+sp_type_in_metadata
+"""""""""""""""""""
+
+Whether the SPType node should appear in the metadata document
+or as part of each AuthnRequest.
+
+Example::
+
+ "service": {
+ "sp": {
+ "sp_type_in_metadata": True,
+ }
+ }
+
+.. note::
+ This is relevant only for the eIDAS SAML profile.
+
+
+requested_attributes
+""""""""""""""""""""
+
+A list of attributes that the SP requires from an eIDAS-Service (IdP).
+Each attribute is an object with the following attributes:
+
+* friendly_name
+* name
+* required
+* name_format
+
+Where friendly_name is an attribute name such as *DateOfBirth*, name is the
+full attribute name such as
+*http://eidas.europa.eu/attributes/naturalperson/DateOfBirth*, required
+indicates whether this attributed is required for authentication, and
+name_format indicates the name format for that attribute, such as
+*urn:oasis:names:tc:SAML:2.0:attrname-format:uri*.
+
+It is mandatory that at least name or friendly_name is set.
+By default attributes are assumed to be required.
+Missing attributes are infered based on the attribute maps data.
+
+Example::
+
+ "service": {
+ "sp": {
+ "requested_attributes": [
+ {
+ "name": "http://eidas.europa.eu/attributes/naturalperson/PersonIdentifier",
+ },
+ {
+ "friendly_name": "DateOfBirth",
+ "required": False,
+ },
+ ],
+ }
+ }
+
+.. note::
+ This is relevant only for the eIDAS SAML profile.
+
+ This option is different from the required_attributes and
+ optional_attributes parameters that control the requested
+ attributes in the metadata of an SP.
+
+
+idp
+"""
+
+Defines the set of IdPs that this SP is allowed to use; if unset, all listed
+IdPs may be used. If set, then the value is expected to be a list with entity
+identifiers for the allowed IdPs.
+A typical configuration, when the allowed set of IdPs are limited, would look
+something like this::
+
+ "service": {
+ "sp": {
+ "idp": ["urn:mace:umu.se:saml:roland:idp"],
+ }
+ }
+
+In this case the SP has only one IdP it can use.
+
+optional_attributes
+"""""""""""""""""""
+
+Attributes that this SP would like to receive from IdPs.
+
+Example::
+
+ "service": {
+ "sp": {
+ "optional_attributes": ["title"],
+ }
+ }
+
+Since the attribute names used here are the user friendly ones an attribute map
+must exist, so that the server can use the full name when communicating
+with other servers.
+
+required_attributes
+"""""""""""""""""""
+
+Attributes that this SP demands to receive from IdPs.
+
+Example::
+
+ "service": {
+ "sp": {
+ "required_attributes": ["surname", "givenName", "mail"],
+ }
+ }
+
+Again as for *optional_attributes* the names given are expected to be
+the user friendly names.
+
+want_assertions_signed
+""""""""""""""""""""""
+
+Indicates if this SP wants the IdP to send the assertions signed. This
+sets the WantAssertionsSigned attribute of the SPSSODescriptor node
+of the metadata so the IdP will know this SP preference.
+
+Valid values are True or False. Default value is False.
+
+Example::
+
+ "service": {
+ "sp": {
+ "want_assertions_signed": True,
+ }
+ }
+
+
+idp/aa/sp
+^^^^^^^^^
+
+If the configuration is covering both two or three different service types
+(like if one server is actually acting as both an IdP and a SP) then in some
+cases you might want to have these below different for the different services.
+
+endpoints
+"""""""""
+
+Where the endpoints for the services provided are.
+This directive has as value a dictionary with one or more of the following keys:
+
+* artifact_resolution_service (aa, idp and sp)
+* assertion_consumer_service (sp)
+* assertion_id_request_service (aa, idp)
+* attribute_service (aa)
+* manage_name_id_service (aa, idp)
+* name_id_mapping_service (idp)
+* single_logout_service (aa, idp, sp)
+* single_sign_on_service (idp)
+
+The values per service is a list of endpoint specifications.
+An endpoint specification can either be just the URL::
+
+ ”http://localhost:8088/A"
+
+or it can be a 2-tuple (URL+binding)::
+
+ from saml2 import BINDING_HTTP_POST
+ (”http://localhost:8087/A”, BINDING_HTTP_POST)
+
+or a 3-tuple (URL+binding+index)::
+
+ from saml2 import BINDING_HTTP_POST
+ (”http://lingon.catalogix.se:8087/A”, BINDING_HTTP_POST, 1)
+
+If no binding is specified, no index can be set.
+If no index is specified, the index is set based on the position in the list.
+
+Example::
+
+ "service":
+ "idp": {
+ "endpoints" : {
+ "single_sign_on_service" : [
+ ("http://localhost:8088/sso", BINDING_HTTP_REDIRECT)],
+ "single_logout_service": [
+ ("http://localhost:8088/slo", BINDING_HTTP_REDIRECT)]
+ },
+ },
+ },
+
+logout_requests_signed
+""""""""""""""""""""""
+
+Indicates if this entity will sign the Logout Requests originated from it.
+
+This can be overriden by application code for a specific call.
+
+Valid values are True or False. Default value is False.
+
+Example::
+
+ "service": {
+ "sp": {
+ "logout_requests_signed": False,
+ }
+ }
+
+subject_data
+""""""""""""
+
+The name of a database where the map between a local identifier and
+a distributed identifier is kept. By default this is a shelve database.
+So if you just specify name, then a shelve database with that name
+is created. On the other hand if you specify a tuple then the first
+element in the tuple specifies which type of database you want to use
+and the second element is the address of the database.
+
+Example::
+
+ "subject_data": "./idp.subject.db",
+
+or if you want to use for instance memcache::
+
+ "subject_data": ("memcached", "localhost:12121"),
+
+*shelve* and *memcached* are the only database types that are presently
+supported.
+
+
+virtual_organization
+""""""""""""""""""""
+
+Gives information about common identifiers for virtual_organizations::
+
+ "virtual_organization" : {
+ "urn:mace:example.com:it:tek":{
+ "nameid_format" : "urn:oid:1.3.6.1.4.1.1466.115.121.1.15-NameID",
+ "common_identifier": "umuselin",
+ }
+ },
+
+Keys in this dictionary are the identifiers for the virtual organizations.
+The arguments per organization are 'nameid_format' and 'common_identifier'.
+Useful if all the IdPs and AAs that are involved in a virtual organization
+have common attribute values for users that are part of the VO.
+
+Complete example
+----------------
+
+We start with a simple but fairly complete Service provider configuration::
+
+ from saml2 import BINDING_HTTP_REDIRECT
+
+ CONFIG = {
+ "entityid" : "http://example.com/sp/metadata.xml",
+ "service": {
+ "sp":{
+ "name" : "Example SP",
+ "endpoints":{
+ "assertion_consumer_service": ["http://example.com/sp"],
+ "single_logout_service" : [("http://example.com/sp/slo",
+ BINDING_HTTP_REDIRECT)],
+ },
+ }
+ },
+ "key_file" : "./mykey.pem",
+ "cert_file" : "./mycert.pem",
+ "xmlsec_binary" : "/usr/local/bin/xmlsec1",
+ "attribute_map_dir": "./attributemaps",
+ "metadata": {
+ "local": ["idp.xml"]
+ }
+ "organization": {
+ "display_name":["Example identities"]
+ }
+ "contact_person": [{
+ "givenname": "Roland",
+ "surname": "Hedberg",
+ "phone": "+46 90510",
+ "mail": "roland@example.com",
+ "type": "technical",
+ }]
+ }
+
+This is the typical setup for a SP.
+A metadata file to load is *always* needed, but it can of course
+contain anything from 1 up to many entity descriptions.
+
+------
+
+A slightly more complex configuration::
+
+ from saml2 import BINDING_HTTP_REDIRECT
+
+ CONFIG = {
+ "entityid" : "http://sp.example.com/metadata.xml",
+ "service": {
+ "sp":{
+ "name" : "Example SP",
+ "endpoints":{
+ "assertion_consumer_service": ["http://sp.example.com/"],
+ "single_logout_service" : [("http://sp.example.com/slo",
+ BINDING_HTTP_REDIRECT)],
+ },
+ "subject_data": ("memcached", "localhost:12121"),
+ "virtual_organization" : {
+ "urn:mace:example.com:it:tek":{
+ "nameid_format" : "urn:oid:1.3.6.1.4.1.1466.115.121.1.15-NameID",
+ "common_identifier": "eduPersonPrincipalName",
+ }
+ },
+ }
+ },
+ "key_file" : "./mykey.pem",
+ "cert_file" : "./mycert.pem",
+ "xmlsec_binary" : "/usr/local/bin/xmlsec1",
+ "metadata" : {
+ "local": ["example.xml"],
+ "remote": [{
+ "url":"https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral2&set=saml2",
+ "cert":"kalmar2.pem"}]
+ },
+ "attribute_maps" : "attributemaps",
+ "organization": {
+ "display_name":["Example identities"]
+ }
+ "contact_person": [{
+ "givenname": "Roland",
+ "surname": "Hedberg",
+ "phone": "+46 90510",
+ "mail": "roland@example.com",
+ "type": "technical",
+ }]
+ }
+
+Uses metadata files, both local and remote, and will talk to whatever
+IdP that appears in any of the metadata files.
+
+Other considerations
+::::::::::::::::::::
+
+Entity Categories
+-----------------
+Entity categories and their attributes are defined in src/saml2/entity_category/<registrar of entcat>.py
diff --git a/docs/howto/index.rst b/docs/howto/index.rst
new file mode 100644
index 00000000..52f2d409
--- /dev/null
+++ b/docs/howto/index.rst
@@ -0,0 +1,40 @@
+.. _howto:
+
+How to use PySAML2
+===================
+
+:Release: |release|
+:Date: |today|
+
+Before you can use Pysaml2, you'll need to get it installed.
+If you have not done it yet, read the :ref:`install`
+
+Well, now you have it installed and you want to do something.
+
+And I'm sorry to tell you this; but there isn't really a lot you can do with
+this code on its own.
+
+Sure you can send a AuthenticationRequest to an IdentityProvider or a
+AttributeQuery to an AttributeAuthority, but in order to get what they
+return you have to sit behind a Web server. Well that is not really true since
+the AttributeQuery would be over SOAP and you would get the result over the
+connection you have to the AttributeAuthority.
+
+But anyway, you may get my point. This is middleware stuff !
+
+PySAML2 is built to fit into a
+`WSGI <http://www.python.org/dev/peps/pep-0333/>`_ application
+
+But it can be used in a non-WSGI environment too.
+
+So you will find descriptions of both cases here.
+
+The configuration is the same regardless of whether you are using PySAML2 in a
+WSGI or non-WSGI environment.
+
+.. toctree::
+ :maxdepth: 1
+
+ config
+
+
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 00000000..4b596290
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,64 @@
+:Release: |release|
+:Date: |today|
+
+About SAML 2.0
+==============
+
+SAML 2.0 or Security Assertion Markup Language 2.0 is a version of the SAML standard for exchanging authentication and authorization data between security domains.
+
+About PySAML2
+=============
+
+PySAML2 is a pure python implementation of SAML2. It contains all
+necessary pieces for building a SAML2 service provider or an identity provider.
+The distribution contains examples of both.
+Originally written to work in a WSGI environment there are extensions that
+allow you to use it with other frameworks.
+
+
+How to use PySAML2
+===================
+
+Before you can use Pysaml2, you'll need to get it installed.
+If you have not done it yet, read the :ref:`install`
+
+Well, now you have it installed and you want to do something.
+
+And I'm sorry to tell you this; but there isn't really a lot you can do with
+this code on it's own.
+
+Sure you can send a AuthenticationRequest to an IdentityProvider or a
+AttributeQuery to an AttributeAuthority but in order to get what they
+return you have to sit behind a Web server. Well that is not really true since
+the AttributeQuery would be over SOAP and you would get the result over the
+connection you have to the AttributeAuthority.
+
+But anyway, you may get my point. This is middleware stuff !
+
+PySAML2 is built to fit into a
+`WSGI <http://www.python.org/dev/peps/pep-0333/>`_ application
+
+But it can be used in a non-WSGI environment too.
+
+So you will find descriptions of both cases here.
+
+The configuration is the same disregarding whether you are using PySAML2 in a
+WSGI or non-WSGI environment.
+
+Table of contents
+==================
+
+.. toctree::
+ :maxdepth: 2
+
+ install
+ examples/index
+ howto/index
+ sp_test/internal
+
+
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
diff --git a/docs/install.rst b/docs/install.rst
new file mode 100644
index 00000000..58910e29
--- /dev/null
+++ b/docs/install.rst
@@ -0,0 +1,57 @@
+.. _install:
+
+Quick install guide
+===================
+
+Before you can use PySAML2, you'll need to get it installed. This guide
+will guide you to a simple, minimal installation.
+
+Install PySAML2
+---------------
+
+For all this to work you need to have Python installed.
+The development has been done using 2.7.
+There is now a 3.X version.
+
+Prerequisites
+^^^^^^^^^^^^^
+
+You have to have ElementTree, which is either part of your Python distribution
+if it's recent enough, or if the Python is too old you have to install it,
+for instance by getting it from the Python Package Instance by using
+easy_install.
+
+You also need xmlsec1 which you can download from http://www.aleksey.com/xmlsec/
+
+If you're on OS X you can get xmlsec1 installed from MacPorts or Fink.
+
+Depending on how you are going to use PySAML2 you might also need
+
+* Mako
+* pyASN1
+* repoze.who
+* python-memcache
+* memcached
+
+Quick build instructions
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Once you have installed all the necessary prerequisites a simple::
+
+ python setup.py install
+
+will install the basic code.
+
+Note for rhel/centos 6: cffi depends on libffi-devel, and cryptography on openssl-devel to compile
+So you might want first to do:
+yum install libffi-devel openssl-devel
+
+After this you ought to be able to run the tests without an hitch.
+The tests are based on the pypy test environment, so::
+
+ cd tests
+ py.test
+
+is what you should use. If you don't have py.test, get it it's part of pypy!
+It's really good !
+
diff --git a/docs/make.bat b/docs/make.bat
new file mode 100644
index 00000000..4a006237
--- /dev/null
+++ b/docs/make.bat
@@ -0,0 +1,112 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+set SPHINXBUILD=sphinx-build
+set ALLSPHINXOPTS=-d _build/doctrees %SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+ set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+ :help
+ echo.Please use `make ^<target^>` where ^<target^> is one of
+ echo. html to make standalone HTML files
+ echo. dirhtml to make HTML files named index.html in directories
+ echo. pickle to make pickle files
+ echo. json to make JSON files
+ echo. htmlhelp to make HTML files and a HTML help project
+ echo. qthelp to make HTML files and a qthelp project
+ echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+ echo. changes to make an overview over all changed/added/deprecated items
+ echo. linkcheck to check all external links for integrity
+ echo. doctest to run all doctests embedded in the documentation if enabled
+ goto end
+)
+
+if "%1" == "clean" (
+ for /d %%i in (_build\*) do rmdir /q /s %%i
+ del /q /s _build\*
+ goto end
+)
+
+if "%1" == "html" (
+ %SPHINXBUILD% -b html %ALLSPHINXOPTS% _build/html
+ echo.
+ echo.Build finished. The HTML pages are in _build/html.
+ goto end
+)
+
+if "%1" == "dirhtml" (
+ %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% _build/dirhtml
+ echo.
+ echo.Build finished. The HTML pages are in _build/dirhtml.
+ goto end
+)
+
+if "%1" == "pickle" (
+ %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% _build/pickle
+ echo.
+ echo.Build finished; now you can process the pickle files.
+ goto end
+)
+
+if "%1" == "json" (
+ %SPHINXBUILD% -b json %ALLSPHINXOPTS% _build/json
+ echo.
+ echo.Build finished; now you can process the JSON files.
+ goto end
+)
+
+if "%1" == "htmlhelp" (
+ %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% _build/htmlhelp
+ echo.
+ echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in _build/htmlhelp.
+ goto end
+)
+
+if "%1" == "qthelp" (
+ %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% _build/qthelp
+ echo.
+ echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in _build/qthelp, like this:
+ echo.^> qcollectiongenerator _build\qthelp\pysaml2.qhcp
+ echo.To view the help file:
+ echo.^> assistant -collectionFile _build\qthelp\pysaml2.ghc
+ goto end
+)
+
+if "%1" == "latex" (
+ %SPHINXBUILD% -b latex %ALLSPHINXOPTS% _build/latex
+ echo.
+ echo.Build finished; the LaTeX files are in _build/latex.
+ goto end
+)
+
+if "%1" == "changes" (
+ %SPHINXBUILD% -b changes %ALLSPHINXOPTS% _build/changes
+ echo.
+ echo.The overview file is in _build/changes.
+ goto end
+)
+
+if "%1" == "linkcheck" (
+ %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% _build/linkcheck
+ echo.
+ echo.Link check complete; look for any errors in the above output ^
+or in _build/linkcheck/output.txt.
+ goto end
+)
+
+if "%1" == "doctest" (
+ %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% _build/doctest
+ echo.
+ echo.Testing of doctests in the sources finished, look at the ^
+results in _build/doctest/output.txt.
+ goto end
+)
+
+:end
diff --git a/docs/make.sh b/docs/make.sh
new file mode 100755
index 00000000..a2d7c6e6
--- /dev/null
+++ b/docs/make.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+rm -f saml2*
+sphinx-apidoc -F -o ../doc/ ../src/saml2
+make clean
+make html \ No newline at end of file
diff --git a/docs/sp_test/internal.rst b/docs/sp_test/internal.rst
new file mode 100644
index 00000000..5875cdf1
--- /dev/null
+++ b/docs/sp_test/internal.rst
@@ -0,0 +1,149 @@
+How sp_test works internally
+============================
+
+:Release: |release|
+:Date: |today|
+
+This are a few hints how sp_test works internally. It halps to extend it with
+new test classes
+
+When you want to test a SAML2 entity with this tool you need following things:
+
+#. The Test Driver Configuration, an example can be found in tests/idp_test/config.py
+#. Attribute Maps mapping URNs, OIDs and friendly names
+#. Key files for the test tool
+#. A metadata file representing the tool
+#. The Test Target Configuration file describes how to interact with the entity to be tested. The metadata for the entity is part of this file. An example can be found in tests/idp_test/test_target_config.py.
+
+These files should be stored outside the saml2test package to have a clean separation between the package and a particular test configuration. To create a directory for the configuration files copy the saml2test/tests including its contents.
+
+
+(1) Class and Object Structure
+::::::::::::::::::::::::::::::
+
+Client (sp_test/__init__.py)
+.........................
+Its life cycle is responsible for following activites:
+ - read config files and command line argumants (the test driver's config is "json_config")
+ - initialize the test driver IDP
+ - initialize a Conversation
+ - start the Conversion with .do_sequence_and_tests()
+ - post-process log messages
+
+Conversation (sp_test/base.py)
+..............................
+
+Operation (oper)
+................
+ - Comprises an id, name, sequence and tests
+ - Example: 'sp-00': {"name": 'Basic Login test', "sequence": [(Login, AuthnRequest, AuthnResponse, None)], "tests": {"pre": [], "post": []}
+
+OPERATIONS
+..........
+ - set of operations provided in sp_test
+ - can be listed with the -l command line option
+
+Sequence
+........
+ - A list of flows
+ - Example: see "sequence" item in operation dict
+
+Test (in the context of an operation)
+....
+ - class to be executed as part of an operation, either before ("pre") or after ("post") the sequence or inbetween a SAML request and response ("mid").
+ There are standard tests with the Request class (VerifyAuthnRequest) and operation-specific tests.
+ - Example for an operation-specific "mid" test: VerifyIfRequestIsSigned
+ - A test may be specified together with an argument as a tupel
+
+Flow
+....
+ * A tupel of classes that together implement an SAML request-response pair between IDP and SP (and possible other actors, such as a discovery service or IDP-proxy). A class can be derived from Request, Response (or other), Check or Operation.
+ * A flow for a solicited authentication consists of 4 classes:
+
+ * flow[0]: Operation (Handling a login flow such as discovery or WAYF - not implemented yet)
+ * flow[1]: Request (process the authentication request)
+ * flow[2]: Response (send the authentication response)
+ * flow[3]: Check (optional - can be None. E.g. check the response if a correct error status was raised when sending a broken response)
+
+Check (and subclasses)
+.....
+ - an optional class that is executed on receiving the SP's HTTP response(s) after the SAML response. If there are redirects it will be called for each response.
+ - writes a structured test report to conv.test_output
+ - It can check for expected errors, which do not cause an exception but in contrary are reported as success
+
+Interaction
+...........
+ - An interaction automates a human interaction. It searches a response from a test target for some constants, and if
+ there is a match, it will create a response suitable response.
+
+(2) Simplyfied Flow
+:::::::::::::::::::
+
+The following pseudocode is an extract showing an overview of what is executed
+for test sp-00::
+
+ do_sequence_and_test(self, oper, test):
+ self.test_sequence(tests["pre"]) # currently no tests defined for sp_test
+ for flow in oper:
+ self.do_flow(flow)
+
+ do_flow(flow):
+ if len(flow) >= 3:
+ self.wb_send_GET_startpage() # send start page GET request
+ self.intermit(flow[0]._interaction) # automate human user interface
+ self.parse_saml_message() # read relay state and saml message
+ self.send_idp_response(flow[1], flow[2]) # construct, sign & send a nice Response from config, metadata and request
+ if len(flow) == 4:
+ self.handle_result(flow[3]) # pass optional check class
+ else:
+ self.handle_result()
+
+ send_idp_response(req_flow, resp_flow):
+ self.test_sequence(req_flow.tests["mid"]) # execute "mid"-tests (request has "VerifyContent"-test built in; others from config)
+ # this line stands for a part that is a bit more involved .. see source
+
+ args.update(resp._response_args) # set userid, identity
+
+ test_sequence(sequence):
+ # execute tests in sequence (first invocation usually with check.VerifyContent)
+ for test in sequence:
+ self.do_check(test, **kwargs)
+
+ do_check(test, **kwargs):
+ # executes the test class using the __call__ construct
+
+ handle_result(response=None):
+ if response:
+ if isinstance(response(), VerifyEchopageContents):
+ if 300 < self.last_response.status_code <= 303:
+ self._redirect(self.last_response)
+ self.do_check(response)
+ elif isinstance(response(), Check):
+ self.do_check(response)
+ else:
+ # A HTTP redirect or HTTP Post (not sure this is ever executed)
+ ...
+ else:
+ if 300 < self.last_response.status_code <= 303:
+ self._redirect(self.last_response)
+
+ _txt = self.last_response.content
+ if self.last_response.status_code >= 400:
+ raise FatalError("Did not expected error")
+
+(3) Status Reporting
+::::::::::::::::::::
+The proper reporting of results is at the core of saml2test. Several conditions
+must be considered:
+
+#. An operation that was successful because the test target reports OK (e.g. HTTP 200)
+#. An operation that was successful because the test target reports NOK as expected, e.g. because of an invalid signature - HTTP 500 could be the correct response
+#. An errror in SAML2Test
+#. An errror in configuration of SAML2Test
+
+Status values are defined in saml2test.check like this:
+INFORMATION = 0, OK = 1, WARNING = 2, ERROR = 3, CRITICAL = 4, INTERACTION = 5
+
+
+There are 2 targets to write output to:
+* Test_ouput is written to conv.test_ouput during the execution of the flows. \ No newline at end of file