Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Add endpoint to get SAML providers for a user. #1047

Merged
merged 1 commit into from
Apr 25, 2018

Conversation

jcdyer
Copy link

@jcdyer jcdyer commented Apr 10, 2018

This PR contains a new view that returns a list of authentication providers for a user. This includes SAML, OAuth, and any other configured 3rd party auth providers.

JIRA tickets: Implements OC-4285, MCKIN-7245

Dependencies: None

Screenshots: None

Sandbox URL: TBD - sandbox is being provisioned.

Merge deadline: None

Testing instructions:

  1. As an unauthenticated user, access /api/third_party_auth/v0/users//providers/ for a user with at least one third-party-auth connection. Verify that the providers are included in the response.
  2. Replace with the same user's email address, and verify that the same response is returned.
  3. Replace with the username or email address of a user that doesn't have any third-party-auth connections. Verify the the returned list of providers is empty.
  4. Replace with a nonexistent username. Verify that a 200 response is returned with an empty list of providers.
  5. Run third-party-auth unittests: paver test_system -s lms -t common/djangoapps/third_party_auth/api/tests/
  6. Hit the api several times (11) in one minute. Verify that a 429 (throttled) response is eventually returned. If you're feeling ambitious, send 51 requests over the course of 10 minutes, and verify that the daily throttle limit gets hit as well.

Author notes and concerns:

  • Throttling seems to be happening, but not according to the configuration I provided. Tested via curl on the command line. Throttling works now.
  • Tests are failing due to NPM installation issues. I spent a few hours trying to resolve the problem this morning, with no luck. I'll ask around if anyone else has faced this, and if not I'll try to deal with it later. In the meantime, please review with manual testing, and also run unit tests manually using paver test_system -s lms -t common/djangoapps/api/tests

Reviewers:

@jcdyer jcdyer force-pushed the cliff/sso-discovery-endpoint branch 3 times, most recently from a6938b9 to 434dad4 Compare April 11, 2018 15:17
@jcdyer jcdyer closed this Apr 11, 2018
@jcdyer jcdyer reopened this Apr 11, 2018
@jcdyer
Copy link
Author

jcdyer commented Apr 11, 2018

Accidentally closed PR.

@jcdyer jcdyer force-pushed the cliff/sso-discovery-endpoint branch 2 times, most recently from ed4b177 to 09b26f7 Compare April 12, 2018 12:05
@jcdyer jcdyer changed the base branch from master to integration April 12, 2018 12:25
@jcdyer jcdyer force-pushed the cliff/sso-discovery-endpoint branch from 255e9ba to 291ba07 Compare April 12, 2018 12:30
@jcdyer
Copy link
Author

jcdyer commented Apr 12, 2018

Had to fix JSLint issues. How did those get in there?

@jcdyer jcdyer force-pushed the cliff/sso-discovery-endpoint branch from f17ee35 to c7bf542 Compare April 12, 2018 18:26
Copy link

@xitij2000 xitij2000 left a comment

Choose a reason for hiding this comment

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

I'm working on testing this manually but noticed a few issues that you could address. Further feedback once I've tested the code a bit.

circle.yml Outdated
@@ -11,7 +11,11 @@ dependencies:
pre:
- bash ./scripts/install-system-req.sh
override:

Choose a reason for hiding this comment

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

I checked, and each command in override runs in its own shell instance, so nvm use will not work since it makes changes to the active shell and those aren't preserved for the next command.

"""
Test that the provider endpoint returns the appropriate data
"""
def test_results(self):

Choose a reason for hiding this comment

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

Could you split up this into multiple tests for linked and unlinked users? Also, you can use the ddt instead of a loop.


* provider_id: The unique identifier of this provider (string)
* name: The name of this provider (string)
* remote_id: The ID of the user according to the provider. This ID

Choose a reason for hiding this comment

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

This documentation does not seem to be up to date with the code.

@jcdyer
Copy link
Author

jcdyer commented Apr 19, 2018

Addressed feedback provided so far.

@jcdyer
Copy link
Author

