1717office365 .logger .ensure_debug_secrets ()
1818
1919
20- def resolve_base_url (url ):
21- parts = url .split ("://" )
22- host_name = parts [1 ].split ("/" )[0 ]
23- return parts [0 ] + "://" + host_name
24-
25-
2620def string_escape (value ):
2721 value = value .replace ("&" , "&" )
2822 value = value .replace ("<" , "<" )
@@ -37,7 +31,7 @@ def datetime_escape(value):
3731
3832
3933class SamlTokenProvider (AuthenticationProvider , office365 .logger .LoggerContext ):
40- def __init__ (self , url , username , password , browser_mode , environment = "commercial" ):
34+ def __init__ (self , url , username , password , browser_mode , environment = None ):
4135 """
4236 SAML Security Token Service provider (claims-based authentication)
4337
@@ -46,13 +40,11 @@ def __init__(self, url, username, password, browser_mode, environment="commercia
4640 :param str password: The password
4741 :param bool browser_mode:
4842 :param str environment: The Office 365 Cloud Environment endpoint used for authentication.
49- By default, this will be set to commercial ('commercial', 'GCCH')
5043 """
5144 # Security Token Service info
52- self ._sts_profile = STSProfile (resolve_base_url ( url ) , environment )
45+ self ._sts_profile = STSProfile (url , environment )
5346 # Obtain authentication cookies, using the browser mode
5447 self ._browser_mode = browser_mode
55- self ._environment = environment
5648 # Last occurred error
5749 self .error = ""
5850 self ._username = username
@@ -137,7 +129,7 @@ def _acquire_service_token_from_adfs(self, adfs_url):
137129 "password" : string_escape (self ._password ),
138130 "created" : datetime_escape (self ._sts_profile .created ),
139131 "expires" : datetime_escape (self ._sts_profile .expires ),
140- "issuer" : self ._sts_profile .tokenIssuer ,
132+ "issuer" : self ._sts_profile .token_issuer ,
141133 },
142134 )
143135
@@ -184,13 +176,13 @@ def _acquire_service_token(self):
184176 payload = self ._prepare_request_from_template (
185177 "SAML.xml" ,
186178 {
187- "auth_url" : self ._sts_profile .authorityUrl ,
179+ "auth_url" : self ._sts_profile .site_url ,
188180 "username" : string_escape (self ._username ),
189181 "password" : string_escape (self ._password ),
190182 "message_id" : str (uuid .uuid4 ()),
191183 "created" : datetime_escape (self ._sts_profile .created ),
192184 "expires" : datetime_escape (self ._sts_profile .expires ),
193- "issuer" : self ._sts_profile .tokenIssuer ,
185+ "issuer" : self ._sts_profile .token_issuer ,
194186 },
195187 )
196188 logger .debug_secrets ("options: %s" , payload )
0 commit comments