Skip to content

Commit 385a439

Browse files
Merge pull request #791 from wibed/commentary
Add inline documentation
2 parents c89082f + edbb952 commit 385a439

File tree

2 files changed

+85
-6
lines changed

2 files changed

+85
-6
lines changed

src/saml2/__init__.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,20 @@
6060
DECISION_TYPE_INDETERMINATE = "Indeterminate"
6161

6262
VERSION = "2.0"
63-
63+
# http://docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf
64+
# The specification was later updated with errata, and the new version is here:
65+
# http://www.oasis-open.org/committees/download.php/56779/sstc-saml-bindings-errata-2.0-wd-06.pdf
66+
# parse a SOAP header, make a SOAP request, and receive a SOAP response
6467
BINDING_SOAP = 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP'
68+
# parse a PAOS header, make a PAOS request, and receive a PAOS response
6569
BINDING_PAOS = 'urn:oasis:names:tc:SAML:2.0:bindings:PAOS'
70+
# URI encoded messages
6671
BINDING_HTTP_REDIRECT = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect'
72+
# HTML encoded messages
6773
BINDING_HTTP_POST = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'
74+
# sensitive messages are transported over a backchannel
6875
BINDING_HTTP_ARTIFACT = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact'
76+
# as uri response encoded message
6977
BINDING_URI = 'urn:oasis:names:tc:SAML:2.0:bindings:URI'
7078

7179

src/saml2/saml.py

+76-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
#
44
# Generated Mon May 2 14:23:33 2011 by parse_xsd.py version 0.4.
55
#
6+
# A summary of available specifications can be found at:
7+
# https://wiki.oasis-open.org/security/FrontPage
8+
#
9+
# saml core specifications to be found at:
10+
# if any question arise please query the following pdf.
11+
# http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf
12+
# The specification was later updated with errata, and the new version is here:
13+
# https://www.oasis-open.org/committees/download.php/56776/sstc-saml-core-errata-2.0-wd-07.pdf
14+
#
15+
16+
617
import base64
718

819
from saml2.validate import valid_ipv4, MustValueError
@@ -17,32 +28,53 @@
1728
from saml2 import xmldsig as ds
1829
from saml2 import xmlenc as xenc
1930

31+
# authentication information fields
2032
NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:assertion'
2133

22-
XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance'
34+
# xmlschema definition
35+
XSD = "xs"
36+
# xmlschema templates and extensions
2337
XS_NAMESPACE = 'http://www.w3.org/2001/XMLSchema'
24-
38+
# xmlschema-instance, which contains several builtin attributes
39+
XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance'
40+
# xml soap namespace
41+
NS_SOAP_ENC = "http://schemas.xmlsoap.org/soap/encoding/"
42+
# type definitions for xmlschemas
2543
XSI_TYPE = '{%s}type' % XSI_NAMESPACE
44+
# nil type definition for xmlschemas
2645
XSI_NIL = '{%s}nil' % XSI_NAMESPACE
2746

47+
# idp and sp communicate usually about a subject(NameID)
48+
# the format determines the category the subject is in
49+
50+
# custom subject
2851
NAMEID_FORMAT_UNSPECIFIED = (
2952
"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified")
53+
# subject as email address
3054
NAMEID_FORMAT_EMAILADDRESS = (
3155
"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress")
56+
# subject as x509 key
3257
NAMEID_FORMAT_X509SUBJECTNAME = (
3358
"urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName")
59+
# subject as windows domain name
3460
NAMEID_FORMAT_WINDOWSDOMAINQUALIFIEDNAME = (
3561
"urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName")
62+
# subject from a kerberos instance
3663
NAMEID_FORMAT_KERBEROS = (
3764
"urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos")
65+
# subject as name
3866
NAMEID_FORMAT_ENTITY = (
3967
"urn:oasis:names:tc:SAML:2.0:nameid-format:entity")
68+
# linked subject
4069
NAMEID_FORMAT_PERSISTENT = (
4170
"urn:oasis:names:tc:SAML:2.0:nameid-format:persistent")
71+
# annonymous subject
4272
NAMEID_FORMAT_TRANSIENT = (
4373
"urn:oasis:names:tc:SAML:2.0:nameid-format:transient")
74+
# subject avaiable in encrypted format
4475
NAMEID_FORMAT_ENCRYPTED = (
4576
"urn:oasis:names:tc:SAML:2.0:nameid-format:encrypted")
77+
# dicc for avaiable formats
4678
NAMEID_FORMATS_SAML2 = (
4779
('NAMEID_FORMAT_EMAILADDRESS', NAMEID_FORMAT_EMAILADDRESS),
4880
('NAMEID_FORMAT_ENCRYPTED', NAMEID_FORMAT_ENCRYPTED),
@@ -51,41 +83,80 @@
5183
('NAMEID_FORMAT_TRANSIENT', NAMEID_FORMAT_TRANSIENT),
5284
('NAMEID_FORMAT_UNSPECIFIED', NAMEID_FORMAT_UNSPECIFIED),
5385
)
86+
87+
# a profile outlines a set of rules describing how to embed SAML assertions.
88+
# https://docs.oasis-open.org/security/saml/v2.0/saml-profiles-2.0-os.pdf
89+
# The specification was later updated with errata, and the new version is here:
90+
# https://www.oasis-open.org/committees/download.php/56782/sstc-saml-profiles-errata-2.0-wd-07.pdf
91+
92+
# XML based values for SAML attributes
5493
PROFILE_ATTRIBUTE_BASIC = (
5594
"urn:oasis:names:tc:SAML:2.0:profiles:attribute:basic")
5695

