Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cbe98f3
Initial commit
abhidnya13 Feb 25, 2020
e64332f
Iteration 1
abhidnya13 Mar 5, 2020
2a7d5e3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
abhidnya13 Mar 5, 2020
aed0e8d
Iteration 2 rectifying tests
abhidnya13 Mar 6, 2020
30f7d99
Iteration 3 modifying some more failing tests
abhidnya13 Mar 6, 2020
34e8e16
Iteration 4
abhidnya13 Mar 7, 2020
f60bbb5
Removing tests whose implementation was removed
abhidnya13 Mar 7, 2020
d54fb8b
Iteration 5
abhidnya13 Mar 7, 2020
be389d5
Replacing generic exception to specific Http error
abhidnya13 Mar 9, 2020
dcec4af
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
abhidnya13 Mar 16, 2020
e37f0c3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
abhidnya13 Mar 16, 2020
b3a4e09
Refactor according to new interface
abhidnya13 Mar 20, 2020
96988f8
Changing one reference to new interface left in the previous one
abhidnya13 Mar 20, 2020
1d05615
Modified one more missed change
abhidnya13 Mar 20, 2020
ccafcf9
Few more changes and refactor
abhidnya13 Mar 20, 2020
2670e25
Adding raw response to response object
abhidnya13 Mar 20, 2020
cb70a37
Cleaning None values
abhidnya13 Mar 23, 2020
53520fd
PR review iteration
abhidnya13 Mar 26, 2020
293b081
Removing default http client
abhidnya13 Mar 30, 2020
fcac05e
cleaning up
abhidnya13 Mar 30, 2020
229ad26
Adding deleted single empty line back
abhidnya13 Mar 30, 2020
340210f
Updating filtering of non values from dictionary
abhidnya13 Mar 30, 2020
ca8a129
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
abhidnya13 Apr 7, 2020
d993950
Capturing editorial changes
abhidnya13 Apr 13, 2020
e5ebd28
Review changes 1
abhidnya13 Apr 16, 2020
8901269
Fixing broken test
abhidnya13 Apr 16, 2020
7774be8
Cleaning up
abhidnya13 Apr 16, 2020
42ca7a2
PR review changes part 1
abhidnya13 Apr 17, 2020
d38d38d
PR review changes part 2
abhidnya13 Apr 17, 2020
3226bc4
PR review changes part 3
abhidnya13 Apr 17, 2020
90afb94
Minor indent change
abhidnya13 Apr 17, 2020
a1ce0d1
PR review changes part 4
abhidnya13 Apr 20, 2020
ad245a7
Adding back accidentally deleted blank line
abhidnya13 Apr 20, 2020
34bb127
Removing extra indent
abhidnya13 Apr 20, 2020
a745949
Minor line add in authority.py
abhidnya13 Apr 20, 2020
b636baa
Making changes for backward compatibility
abhidnya13 Apr 20, 2020
d24d575
Some more editorial changes
abhidnya13 Apr 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PR review changes part 1
  • Loading branch information
abhidnya13 committed Apr 17, 2020
commit 42ca7a2294804815ed8db35cb0673105d54debf2
20 changes: 11 additions & 9 deletions msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def __init__(
self.app_version = app_version
self.authority = Authority(
authority or "https://login.microsoftonline.com/common/",
http_client=self.http_client, validate_authority=validate_authority)
self.http_client, validate_authority=validate_authority)
# Here the self.authority is not the same type as authority in input
self.token_cache = token_cache or TokenCache()
self.client = self._build_client(client_credential, self.authority)
Expand Down Expand Up @@ -284,12 +284,14 @@ def get_authorization_request_url(
# The previous implementation is, it will use self.authority by default.
# Multi-tenant app can use new authority on demand
the_authority = Authority(
authority, http_client=self.http_client
authority,
self.http_client
) if authority else self.authority

client = Client(
{"authorization_endpoint": the_authority.authorization_endpoint},
self.client_id, http_client=self.http_client)
self.client_id,
self.http_client)
return client.build_auth_request_uri(
response_type=response_type,
redirect_uri=redirect_uri, state=state, login_hint=login_hint,
Expand Down Expand Up @@ -398,9 +400,8 @@ def _get_authority_aliases(self, instance):
"https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=https://login.microsoftonline.com/common/oauth2/authorize",
headers={'Accept': 'application/json'})
resp.raise_for_status()
resp = json.loads(resp.text)
self.authority_groups = [
set(group['aliases']) for group in resp['metadata']]
set(group['aliases']) for group in json.loads(resp.text)['metadata']]
for group in self.authority_groups:
if instance in group:
return [alias for alias in group if alias != instance]
Expand Down Expand Up @@ -519,7 +520,7 @@ def acquire_token_silent_with_error(
warnings.warn("We haven't decided how/if this method will accept authority parameter")
# the_authority = Authority(
# authority,
# http_client=self.http_client,
# self.http_client,
# ) if authority else self.authority
result = self._acquire_token_silent_from_cache_and_possibly_refresh_it(
scopes, account, self.authority, force_refresh=force_refresh,
Expand All @@ -531,7 +532,8 @@ def acquire_token_silent_with_error(
for alias in self._get_authority_aliases(self.authority.instance):
the_authority = Authority(
"https://" + alias + "/" + self.authority.tenant,
http_client=self.http_client, validate_authority=False)
self.http_client,
validate_authority=False)
result = self._acquire_token_silent_from_cache_and_possibly_refresh_it(
scopes, account, the_authority, force_refresh=force_refresh,
correlation_id=correlation_id,
Expand Down Expand Up @@ -778,7 +780,7 @@ def _acquire_token_by_username_password_federated(
if user_realm_result.get("federation_metadata_url"):
wstrust_endpoint = mex_send_request(
user_realm_result["federation_metadata_url"],
http_client=self.http_client)
self.http_client)
if wstrust_endpoint is None:
raise ValueError("Unable to find wstrust endpoint from MEX. "
"This typically happens when attempting MSA accounts. "
Expand All @@ -790,7 +792,7 @@ def _acquire_token_by_username_password_federated(
wstrust_endpoint.get("address",
# Fallback to an AAD supplied endpoint
user_realm_result.get("federation_active_auth_url")),
wstrust_endpoint.get("action"), http_client=self.http_client)
wstrust_endpoint.get("action"), self.http_client)
if not ("token" in wstrust_result and "type" in wstrust_result):
raise RuntimeError("Unsuccessful RSTR. %s" % wstrust_result)
GRANT_TYPE_SAML1_1 = 'urn:ietf:params:oauth:grant-type:saml1_1-bearer'
Expand Down
8 changes: 5 additions & 3 deletions msal/authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ def canonicalize(authority_url):
return authority, authority.hostname, parts[1]

def instance_discovery(url, http_client, **kwargs):
resp = http_client.get('https://{}/common/discovery/instance'.format(
resp = http_client.get( # Note: This URL seemingly returns V1 endpoint only
'https://{}/common/discovery/instance'.format(
WORLD_WIDE # Historically using WORLD_WIDE. Could use self.instance too
# See https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/4.0.0/src/Microsoft.Identity.Client/Instance/AadInstanceDiscovery.cs#L101-L103
# and https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/4.0.0/src/Microsoft.Identity.Client/Instance/AadAuthority.cs#L19-L33
), params={'authorization_endpoint': url, 'api-version': '1.0'},
**kwargs)
),
params={'authorization_endpoint': url, 'api-version': '1.0'},
**kwargs)
return json.loads(resp.text)

def tenant_discovery(tenant_discovery_endpoint, http_client, **kwargs):
Expand Down