jcdyer commented Apr 19, 2018

Currently waiting on circle-ci and vagrant so I can confirm the fix does what it should.

@xitij2000
Copy link

@jcdyer Thanks! I tested it manually and it seems to be working as expected, and throttling is working as well. I also ran the new tests (post ddt refactor) and they are passing.
I just don't know about the JavaScript changes, are they still necessary? I did not see these issues when testing locally with the JavaScript changes removed.

@jcdyer jcdyer force-pushed the cliff/sso-discovery-endpoint branch from 3ad91f1 to fc08bfa Compare April 20, 2018 20:42
@jcdyer
Copy link
Author

jcdyer commented Apr 20, 2018

Trying a test run without the jslint fixes.

@xitij2000
Copy link

@jcdyer Thanks! I think the main code looks good to merge now, but some unrelated tests seem to be failing.

@jcdyer
Copy link
Author

jcdyer commented Apr 20, 2018

Yep. I tried rebasing. If that doesn't solve it, I'll bump the query numbers, but I'd rather understand why the query count increased.

@xitij2000
Copy link

@jcdyer It seems those test and quality failures are to be expected and being worked on separately, so as long as those are the only failures this is good to go.

@xitij2000
Copy link

I did another test with all the latest changes and the relevant tests are passing, so I think this is close to done. Please just update the code documentation and update the ticket description, and we can merge this.

@jcdyer jcdyer force-pushed the cliff/sso-discovery-endpoint branch from ea4337b to db14792 Compare April 21, 2018 15:29
@jcdyer
Copy link
Author

jcdyer commented Apr 21, 2018

Docs were updated. Did I miss another place where they were out of date? (I just squashed commits. That may have been unhelpful. Sorry about that.) The ticket description looks accurate on OC- and I don't have access to MCKIN-, so I don't know if that should be updated or not. Perhaps @bradenmacdonald can assist. Once you update your review to Approval, we should be able to merge.

@xitij2000
Copy link

@jcdyer Sorry I meant PR description. I currently contains the text: "Description goes here. e.g. This PR contains the LibraryContent XBlock, which allows to display library content in a course."

As for docs I mean the get method currently includes:

HTTP Endpoint for all CRUD operations for a user course enrollment. Allows creation, reading, and
updates of the current enrollment for a particular course.

Copy link

@xitij2000 xitij2000 left a comment

Choose a reason for hiding this comment

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

👍

  • I tested this:
    • I ran the automated tests
    • I manually tested the API response to ensure it matches what we need
    • I manually tested that the throttling works (see note below)
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation (see note below)

Please update the get method docstring, I think that is the only thing that's missing now.

While throttling is working for me, it is not working the way I expected it, or as described in the ticket. For me, only 5 requests per second are allowed, and the 50/day limit isn't working. I'm still looking into this since I think it's an issue on my side.

throttle_classes = [ProviderSustainedThrottle, ProviderBurstThrottle]

def get(self, request, identifier):
"""Create, read, or update enrollment information for a user.

Choose a reason for hiding this comment

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

Please update these docs as well.

@jcdyer jcdyer force-pushed the cliff/sso-discovery-endpoint branch from db14792 to 6d46c61 Compare April 23, 2018 13:57
@jcdyer
Copy link
Author

jcdyer commented Apr 23, 2018

Updated docs and PR description. Commits squashed & waiting for CI.

@xitij2000
Copy link

@jcdyer Thanks! The CI tests will probably fail again though for the same reasons as before.

@jcdyer jcdyer force-pushed the cliff/sso-discovery-endpoint branch from 6d46c61 to 880d796 Compare April 23, 2018 17:08
@jcdyer
Copy link
Author

jcdyer commented Apr 25, 2018

Confirmed. The only failures are the quality issues now. (Query counts are back to normal after the latest rebase.

@jcdyer jcdyer merged commit 3a00060 into integration Apr 25, 2018
@xitij2000 xitij2000 deleted the cliff/sso-discovery-endpoint branch April 25, 2018 22:14
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.

2 participants