96+
# an AuthnRequest is made to initiate authentication
97+
# authenticate the request with login credentials
5798
AUTHN_PASSWORD = "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"
99+
# authenticate the request with login credentials, over tls/https
58100
AUTHN_PASSWORD_PROTECTED = \
59101
"urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
60102

103+
# attribute statements is key:value metadata shared with your app
104+
105+
# custom format
61106
NAME_FORMAT_UNSPECIFIED = (
62107
"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified")
108+
# uri format
63109
NAME_FORMAT_URI = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
110+
# XML-based format
64111
NAME_FORMAT_BASIC = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
112+
# dicc for avaiable formats
65113
NAME_FORMATS_SAML2 = (
66114
('NAME_FORMAT_BASIC', NAME_FORMAT_BASIC),
67115
('NAME_FORMAT_URI', NAME_FORMAT_URI),
68116
('NAME_FORMAT_UNSPECIFIED', NAME_FORMAT_UNSPECIFIED),
69117
)
118+
119+
# the SAML authority's decision can be predetermined by arbitrary context
120+
121+
# the specified action is permitted
70122
DECISION_TYPE_PERMIT = "Permit"
123+
# the specified action is denied
71124
DECISION_TYPE_DENY = "Deny"
125+
# the SAML authority cannot determine if the action is permitted or denied
72126
DECISION_TYPE_INDETERMINATE = "Indeterminate"
73127

128+
129+
# consent attributes determine wether consent has been given and under
130+
# what conditions
131+
132+
# no claim to consent is made
74133
CONSENT_UNSPECIFIED = "urn:oasis:names:tc:SAML:2.0:consent:unspecified"
134+
# consent has been obtained
75135
CONSENT_OBTAINED = "urn:oasis:names:tc:SAML:2.0:consent:obtained"
136+
# consent has been obtained before the message has been initiated
76137
CONSENT_PRIOR = "urn:oasis:names:tc:SAML:2.0:consent:prior"
138+
# consent has been obtained implicitly
77139
CONSENT_IMPLICIT = "urn:oasis:names:tc:SAML:2.0:consent:current-implicit"
140+
# consent has been obtained explicitly
78141
CONSENT_EXPLICIT = "urn:oasis:names:tc:SAML:2.0:consent:current-explicit"
142+
# no consent has been obtained
79143
CONSENT_UNAVAILABLE = "urn:oasis:names:tc:SAML:2.0:consent:unavailable"
144+
# no consent is needed.
80145
CONSENT_INAPPLICABLE = "urn:oasis:names:tc:SAML:2.0:consent:inapplicable"
81146

147+
148+
# Subject confirmation methods(scm), can be issued, besides the subject itself
149+
# by third parties.
150+
# http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0.pdf
151+
152+
# the 3rd party is identified on behalf of the subject given private/public key
82153
SCM_HOLDER_OF_KEY = "urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"
154+
# the 3rd party is identified by subject confirmation and must include a security header
155+
# signing its content.
83156
SCM_SENDER_VOUCHES = "urn:oasis:names:tc:SAML:2.0:cm:sender-vouches"
157+
# a bearer token is issued instead.
84158
SCM_BEARER = "urn:oasis:names:tc:SAML:2.0:cm:bearer"
85159

86-
XSD = "xs"
87-
NS_SOAP_ENC = "http://schemas.xmlsoap.org/soap/encoding/"
88-
89160

90161
class AttributeValueBase(SamlBase):
91162
def __init__(self,

0 commit comments

Comments
 (0)