Skip to content

Commit b0c0cf8

Browse files
author
Roland Hedberg
committed
Merge pull request #86 from HaToHo/master
Added certificate generation
2 parents 26e25cd + 234ce01 commit b0c0cf8

File tree

14 files changed

+790
-27
lines changed

14 files changed

+790
-27
lines changed

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,43 @@ example/sp/sp_conf_local.py
109109
example/sp/my_backup_sp_conf_local.py
110110

111111
example/sp/backup_sp_conf_local.py
112+
113+
example/idp2/pki/localhost.ca.crt
114+
115+
example/idp2/pki/localhost.ca.crt
116+
117+
example/idp2/pki/localhost.ca.key
118+
119+
example/idp2/pki/localhost.ca.key
120+
121+
example/sp/pki/localhost.ca.crt
122+
123+
example/sp/pki/localhost.ca.crt
124+
125+
example/sp/pki/localhost.ca.key
126+
127+
example/sp/pki/localhost.ca.key
128+
129+
example/idp2/idp_conf_dirgweb.py
130+
131+
example/idp2/idp_conf_nocert.py
132+
133+
example/idp2/idp_conf_proxy.py
134+
135+
example/idp2/idp_nocert.xml
136+
137+
example/sp/nocert_sp_conf/sp_nocert.xml
138+
139+
example/sp/normal_sp_conf/sp.xml
140+
141+
example/sp/normal_sp_conf/sp_conf.py
142+
143+
example/sp/normal_sp_conf/who.ini
144+
145+
example/sp/sp_nocert.xml
146+
147+
example/sp/sp_nocert2.xml
148+
149+
example/sp/test.py
150+
151+
example/sp/sp_conf.py

example/idp2/idp.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,13 @@ def do(self, query, binding_in, relay_state=""):
297297
if REPOZE_ID_EQUIVALENT:
298298
identity[REPOZE_ID_EQUIVALENT] = self.user
299299
try:
300+
sign_assertion = IDP.config.getattr("sign_assertion", "idp")
301+
if sign_assertion is None:
302+
sign_assertion = False
300303
_resp = IDP.create_authn_response(
301304
identity, userid=self.user,
302-
authn=AUTHN_BROKER[self.environ["idp.authn_ref"]],
303-
**resp_args)
305+
authn=AUTHN_BROKER[self.environ["idp.authn_ref"]], sign_assertion=sign_assertion,
306+
sign_response=False, **resp_args)
304307
except Exception, excp:
305308
logging.error(exception_trace(excp))
306309
resp = ServiceError("Exception: %s" % (excp,))
@@ -322,6 +325,7 @@ def _store_request(self, _dict):
322325

323326
def redirect(self):
324327
""" This is the HTTP-redirect endpoint """
328+
325329
logger.info("--- In SSO Redirect ---")
326330
_info = self.unpack_redirect()
327331

example/sp/pki/certgeneration.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from saml2.cert import OpenSSLWrapper
4+
5+
__author__ = 'haho0032'
6+
7+
8+
cert_info_ca = {
9+
"cn": "localhost.ca",
10+
"country_code": "se",
11+
"state": "ac",
12+
"city": "umea",
13+
"organization": "ITS Umea University",
14+
"organization_unit": "DIRG"
15+
}
16+
17+
osw = OpenSSLWrapper()
18+
19+
ca_cert, ca_key = osw.create_certificate(cert_info_ca, request=False, write_to_file=True,
20+
cert_dir="./")

example/sp/sp_conf.py.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ CONFIG = {
4848
},
4949
"loglevel": "debug",
5050
}
51-
}
51+
}

src/s2repoze/plugins/sp.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import sys
2424
import platform
2525
import shelve
26+
import threading
2627
import traceback
28+
import saml2
2729
from urlparse import parse_qs, urlparse
2830

2931
from StringIO import StringIO
@@ -133,7 +135,6 @@ def __init__(self, rememberer_name, config, saml_client, wayf, cache,
133135
self.discosrv = discovery
134136
self.idp_query_param = idp_query_param
135137
self.logout_endpoints = [urlparse(ep)[2] for ep in config.endpoint("single_logout_service")]
136-
137138
try:
138139
self.metadata = self.conf.metadata
139140
except KeyError:
@@ -360,11 +361,18 @@ def challenge(self, environ, _status, _app_headers, _forget_headers):
360361
logger.debug("srvs: %s" % srvs)
361362
dest = srvs[0]["location"]
362363
logger.debug("destination: %s" % dest)
363-
req = _cli.create_authn_request(dest, vorg=vorg_name)
364-
ht_args = _cli.apply_binding(_binding, "%s" % req,
365-
destination=dest,
366-
relay_state=came_from)
367-
_sid = req.id
364+
365+
if _cli.authn_requests_signed:
366+
_sid = saml2.s_utils.sid(_cli.seed)
367+
msg_str = _cli.create_authn_request(dest, vorg=vorg_name, sign=_cli.authn_requests_signed,
368+
message_id=_sid)
369+
else:
370+
req = _cli.create_authn_request(dest, vorg=vorg_name, sign=False)
371+
msg_str = "%s" % req
372+
_sid = req.id
373+
374+
ht_args = _cli.apply_binding(_binding, msg_str, destination=dest, relay_state=came_from)
375+
368376
logger.debug("ht_args: %s" % ht_args)
369377
except Exception, exc:
370378
logger.exception(exc)

src/saml2/authn_context/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _pick_by_class_ref(self, cls_ref, comparision_type="exact"):
136136
res = []
137137

138138
for ref in _refs[1:]:
139-
item = self.db[ref]
139+
item = self.db["info"][ref]
140140
res.append((item["method"], ref))
141141
if func(_level, item["level"]):
142142
_level = item["level"]

0 commit comments

Comments
 (0)