Skip to content

Commit 015fac5

Browse files
committed
Idp2 uses ssl
1 parent bf7ef77 commit 015fac5

File tree

2 files changed

+69
-15
lines changed

2 files changed

+69
-15
lines changed

example/idp2/idp.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
import re
88
import socket
99
import time
10+
import ssl
1011

1112
from Cookie import SimpleCookie
1213
from hashlib import sha1
1314
from urlparse import parse_qs
15+
from cherrypy import wsgiserver
16+
from cherrypy.wsgiserver import ssl_pyopenssl
1417

1518
from saml2 import BINDING_HTTP_ARTIFACT
1619
from saml2 import BINDING_URI
@@ -1044,13 +1047,15 @@ def application(environ, start_response):
10441047
parser.add_argument(dest="config")
10451048
args = parser.parse_args()
10461049

1050+
CONFIG = importlib.import_module(args.config)
1051+
10471052
AUTHN_BROKER = AuthnBroker()
10481053
AUTHN_BROKER.add(authn_context_class_ref(PASSWORD),
10491054
username_password_authn, 10,
1050-
"http://%s" % socket.gethostname())
1055+
CONFIG.BASE)
10511056
AUTHN_BROKER.add(authn_context_class_ref(UNSPECIFIED),
1052-
"", 0, "http://%s" % socket.gethostname())
1053-
CONFIG = importlib.import_module(args.config)
1057+
"", 0, CONFIG.BASE)
1058+
10541059
IDP = server.Server(args.config, cache=Cache())
10551060
IDP.ticket = {}
10561061

@@ -1062,6 +1067,17 @@ def application(environ, start_response):
10621067
HOST = CONFIG.HOST
10631068
PORT = CONFIG.PORT
10641069

1065-
SRV = make_server(HOST, PORT, application)
1066-
print("IdP listening on %s:%s" % (HOST, PORT))
1067-
SRV.serve_forever()
1070+
SRV = wsgiserver.CherryPyWSGIServer((HOST, PORT), application)
1071+
1072+
_https = ""
1073+
if CONFIG.HTTPS:
1074+
SRV.ssl_adapter = ssl_pyopenssl.pyOpenSSLAdapter(CONFIG.SERVER_CERT,
1075+
CONFIG.SERVER_KEY, CONFIG.CERT_CHAIN)
1076+
_https = " using SSL/TLS"
1077+
logger.info("Server starting")
1078+
print("IDP listening on %s:%s%s" % (HOST, PORT, _https))
1079+
try:
1080+
SRV.start()
1081+
except KeyboardInterrupt:
1082+
SRV.stop()
1083+

example/idp2/idp_conf.py.example

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,36 @@ except ImportError:
1515
get_xmlsec_binary = None
1616

1717
if get_xmlsec_binary:
18-
xmlsec_path = get_xmlsec_binary(["/opt/local/bin"])
18+
xmlsec_path = get_xmlsec_binary(["/opt/local/bin","/usr/local/bin"])
1919
else:
20-
xmlsec_path = '/usr/bin/xmlsec1'
20+
xmlsec_path = '/usr/local/bin/xmlsec1'
2121

2222
BASEDIR = os.path.abspath(os.path.dirname(__file__))
2323

2424

2525
def full_path(local_file):
2626
return os.path.join(BASEDIR, local_file)
2727

28+
#HOST = '130.239.200.190'
2829
HOST = 'localhost'
2930
PORT = 8088
3031

31-
BASE = "http://%s:%s" % (HOST, PORT)
32+
HTTPS = True
33+
34+
if HTTPS:
35+
BASE = "https://%s:%s" % (HOST, PORT)
36+
else:
37+
BASE = "http://%s:%s" % (HOST, PORT)
38+
39+
# HTTPS cert information
40+
SERVER_CERT = "pki/mycert.pem"
41+
SERVER_KEY = "pki/mykey.pem"
42+
CERT_CHAIN = ""
3243

3344
CONFIG = {
3445
"entityid": "%s/idp.xml" % BASE,
3546
"description": "My IDP",
36-
"valid_for": 168,
47+
# "valid_for": 168,
3748
"service": {
3849
"aa": {
3950
"endpoints": {
@@ -81,6 +92,29 @@ CONFIG = {
8192
("%s/nim" % BASE, BINDING_SOAP),
8293
],
8394
},
95+
"ui_info": {
96+
"display_name": [
97+
{
98+
"text": "InAcademia.org - TEST",
99+
"lang": "en"
100+
}
101+
],
102+
"description": [
103+
{
104+
"text": "The InAcademia Simple validation Sevice allows for the easy validation of affiliation (Student, Faculty, Staff) of a user in Academia. This is a TEST instance",
105+
"lang": "en"
106+
}
107+
],
108+
"logo": [
109+
{
110+
"text": "https://inacademia.org/static/logo.png",
111+
"width": "120",
112+
"height": "60",
113+
"lang": "en"
114+
115+
}
116+
],
117+
},
84118
"policy": {
85119
"default": {
86120
"lifetime": {"minutes": 15},
@@ -98,19 +132,23 @@ CONFIG = {
98132
"key_file": full_path("pki/mykey.pem"),
99133
"cert_file": full_path("pki/mycert.pem"),
100134
"metadata": {
101-
"local": [full_path("../sp-wsgi/sp.xml")],
135+
#"local": [full_path("../sp-wsgi/sp.xml")],
136+
"local": ["/Users/mathiashedstrom/work/DIRG/VOpaas_proxy/example/saml2.xml"],
137+
# "local": ["/Users/mathiashedstrom/work/DIRG/VOpaas_proxy/example/proxy.xml"],
138+
# "local": ["/Users/mathiashedstrom/work/DIRG/s2sproxy/example/proxy.xml"],
102139
},
103140
"organization": {
104-
"display_name": "Rolands Identiteter",
105-
"name": "Rolands Identiteter",
106-
"url": "http://www.example.com",
141+
"display_name": [("Rolands Identiteter", "en")],
142+
"name": [("Rolands Identiteter", "se"), ("Rolands Identities", "en")],
143+
"url": [("http://www.example.com", "en"), ("http://www.example.se", "se")],
107144
},
108145
"contact_person": [
109146
{
110147
"contact_type": "technical",
111148
"given_name": "Roland",
112149
"sur_name": "Hedberg",
113-
"email_address": "[email protected]"
150+
"email_address": ["[email protected]", "[email protected]"],
151+
114152
}, {
115153
"contact_type": "support",
116154
"given_name": "Support",

0 commit comments

Comments
 (0)