ENT-3798 Multiple_SSO_Accounts_Association_to_SAML_User - #26170
Conversation
moconnell1453
left a comment
There was a problem hiding this comment.
Looks good, though we may benefit from log statements in the short term to help us diagnose any situations where we might end up deviating from the expected flow.
eaeefe7 to
20b5c75
Compare
| user_details = {'email': details.get('email')} if details else None | ||
| current_user = get_user(user_details or {}) | ||
|
|
||
| if current_user: |
There was a problem hiding this comment.
Is there a possible scenario where the if current user check returns false, and if so, how should that be handled?
There was a problem hiding this comment.
Yes, that's possible in case when the user is coming for the very first time and doesn't have an account on edX. In that case, everything is working fine already.
|
|
||
| def is_multiple_sso_accounts_association_to_saml_user_enabled(): | ||
| """ | ||
| Checks to see if the django-waffle switch for enabling the multiple sso accounts association to saml user is active |
There was a problem hiding this comment.
The purpose of this switch isn't really clear to me -- are we adding a control to determine if it is possible for a single user to be associated with more than one third party identity (ie, UserSocialAuth record)? This is already the case -- lots of users have more than one USA record -- are we altering the default behavior?
There was a problem hiding this comment.
For the safe side, I have added this waffle switch. As, we need some time to test these changes on stage and meanwhile, changes will go on PROD. So, they have been kept behind a switch, which will be turned on once the changes have been tested on Stage.
There was a problem hiding this comment.
I guess I still don't see what this has to do with multiple SSO accounts. We're simply checking to see if the learner is already linked to an enterprise customer, and if the IdP is also linked to that customer.
There was a problem hiding this comment.
This is just a flag which will be controled from admin panel and will be switched on on PROD once we are done with the testing of this change on stage. It doesn't have to do anything with functionality.
There was a problem hiding this comment.
🤷 -- will it be removed after the change has been validated?
There was a problem hiding this comment.
Yes, this can be removed once the changes are validated. Until then we can plug in and out the code by just clicking on a flag in the admin panel which is the safest way to take these changes.
There was a problem hiding this comment.
@mattdrayer Zaman has added this flag at my request, due to my concern for affecting third party auth in prod while we are testing the changes in stage. We'll remove the flag when we go to prod.
| """ Verify that the user linked to enterprise customer of current identity provider""" | ||
| enterprise_idp = EnterpriseCustomerIdentityProvider.objects.get(provider_id=provider_id) | ||
|
|
||
| return EnterpriseCustomerUser.objects.filter(enterprise_customer=enterprise_idp.enterprise_customer, |
There was a problem hiding this comment.
What if no enterprise_idp is found?
There was a problem hiding this comment.
That is not possible as the user will be coming from an IDP and we redirect the user to IDP only if the provider id is found. Here is the reference code where we redirect the user.
https://github.com/edx/edx-platform/blob/aed3d8cbfcd81ab4320224743eeff0115f953d24/openedx/core/djangoapps/user_authn/views/login_form.py#L170
There was a problem hiding this comment.
it seems to me that we're putting a lot of faith in the workflow by assuming that this code only gets executed in that context. I think it would be worthwhile to handle for a null enterprise_idp condition and include logging, accordingly.
There was a problem hiding this comment.
We have also put this code in a try block and catching and logging the exception if something like this will happen. I have tested this locally and it will log the exception EnterpriseCustomerIdentityProvider matching query does not exist.: with all the other details like use email, provider id, and user id.
20b5c75 to
64a8fb9
Compare
64a8fb9 to
14666e3
Compare
|
@mattdrayer Thank you for the valuable feedback. I have incorporated it. Can you please review PR again? |
14666e3 to
45bcf2e
Compare
|
FYI @edx/arch-bom - as technically being technical owners of |
45bcf2e to
7a4d7dc
Compare
7a4d7dc to
a3f5169
Compare
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
No description provided.