summaryrefslogtreecommitdiff
path: root/example/sp-wsgi
diff options
context:
space:
mode:
authorHans Hörberg <hans.horberg@umu.se>2015-06-02 15:34:01 +0200
committerHans Hörberg <hans.horberg@umu.se>2015-06-02 15:34:01 +0200
commitcddf80f4c0e62fac9e8b41ad6f6ecee42909d55e (patch)
tree826568e43f0ac1626ad8244a9b5f61cdfacc9142 /example/sp-wsgi
parent9c2b951be6a830aa4d165821ea4f0d7f245221f2 (diff)
downloadpysaml2-cddf80f4c0e62fac9e8b41ad6f6ecee42909d55e.tar.gz
New metadata configuration for encryption.
Diffstat (limited to 'example/sp-wsgi')
-rwxr-xr-xexample/sp-wsgi/sp.py31
-rw-r--r--example/sp-wsgi/sp.xml34
2 files changed, 31 insertions, 34 deletions
diff --git a/example/sp-wsgi/sp.py b/example/sp-wsgi/sp.py
index f1d14906..1f1de9ac 100755
--- a/example/sp-wsgi/sp.py
+++ b/example/sp-wsgi/sp.py
@@ -3,7 +3,9 @@ from __future__ import print_function
import logging
import re
import argparse
+import os
from saml2.extension.pefim import SPCertEnc
+from saml2.metadata import create_metadata_string
import service_conf
from Cookie import SimpleCookie
@@ -753,6 +755,21 @@ def add_urls():
# ----------------------------------------------------------------------------
+def metadata(environ, start_response):
+ try:
+ path = _args.path
+ if path is None or len(path) == 0:
+ path = os.path.dirname(os.path.abspath( __file__ ))
+ if path[-1] != "/":
+ path += "/"
+ metadata = create_metadata_string(path+"sp_conf.py", None,
+ _args.valid, _args.cert, _args.keyfile,
+ _args.id, _args.name, _args.sign)
+ start_response('200 OK', [('Content-Type', "text/xml")])
+ return metadata
+ except Exception as ex:
+ logger.error("An error occured while creating metadata:" + ex.message)
+ return not_found(environ, start_response)
def application(environ, start_response):
"""
@@ -769,6 +786,8 @@ def application(environ, start_response):
path = environ.get('PATH_INFO', '').lstrip('/')
logger.debug("<application> PATH: '%s'" % path)
+ if path == "metadata":
+ return metadata(environ, start_response)
logger.debug("Finding callback to run")
try:
@@ -822,6 +841,18 @@ if __name__ == '__main__':
_parser.add_argument('-W', dest='wayf', action='store_true',
help="Which WAYF url to use")
_parser.add_argument("config", help="SAML client config")
+ _parser.add_argument('-p', dest='path', help='Path to configuration file.')
+ _parser.add_argument('-v', dest='valid', default="4",
+ help="How long, in days, the metadata is valid from the time of creation")
+ _parser.add_argument('-c', dest='cert', help='certificate')
+ _parser.add_argument('-i', dest='id',
+ help="The ID of the entities descriptor in the metadata")
+ _parser.add_argument('-k', dest='keyfile',
+ help="A file with a key to sign the metadata with")
+ _parser.add_argument('-n', dest='name')
+ _parser.add_argument('-S', dest='sign', action='store_true',
+ help="sign the metadata")
+
ARGS = {}
_args = _parser.parse_args()
diff --git a/example/sp-wsgi/sp.xml b/example/sp-wsgi/sp.xml
deleted file mode 100644
index f452f02f..00000000
--- a/example/sp-wsgi/sp.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<ns0:EntityDescriptor xmlns:ns0="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="urn:oasis:names:tc:SAML:metadata:attribute" xmlns:ns2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ns4="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" entityID="http://localhost:8087/sp.xml"><ns0:Extensions><ns1:EntityAttributes><ns2:Attribute Name="http://macedir.org/entity-category" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"><ns2:AttributeValue xsi:type="xs:string">http://www.geant.net/uri/dataprotection-code-of-conduct/v1</ns2:AttributeValue></ns2:Attribute></ns1:EntityAttributes></ns0:Extensions><ns0:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="true" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"><ns0:KeyDescriptor use="encryption"><ns4:KeyInfo><ns4:X509Data><ns4:X509Certificate>MIIC8jCCAlugAwIBAgIJAJHg2V5J31I8MA0GCSq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ZYeOhzP/2stAPwCTU4kxEoiy0KpZMANI=
-</ns4:X509Certificate></ns4:X509Data></ns4:KeyInfo></ns0:KeyDescriptor><ns0:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://localhost:8087/acs/post" index="1" /><ns0:AttributeConsumingService index="1"><ns0:ServiceName xml:lang="en">My SP service</ns0:ServiceName><ns0:ServiceDescription xml:lang="en">Example SP</ns0:ServiceDescription><ns0:RequestedAttribute FriendlyName="sn" Name="urn:oid:2.5.4.4" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" /><ns0:RequestedAttribute FriendlyName="givenname" Name="urn:oid:2.5.4.42" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" /><ns0:RequestedAttribute FriendlyName="uid" Name="urn:oid:0.9.2342.19200300.100.1.1" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" /><ns0:RequestedAttribute FriendlyName="edupersonaffiliation" Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" /><ns0:RequestedAttribute FriendlyName="title" Name="urn:oid:2.5.4.12" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="false" /></ns0:AttributeConsumingService></ns0:SPSSODescriptor></ns0:EntityDescriptor>