Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Add support for dSTS enpoints #164

Merged
merged 10 commits into from
Aug 30, 2018
Merged

Add support for dSTS enpoints #164

merged 10 commits into from
Aug 30, 2018

Conversation

jmstimso
Copy link
Contributor

Add support for dSTS by white-listing dSTS domains so that this library can be used to request Oauth2 tokens from dSTS.

jmstimso added 6 commits July 10, 2018 18:18
add whitelist function so dsts hosts pass validation.
Adding unit test to test static instance discovery of dsts enpoints and validating of a dsts endpoint in AuthenticationContext.
@msftclas
Copy link

msftclas commented Jul 16, 2018

CLA assistant check
All CLA requirements met.

@abhidnya13 abhidnya13 requested review from abhidnya13 and rayluo July 30, 2018 22:31
@jmstimso
Copy link
Contributor Author

jmstimso commented Aug 22, 2018

Copy link
Collaborator

@rayluo rayluo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contribution! Added some suggestions below.

@@ -84,11 +90,14 @@ def _parse_authority(self):
self._tenant = path_parts[1]
except IndexError:
raise ValueError("Could not determine tenant.")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: would you mind remove the unnecessary space(s) introduced in this PR? See the explanation in another comment below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary space

@@ -118,7 +127,7 @@ def _perform_dynamic_instance_discovery(self):
operation = "Instance Discovery"
self._log.debug("Attempting instance discover at: %(discovery_endpoint)s",
{"discovery_endpoint": discovery_endpoint.geturl()})

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: would you mind remove the unnecessary space(s) introduced in this PR? Currently they are displayed as changes in this github PR page and then become a distraction during Code Review, twice: one time in this PR review, and another time in future when another person modify this file again and his/her editor is configured to trim trailing spaces automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary space

@@ -215,6 +215,14 @@ class AADConstants(object):
'login.microsoftonline.us',
'login.microsoftonline.de',
]
WHITELISTED_DOMAINS = [
#add dsts domains to whitelist
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to modify this comment to include the link to Domain Reference, something like this:

# Define dSTS domains whitelist based on its Supported Environments & National Clouds list here
# https://microsoft.sharepoint.com/teams/AzureSecurityCompliance/Security/SitePages/dSTS%20Fundamentals.aspx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments

@@ -186,6 +192,10 @@ def test_url_extra_path_elements(self):
"https://login.microsoftonline.com/your_tenant"):
context = AuthenticationContext(self.nonHardCodedAuthority + '/extra/path')

@httpretty.activate
def test_dsts_authority(self):
context = AuthenticationContext(self.dstsTestEndpoint)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the pattern described in the highest-voted answer here to add self.fail(...). The current approach in this PR is not very clear to convey your intention. It would cause the first impression in a reviewer's mind as "was this test case unfinished?".

PS: for the record, your current approach is close to the 2nd-highest voted answer in that Stackoverflow thread. But that answer's vote counts (52) are far behind, and with yet-another-high-voted (30) comment AGAINST such answer. So, the developer comminuty has voted, they don't like this approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added self.fail().

Remove unnecessary white space, add documentation to whitelist, use self.fail in unit test.
Copy link
Collaborator

@rayluo rayluo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation wise it looks good.

@navyasric do you have anything to add or comment for this new feature in general?

@rayluo rayluo merged commit 0735a1d into AzureAD:dev Aug 30, 2018
rayluo added a commit that referenced this pull request Aug 30, 2018
@rayluo rayluo mentioned this pull request Aug 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants