Skip to content

ENT-3798 Multiple_SSO_Accounts_Association_to_SAML_User - #26170

Merged
zamanafzal merged 1 commit into
masterfrom
zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email
Feb 1, 2021
Merged

ENT-3798 Multiple_SSO_Accounts_Association_to_SAML_User#26170
zamanafzal merged 1 commit into
masterfrom
zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email

Conversation

@zamanafzal

Copy link
Copy Markdown
Member

No description provided.

@moconnell1453 moconnell1453 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@zamanafzal
zamanafzal force-pushed the zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email branch 2 times, most recently from eaeefe7 to 20b5c75 Compare January 26, 2021 20:48
user_details = {'email': details.get('email')} if details else None
current_user = get_user(user_details or {})

if current_user:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a possible scenario where the if current user check returns false, and if so, how should that be handled?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Comment thread common/djangoapps/third_party_auth/pipeline.py Outdated

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤷 -- will it be removed after the change has been validated?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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.

Comment thread common/djangoapps/third_party_auth/utils.py Outdated
""" 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if no enterprise_idp is found?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Comment thread common/djangoapps/third_party_auth/pipeline.py Outdated
Comment thread common/djangoapps/third_party_auth/pipeline.py Outdated
@zamanafzal
zamanafzal force-pushed the zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email branch from 20b5c75 to 64a8fb9 Compare January 28, 2021 15:25
@zamanafzal
zamanafzal requested a review from nasthagiri January 28, 2021 15:25
@zamanafzal
zamanafzal force-pushed the zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email branch from 64a8fb9 to 14666e3 Compare January 28, 2021 15:34
@zamanafzal

Copy link
Copy Markdown
Member Author

@mattdrayer Thank you for the valuable feedback. I have incorporated it. Can you please review PR again?

@zamanafzal
zamanafzal force-pushed the zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email branch from 14666e3 to 45bcf2e Compare January 28, 2021 16:04
@openedx openedx deleted a comment from edx-status-bot Jan 28, 2021
@nasthagiri

Copy link
Copy Markdown
Contributor

FYI @edx/arch-bom - as technically being technical owners of third_party_auth.

Comment thread openedx/core/djangoapps/user_api/config/waffle.py Outdated
@zamanafzal
zamanafzal force-pushed the zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email branch from 45bcf2e to 7a4d7dc Compare January 29, 2021 10:28
@zamanafzal
zamanafzal force-pushed the zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email branch from 7a4d7dc to a3f5169 Compare January 29, 2021 12:00
@openedx openedx deleted a comment from edx-status-bot Jan 29, 2021
@zamanafzal
zamanafzal merged commit b99a64c into master Feb 1, 2021
@zamanafzal
zamanafzal deleted the zafzal/ENT3798-attach-multiple-sso-saml-user-accounts-to-email branch February 1, 2021 06:44
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

Comment thread common/djangoapps/third_party_auth/config/waffle.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants