Skip to content

Commit bc9a7bc

Browse files
author
Hans Hörberg
committed
Merge
2 parents 7585d46 + 9a1974b commit bc9a7bc

17 files changed

+7114
-2766
lines changed

README

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,11 @@ README for PySAML2
44
Dependencies
55
------------
66
PySAML2 should be compatible with any python >= 2.6 not 3.X yet.
7-
To be able to sign/verify, encrypt/decrypt you need xmlsec1.
8-
The repoze stuff works best together with repoze.who .
9-
10-
* http://www.aleksey.com/xmlsec/
11-
* http://static.repoze.org/whodocs/
127

138
Install
149
-------
15-
You need repoze.who to get the examples working, can be gotten through
16-
easy_install
17-
18-
easy_install repoze.who
19-
20-
Or from the PyPi site if you prefer to do it that way.
21-
You should get the latest version, which is right now 1.0.18 .
22-
23-
You also need xmlsec, which you can find here:
10+
You will need xmlsec1 to be able to sign/verify, encrypt/decrypt.
11+
You can find xmlsec1 here:
2412

2513
http://www.aleksey.com/xmlsec/
2614

@@ -41,9 +29,9 @@ Project page on :
4129

4230
https://github.com/rohe/pysaml2
4331

44-
Use the [email protected] mailing list. Since we do not have
45-
publicly available bug tracker yet, bug reports should be emailed
46-
there too.
32+
Use the [email protected] mailing list. Bug reports can either be emailed
33+
to this mailing list of added to the github repository
34+
https://github.com/rohe/pysaml2.
4735

4836
You can subscribe to this mailing list at
4937
http://delfos.sci.uma.es/mailman/listinfo/pysaml2

example/idp/idp.xml

Lines changed: 0 additions & 47 deletions
This file was deleted.
File renamed without changes.

example/idp2/idp_conf.py renamed to example/idp2/idp_conf.py.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,16 @@ def full_path(local_file):
129129
"loglevel": "debug",
130130
}
131131
}
132+
133+
# Authentication contexts
134+
135+
#(r'verify?(.*)$', do_verify),
136+
137+
CAS_SERVER = "https://cas.umu.se"
138+
CAS_VERIFY = "%s/verify_cas" % BASE
139+
PWD_VERIFY = "%s/verify_pwd" % BASE
140+
141+
AUTHORIZATION = {
142+
"CAS" : {"ACR": "CAS", "WEIGHT": 1, "URL": CAS_VERIFY},
143+
"UserPassword" : {"ACR": "PASSWORD", "WEIGHT": 2, "URL": PWD_VERIFY}
144+
}

example/sp/sp.xml

Lines changed: 0 additions & 2 deletions
This file was deleted.
File renamed without changes.

src/saml2/assertion.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,8 @@ def _authn_context_decl_ref(self, decl_ref, authn_auth=None):
578578
authenticating_authority=factory(
579579
saml.AuthenticatingAuthority, text=authn_auth))
580580

