File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 1010from .authority import Authority
1111from .mex import send_request as mex_send_request
1212from .wstrust_request import send_request as wst_send_request
13- from .wstrust_response import SAML_TOKEN_TYPE_V1 , SAML_TOKEN_TYPE_V2
13+ from .wstrust_response import *
1414from .token_cache import TokenCache
1515
1616
@@ -405,9 +405,12 @@ def _acquire_token_by_username_password_federated(
405405 wstrust_endpoint .get ("action" ), verify = verify , proxies = proxies )
406406 if not ("token" in wstrust_result and "type" in wstrust_result ):
407407 raise RuntimeError ("Unsuccessful RSTR. %s" % wstrust_result )
408+ GRANT_TYPE_SAML1_1 = 'urn:ietf:params:oauth:grant-type:saml1_1-bearer'
408409 grant_type = {
409- SAML_TOKEN_TYPE_V1 : 'urn:ietf:params:oauth:grant-type:saml1_1-bearer' ,
410+ SAML_TOKEN_TYPE_V1 : GRANT_TYPE_SAML1_1 ,
410411 SAML_TOKEN_TYPE_V2 : self .client .GRANT_TYPE_SAML2 ,
412+ WSS_SAML_TOKEN_PROFILE_V1_1 : GRANT_TYPE_SAML1_1 ,
413+ WSS_SAML_TOKEN_PROFILE_V2 : self .client .GRANT_TYPE_SAML2
411414 }.get (wstrust_result .get ("type" ))
412415 if not grant_type :
413416 raise RuntimeError (
Original file line number Diff line number Diff line change 3737SAML_TOKEN_TYPE_V1 = 'urn:oasis:names:tc:SAML:1.0:assertion'
3838SAML_TOKEN_TYPE_V2 = 'urn:oasis:names:tc:SAML:2.0:assertion'
3939
40+ # http://docs.oasis-open.org/wss-m/wss/v1.1.1/os/wss-SAMLTokenProfile-v1.1.1-os.html#_Toc307397288
41+ WSS_SAML_TOKEN_PROFILE_V1_1 = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
42+ WSS_SAML_TOKEN_PROFILE_V2 = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0"
43+
4044def parse_response (body ): # Returns {"token": "<saml:assertion ...>", "type": "..."}
4145 token = parse_token_by_re (body )
4246 if token :
@@ -84,6 +88,5 @@ def parse_token_by_re(raw_response): # Returns the saml:assertion
8488 token_types = findall_content (rstr , "TokenType" )
8589 tokens = findall_content (rstr , "RequestedSecurityToken" )
8690 if token_types and tokens :
87- assert token_types [0 ] in (SAML_TOKEN_TYPE_V1 , SAML_TOKEN_TYPE_V2 )
8891 return {"token" : tokens [0 ].encode ('us-ascii' ), "type" : token_types [0 ]}
8992
You can’t perform that action at this time.
0 commit comments