| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
SP_SOAP_RESPONSE = b"""<S:Envelope |
| 14 |
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> |
| 15 |
<S:Header> |
| 16 |
<paos:Request xmlns:paos="urn:liberty:paos:2003-08" |
| 17 |
S:actor="http://schemas.xmlsoap.org/soap/actor/next" |
| 18 |
S:mustUnderstand="1" |
| 19 |
responseConsumerURL="https://openstack4.local/Shibboleth.sso/SAML2/ECP" |
| 20 |
service="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp"/> |
| 21 |
<ecp:Request xmlns:ecp="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp" |
| 22 |
IsPassive="0" S:actor="http://schemas.xmlsoap.org/soap/actor/next" |
| 23 |
S:mustUnderstand="1"> |
| 24 |
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> |
| 25 |
https://openstack4.local/shibboleth |
| 26 |
</saml:Issuer> |
| 27 |
<samlp:IDPList xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"> |
| 28 |
<samlp:IDPEntry ProviderID="https://idp.testshib.org/idp/shibboleth"/> |
| 29 |
</samlp:IDPList></ecp:Request> |
| 30 |
<ecp:RelayState xmlns:ecp="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp" |
| 31 |
S:actor="http://schemas.xmlsoap.org/soap/actor/next" S:mustUnderstand="1"> |
| 32 |
ss:mem:6f1f20fafbb38433467e9d477df67615</ecp:RelayState> |
| 33 |
</S:Header><S:Body><samlp:AuthnRequest |
| 34 |
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" |
| 35 |
AssertionConsumerServiceURL="https://openstack4.local/Shibboleth.sso/SAML2/ECP" |
| 36 |
ID="_a07186e3992e70e92c17b9d249495643" IssueInstant="2014-06-09T09:48:57Z" |
| 37 |
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:PAOS" Version="2.0"> |
| 38 |
<saml:Issuer |
| 39 |
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> |
| 40 |
https://openstack4.local/shibboleth |
| 41 |
</saml:Issuer><samlp:NameIDPolicy AllowCreate="1"/><samlp:Scoping> |
| 42 |
<samlp:IDPList> |
| 43 |
<samlp:IDPEntry ProviderID="https://idp.testshib.org/idp/shibboleth"/> |
| 44 |
</samlp:IDPList></samlp:Scoping></samlp:AuthnRequest></S:Body></S:Envelope> |
| 45 |
""" |
| 46 |
|
| 47 |
|
| 48 |
SAML2_ASSERTION = b"""<?xml version="1.0" encoding="UTF-8"?> |
| 49 |
<soap11:Envelope xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"> |
| 50 |
<soap11:Header> |
| 51 |
<ecp:Response xmlns:ecp="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp" |
| 52 |
AssertionConsumerServiceURL="https://openstack4.local/Shibboleth.sso/SAML2/ECP" |
| 53 |
soap11:actor="http://schemas.xmlsoap.org/soap/actor/next" |
| 54 |
soap11:mustUnderstand="1"/> |
| 55 |
<samlec:GeneratedKey xmlns:samlec="urn:ietf:params:xml:ns:samlec" |
| 56 |
soap11:actor="http://schemas.xmlsoap.org/soap/actor/next"> |
| 57 |
x= |
| 58 |
</samlec:GeneratedKey> |
| 59 |
</soap11:Header> |
| 60 |
<soap11:Body> |
| 61 |
<saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" |
| 62 |
Destination="https://openstack4.local/Shibboleth.sso/SAML2/ECP" |
| 63 |
ID="_bbbe6298d7ee586c915d952013875440" |
| 64 |
InResponseTo="_a07186e3992e70e92c17b9d249495643" |
| 65 |
IssueInstant="2014-06-09T09:48:58.945Z" Version="2.0"> |
| 66 |
<saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" |
| 67 |
Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"> |
| 68 |
https://idp.testshib.org/idp/shibboleth |
| 69 |
</saml2:Issuer><saml2p:Status> |
| 70 |
<saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/> |
| 71 |
</saml2p:Status> |
| 72 |
<saml2:EncryptedAssertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"> |
| 73 |
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" |
| 74 |
Id="_e5215ac77a6028a8da8caa8be89bad44" |
| 75 |
Type="http://www.w3.org/2001/04/xmlenc#Element"> |
| 76 |
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc" |
| 77 |
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"/> |
| 78 |
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> |
| 79 |
<xenc:EncryptedKey Id="_204349856f6e73c9480afc949d1b4643" |
| 80 |
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> |
| 81 |
<xenc:EncryptionMethod |
| 82 |
Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" |
| 83 |
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> |
| 84 |
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" |
| 85 |
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/> |
| 86 |
</xenc:EncryptionMethod><ds:KeyInfo><ds:X509Data><ds:X509Certificate> |
| 87 |
</ds:X509Certificate> |
| 88 |
</ds:X509Data></ds:KeyInfo> |
| 89 |
<xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> |
| 90 |
<xenc:CipherValue>VALUE==</xenc:CipherValue></xenc:CipherData> |
| 91 |
</xenc:EncryptedKey></ds:KeyInfo> |
| 92 |
<xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> |
| 93 |
<xenc:CipherValue>VALUE=</xenc:CipherValue></xenc:CipherData> |
| 94 |
</xenc:EncryptedData></saml2:EncryptedAssertion></saml2p:Response> |
| 95 |
</soap11:Body></soap11:Envelope> |
| 96 |
""" |
| 97 |
|
| 98 |
UNSCOPED_TOKEN_HEADER = 'UNSCOPED_TOKEN' |
| 99 |
|
| 100 |
UNSCOPED_TOKEN = { |
| 101 |
"token": { |
| 102 |
"issued_at": "2014-06-09T09:48:59.643406Z", |
| 103 |
"extras": {}, |
| 104 |
"methods": ["saml2"], |
| 105 |
"expires_at": "2014-06-09T10:48:59.643375Z", |
| 106 |
"user": { |
| 107 |
"OS-FEDERATION": { |
| 108 |
"identity_provider": { |
| 109 |
"id": "testshib" |
| 110 |
}, |
| 111 |
"protocol": { |
| 112 |
"id": "saml2" |
| 113 |
}, |
| 114 |
"groups": [ |
| 115 |
{"id": "1764fa5cf69a49a4918131de5ce4af9a"} |
| 116 |
] |
| 117 |
}, |
| 118 |
"id": "testhib%20user", |
| 119 |
"name": "testhib user" |
| 120 |
} |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
PROJECTS = { |
| 125 |
"projects": [ |
| 126 |
{ |
| 127 |
"domain_id": "37ef61", |
| 128 |
"enabled": 'true', |
| 129 |
"id": "12d706", |
| 130 |
"links": { |
| 131 |
"self": "http://identity:35357/v3/projects/12d706" |
| 132 |
}, |
| 133 |
"name": "a project name" |
| 134 |
}, |
| 135 |
{ |
| 136 |
"domain_id": "37ef61", |
| 137 |
"enabled": 'true', |
| 138 |
"id": "9ca0eb", |
| 139 |
"links": { |
| 140 |
"self": "http://identity:35357/v3/projects/9ca0eb" |
| 141 |
}, |
| 142 |
"name": "another project" |
| 143 |
} |
| 144 |
], |
| 145 |
"links": { |
| 146 |
"self": "http://identity:35357/v3/auth/projects", |
| 147 |
"previous": 'null', |
| 148 |
"next": 'null' |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
DOMAINS = { |
| 153 |
"domains": [ |
| 154 |
{ |
| 155 |
"description": "desc of domain", |
| 156 |
"enabled": 'true', |
| 157 |
"id": "37ef61", |
| 158 |
"links": { |
| 159 |
"self": "http://identity:35357/v3/domains/37ef61" |
| 160 |
}, |
| 161 |
"name": "my domain" |
| 162 |
} |
| 163 |
], |
| 164 |
"links": { |
| 165 |
"self": "http://identity:35357/v3/auth/domains", |
| 166 |
"previous": 'null', |
| 167 |
"next": 'null' |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
SAML_ENCODING = "<?xml version='1.0' encoding='UTF-8'?>" |
| 172 |
|
| 173 |
TOKEN_SAML_RESPONSE = """ |
| 174 |
<ns2:Response Destination="http://beta.example.com/Shibboleth.sso/POST/ECP" |
| 175 |
ID="8c21de08d2f2435c9acf13e72c982846" |
| 176 |
IssueInstant="2015-03-25T14:43:21Z" |
| 177 |
Version="2.0"> |
| 178 |
<saml:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"> |
| 179 |
http://keystone.idp/v3/OS-FEDERATION/saml2/idp |
| 180 |
</saml:Issuer> |
| 181 |
<ns2:Status> |
| 182 |
<ns2:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/> |
| 183 |
</ns2:Status> |
| 184 |
<saml:Assertion ID="a5f02efb0bff4044b294b4583c7dfc5d" |
| 185 |
IssueInstant="2015-03-25T14:43:21Z" Version="2.0"> |
| 186 |
<saml:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"> |
| 187 |
http://keystone.idp/v3/OS-FEDERATION/saml2/idp</saml:Issuer> |
| 188 |
<xmldsig:Signature> |
| 189 |
<xmldsig:SignedInfo> |
| 190 |
<xmldsig:CanonicalizationMethod |
| 191 |
Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> |
| 192 |
<xmldsig:SignatureMethod |
| 193 |
Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> |
| 194 |
<xmldsig:Reference URI="#a5f02efb0bff4044b294b4583c7dfc5d"> |
| 195 |
<xmldsig:Transforms> |
| 196 |
<xmldsig:Transform |
| 197 |
Algorithm="http://www.w3.org/2000/09/xmldsig# |
| 198 |
enveloped-signature"/> |
| 199 |
<xmldsig:Transform |
| 200 |
Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> |
| 201 |
</xmldsig:Transforms> |
| 202 |
<xmldsig:DigestMethod |
| 203 |
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> |
| 204 |
<xmldsig:DigestValue> |
| 205 |
0KH2CxdkfzU+6eiRhTC+mbObUKI= |
| 206 |
</xmldsig:DigestValue> |
| 207 |
</xmldsig:Reference> |
| 208 |
</xmldsig:SignedInfo> |
| 209 |
<xmldsig:SignatureValue> |
| 210 |
m2jh5gDvX/1k+4uKtbb08CHp2b9UWsLw |
| 211 |
</xmldsig:SignatureValue> |
| 212 |
<xmldsig:KeyInfo> |
| 213 |
<xmldsig:X509Data> |
| 214 |
<xmldsig:X509Certificate>...</xmldsig:X509Certificate> |
| 215 |
</xmldsig:X509Data> |
| 216 |
</xmldsig:KeyInfo> |
| 217 |
</xmldsig:Signature> |
| 218 |
<saml:Subject> |
| 219 |
<saml:NameID>admin</saml:NameID> |
| 220 |
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"> |
| 221 |
<saml:SubjectConfirmationData |
| 222 |
NotOnOrAfter="2015-03-25T15:43:21.172385Z" |
| 223 |
Recipient="http://beta.example.com/Shibboleth.sso/POST/ECP"/> |
| 224 |
</saml:SubjectConfirmation> |
| 225 |
</saml:Subject> |
| 226 |
<saml:AuthnStatement AuthnInstant="2015-03-25T14:43:21Z" |
| 227 |
SessionIndex="9790eb729858456f8a33b7a11f0a637e" |
| 228 |
SessionNotOnOrAfter="2015-03-25T15:43:21.172385Z"> |
| 229 |
<saml:AuthnContext> |
| 230 |
<saml:AuthnContextClassRef> |
| 231 |
urn:oasis:names:tc:SAML:2.0:ac:classes:Password |
| 232 |
</saml:AuthnContextClassRef> |
| 233 |
<saml:AuthenticatingAuthority> |
| 234 |
http://keystone.idp/v3/OS-FEDERATION/saml2/idp |
| 235 |
</saml:AuthenticatingAuthority> |
| 236 |
</saml:AuthnContext> |
| 237 |
</saml:AuthnStatement> |
| 238 |
<saml:AttributeStatement> |
| 239 |
<saml:Attribute Name="openstack_user" |
| 240 |
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> |
| 241 |
<saml:AttributeValue xsi:type="xs:string">admin</saml:AttributeValue> |
| 242 |
</saml:Attribute> |
| 243 |
<saml:Attribute Name="openstack_roles" |
| 244 |
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> |
| 245 |
<saml:AttributeValue xsi:type="xs:string">admin</saml:AttributeValue> |
| 246 |
</saml:Attribute> |
| 247 |
<saml:Attribute Name="openstack_project" |
| 248 |
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> |
| 249 |
<saml:AttributeValue xsi:type="xs:string">admin</saml:AttributeValue> |
| 250 |
</saml:Attribute> |
| 251 |
</saml:AttributeStatement> |
| 252 |
</saml:Assertion> |
| 253 |
</ns2:Response> |
| 254 |
""" |
| 255 |
|
| 256 |
TOKEN_BASED_SAML = ''.join([SAML_ENCODING, TOKEN_SAML_RESPONSE]) |
| 257 |
|
| 258 |
ECP_ENVELOPE = """ |
| 259 |
<ns0:Envelope |
| 260 |
xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" |
| 261 |
xmlns:ns1="urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp" |
| 262 |
xmlns:ns2="urn:oasis:names:tc:SAML:2.0:protocol" |
| 263 |
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" |
| 264 |
xmlns:xmldsig="http://www.w3.org/2000/09/xmldsig#" |
| 265 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
| 266 |
<ns0:Header> |
| 267 |
<ns1:RelayState |
| 268 |
ns0:actor="http://schemas.xmlsoap.org/soap/actor/next" |
| 269 |
ns0:mustUnderstand="1"> |
| 270 |
ss:mem:1ddfe8b0f58341a5a840d2e8717b0737 |
| 271 |
</ns1:RelayState> |
| 272 |
</ns0:Header> |
| 273 |
<ns0:Body> |
| 274 |
{0} |
| 275 |
</ns0:Body> |
| 276 |
</ns0:Envelope> |
| 277 |
""".format(TOKEN_SAML_RESPONSE) |
| 278 |
|
| 279 |
TOKEN_BASED_ECP = ''.join([SAML_ENCODING, ECP_ENVELOPE]) |