581-
def _authn_context_class_ref(self, authn_class, authn_auth=None):
581+
@staticmethod
582+
def _authn_context_class_ref(authn_class, authn_auth=None):
582583
"""
583584
Construct the authn context with a authn context class reference
584585
:param authn_class: The authn context class reference
@@ -596,45 +597,62 @@ def _authn_context_class_ref(self, authn_class, authn_auth=None):
596597
authn_context_class_ref=cntx_class)
597598

598599
def _authn_statement(self, authn_class=None, authn_auth=None,
599-
authn_decl=None, authn_decl_ref=None):
600+
authn_decl=None, authn_decl_ref=None, authn_instant="",
601+
subject_locality=""):
600602
"""
601603
Construct the AuthnStatement
602604
:param authn_class: Authentication Context Class reference
603605
:param authn_auth: Authenticating Authority
604606
:param authn_decl: Authentication Context Declaration
605607
:param authn_decl_ref: Authentication Context Declaration reference
608+
:param authn_instant: When the Authentication was performed.
609+
Assumed to be seconds since the Epoch.
610+
:param subject_locality: Specifies the DNS domain name and IP address
611+
for the system from which the assertion subject was apparently
612+
authenticated.
606613
:return: An AuthnContext instance
607614
"""
615+
if authn_instant:
616+
_instant = instant(time_stamp=authn_instant)
617+
else:
618+
_instant = instant()
619+
608620
if authn_class:
609-
return factory(
621+
res = factory(
610622
saml.AuthnStatement,
611-
authn_instant=instant(),
623+
authn_instant=_instant,
612624
session_index=sid(),
613625
authn_context=self._authn_context_class_ref(
614626
authn_class, authn_auth))
615627
elif authn_decl:
616-
return factory(
628+
res = factory(
617629
saml.AuthnStatement,
618-
authn_instant=instant(),
630+
authn_instant=_instant,
619631
session_index=sid(),
620632
authn_context=self._authn_context_decl(authn_decl, authn_auth))
621633
elif authn_decl_ref:
622-
return factory(
634+
res = factory(
623635
saml.AuthnStatement,
624-
authn_instant=instant(),
636+
authn_instant=_instant,
625637
session_index=sid(),
626638
authn_context=self._authn_context_decl_ref(authn_decl_ref,
627639
authn_auth))
628640
else:
629-
return factory(
641+
res = factory(
630642
saml.AuthnStatement,
631-
authn_instant=instant(),
643+
authn_instant=_instant,
632644
session_index=sid())
633645

646+
if subject_locality:
647+
res.subject_locality = saml.SubjectLocality(text=subject_locality)
648+
649+
return res
650+
634651
def construct(self, sp_entity_id, in_response_to, consumer_url,
635652
name_id, attrconvs, policy, issuer, authn_class=None,
636653
authn_auth=None, authn_decl=None, encrypt=None,
637-
sec_context=None, authn_decl_ref=None):
654+
sec_context=None, authn_decl_ref=None, authn_instant="",
655+
subject_locality=""):
638656
""" Construct the Assertion
639657
640658
:param sp_entity_id: The entityid of the SP
@@ -651,6 +669,10 @@ def construct(self, sp_entity_id, in_response_to, consumer_url,
651669
:param encrypt: Whether to encrypt parts or all of the Assertion
652670
:param sec_context: The security context used when encrypting
653671
:param authn_decl_ref: An Authentication Context declaration reference
672+
:param authn_instant: When the Authentication was performed
673+
:param subject_locality: Specifies the DNS domain name and IP address
674+
for the system from which the assertion subject was apparently
675+
authenticated.
654676
:return: An Assertion instance
655677
"""
656678

@@ -677,7 +699,9 @@ def construct(self, sp_entity_id, in_response_to, consumer_url,
677699

678700
if authn_auth or authn_class or authn_decl or authn_decl_ref:
679701
_authn_statement = self._authn_statement(authn_class, authn_auth,
680-
authn_decl, authn_decl_ref)
702+
authn_decl, authn_decl_ref,
703+
authn_instant,
704+
subject_locality)
681705
else:
682706
_authn_statement = None
683707

src/saml2/mdstore.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,26 @@ def entity_categories(self, entity_id):
345345

346346
return res
347347

348+
def __eq__(self, other):
349+
try:
350+
assert isinstance(other, MetaData)
351+
except AssertionError:
352+
return False
353+
354+
if len(self.entity) != len(other.entity):
355+
return False
356+
357+
if set(self.entity.keys()) != set(other.entity.keys()):
358+
return False
359+
360+
for key, item in self.entity.items():
361+
try:
362+
assert item == other[key]
363+
except AssertionError:
364+
return False
365+
366+
return True
367+
348368

349369
class MetaDataFile(MetaData):
350370
"""

0 commit comments

Comments
 (0)