|
3 | 3 | #
|
4 | 4 | # Generated Mon May 2 14:23:33 2011 by parse_xsd.py version 0.4.
|
5 | 5 | #
|
| 6 | +# saml core specifications to be found at: |
| 7 | +# if any question arise please query the following pdf. |
| 8 | +# http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf |
| 9 | +# |
| 10 | + |
| 11 | + |
6 | 12 | import base64
|
7 | 13 |
|
8 | 14 | from saml2.validate import valid_ipv4, MustValueError
|
|
17 | 23 | from saml2 import xmldsig as ds
|
18 | 24 | from saml2 import xmlenc as xenc
|
19 | 25 |
|
| 26 | +# authentication information fields |
20 | 27 | NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:assertion'
|
21 | 28 |
|
22 |
| -XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance' |
| 29 | +# xmlschema definition |
| 30 | +XSD = "xs" |
| 31 | +# xmlschema templates and extensions |
23 | 32 | XS_NAMESPACE = 'http://www.w3.org/2001/XMLSchema'
|
24 |
| - |
| 33 | +# xmlschema-instance, which contains several builtin attributes |
| 34 | +XSI_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance' |
| 35 | +# xml soap namespace |
| 36 | +NS_SOAP_ENC = "http://schemas.xmlsoap.org/soap/encoding/" |
| 37 | +# type definitions for xmlschemas |
25 | 38 | XSI_TYPE = '{%s}type' % XSI_NAMESPACE
|
| 39 | +# nil type definition for xmlschemas |
26 | 40 | XSI_NIL = '{%s}nil' % XSI_NAMESPACE
|
27 | 41 |
|
| 42 | +# idp and sp communicate usually about a subject(NameID) |
| 43 | +# the format determines the category the subject is in |
| 44 | + |
| 45 | +# custom subject |
28 | 46 | NAMEID_FORMAT_UNSPECIFIED = (
|
29 | 47 | "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified")
|
| 48 | +# subject as email address |
30 | 49 | NAMEID_FORMAT_EMAILADDRESS = (
|
31 | 50 | "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress")
|
| 51 | +# subject as x509 key |
32 | 52 | NAMEID_FORMAT_X509SUBJECTNAME = (
|
33 | 53 | "urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName")
|
| 54 | +# subject as windows domain name |
34 | 55 | NAMEID_FORMAT_WINDOWSDOMAINQUALIFIEDNAME = (
|
35 | 56 | "urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName")
|
| 57 | +# subject from a kerberos instance |
36 | 58 | NAMEID_FORMAT_KERBEROS = (
|
37 | 59 | "urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos")
|
| 60 | +# subject as name |
38 | 61 | NAMEID_FORMAT_ENTITY = (
|
39 | 62 | "urn:oasis:names:tc:SAML:2.0:nameid-format:entity")
|
| 63 | +# linked subject |
40 | 64 | NAMEID_FORMAT_PERSISTENT = (
|
41 | 65 | "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent")
|
| 66 | +# annonymous subject |
42 | 67 | NAMEID_FORMAT_TRANSIENT = (
|
43 | 68 | "urn:oasis:names:tc:SAML:2.0:nameid-format:transient")
|
| 69 | +# subject avaiable in encrypted format |
44 | 70 | NAMEID_FORMAT_ENCRYPTED = (
|
45 | 71 | "urn:oasis:names:tc:SAML:2.0:nameid-format:encrypted")
|
| 72 | +# dicc for avaiable formats |
46 | 73 | NAMEID_FORMATS_SAML2 = (
|
47 | 74 | ('NAMEID_FORMAT_EMAILADDRESS', NAMEID_FORMAT_EMAILADDRESS),
|
48 | 75 | ('NAMEID_FORMAT_ENCRYPTED', NAMEID_FORMAT_ENCRYPTED),
|
|
51 | 78 | ('NAMEID_FORMAT_TRANSIENT', NAMEID_FORMAT_TRANSIENT),
|
52 | 79 | ('NAMEID_FORMAT_UNSPECIFIED', NAMEID_FORMAT_UNSPECIFIED),
|
53 | 80 | )
|
| 81 | + |
| 82 | +# a profile outlines a set of rules describing how to embed SAML assertions. |
| 83 | +# https://docs.oasis-open.org/security/saml/v2.0/saml-profiles-2.0-os.pdf |
| 84 | + |
| 85 | +# XML based values for SAML attributes |
54 | 86 | PROFILE_ATTRIBUTE_BASIC = (
|
55 | 87 | "urn:oasis:names:tc:SAML:2.0:profiles:attribute:basic")
|
56 | 88 |
|
| 89 | +# an AuthnRequest is made to initiate authentication |
| 90 | +# TODO: it is not clear that the request sets the context |
| 91 | +# for the AuthnRequest, maybe rename to AUTHN_CONTEXT_PASSWORD |
| 92 | + |
| 93 | +# authenticate the request with login credentials |
57 | 94 | AUTHN_PASSWORD = "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"
|
| 95 | +# authenticate the request with login credentials, over tls/https |
58 | 96 | AUTHN_PASSWORD_PROTECTED = \
|
59 | 97 | "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
|
60 | 98 |
|
| 99 | +# attribute statements is key:value metadata shared with your app |
| 100 | + |
| 101 | +# custom format |
61 | 102 | NAME_FORMAT_UNSPECIFIED = (
|
62 | 103 | "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified")
|
| 104 | +# uri format |
63 | 105 | NAME_FORMAT_URI = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
|
| 106 | +# XML-based format |
64 | 107 | NAME_FORMAT_BASIC = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"
|
| 108 | +# dicc for avaiable formats |
65 | 109 | NAME_FORMATS_SAML2 = (
|
66 | 110 | ('NAME_FORMAT_BASIC', NAME_FORMAT_BASIC),
|
67 | 111 | ('NAME_FORMAT_URI', NAME_FORMAT_URI),
|
68 | 112 | ('NAME_FORMAT_UNSPECIFIED', NAME_FORMAT_UNSPECIFIED),
|
69 | 113 | )
|
| 114 | + |
| 115 | +# the SAML authority's decision can be predetermined by arbitrary context |
| 116 | + |
| 117 | +# the specified action is permitted |
70 | 118 | DECISION_TYPE_PERMIT = "Permit"
|
| 119 | +# the specified action is denied |
71 | 120 | DECISION_TYPE_DENY = "Deny"
|
| 121 | +# the SAML authority cannot determine if the action is permitted or denied |
72 | 122 | DECISION_TYPE_INDETERMINATE = "Indeterminate"
|
73 | 123 |
|
| 124 | + |
| 125 | +# consent attributes determine wether consent has been given and under |
| 126 | +# what conditions |
| 127 | + |
| 128 | +# no claim to consent is made |
74 | 129 | CONSENT_UNSPECIFIED = "urn:oasis:names:tc:SAML:2.0:consent:unspecified"
|
| 130 | +# consent has been obtained |
75 | 131 | CONSENT_OBTAINED = "urn:oasis:names:tc:SAML:2.0:consent:obtained"
|
| 132 | +# consent has been obtained before the message has been initiated |
76 | 133 | CONSENT_PRIOR = "urn:oasis:names:tc:SAML:2.0:consent:prior"
|
| 134 | +# consent has been obtained implicitly |
77 | 135 | CONSENT_IMPLICIT = "urn:oasis:names:tc:SAML:2.0:consent:current-implicit"
|
| 136 | +# consent has been obtained explicitly |
78 | 137 | CONSENT_EXPLICIT = "urn:oasis:names:tc:SAML:2.0:consent:current-explicit"
|
| 138 | +# no consent has been obtained |
79 | 139 | CONSENT_UNAVAILABLE = "urn:oasis:names:tc:SAML:2.0:consent:unavailable"
|
| 140 | +# no consent is needed. |
80 | 141 | CONSENT_INAPPLICABLE = "urn:oasis:names:tc:SAML:2.0:consent:inapplicable"
|
81 | 142 |
|
| 143 | + |
| 144 | +# Subject confirmation methods(scm), can be issued, besides the subject itself |
| 145 | +# by third parties. |
| 146 | +# http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0.pdf |
| 147 | + |
| 148 | +# the 3rd party is identified on behalf of the subject given private/public key |
82 | 149 | SCM_HOLDER_OF_KEY = "urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"
|
| 150 | +# the 3rd party is identified by subject confirmation and must include a security header |
| 151 | +# signing its content. |
83 | 152 | SCM_SENDER_VOUCHES = "urn:oasis:names:tc:SAML:2.0:cm:sender-vouches"
|
| 153 | +# a bearer token is issued instead. |
84 | 154 | SCM_BEARER = "urn:oasis:names:tc:SAML:2.0:cm:bearer"
|
85 | 155 |
|
86 |
| -XSD = "xs" |
87 |
| -NS_SOAP_ENC = "http://schemas.xmlsoap.org/soap/encoding/" |
88 |
| - |
89 | 156 |
|
90 | 157 | class AttributeValueBase(SamlBase):
|
91 | 158 | def __init__(self,
|
|
0 commit comments