From 975f8f90eb3e92d243d0c32cf02d117e9bd93e21 Mon Sep 17 00:00:00 2001 From: Squirrel18 Date: Mon, 29 Jul 2024 12:38:48 -0500 Subject: [PATCH] feat: improve the way we handle the IES IDP id values. --- common/djangoapps/third_party_auth/pipeline.py | 8 +------- lms/envs/common.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/common/djangoapps/third_party_auth/pipeline.py b/common/djangoapps/third_party_auth/pipeline.py index 828959c428f7..1e7075a106a6 100644 --- a/common/djangoapps/third_party_auth/pipeline.py +++ b/common/djangoapps/third_party_auth/pipeline.py @@ -964,13 +964,7 @@ def user_details_force_sync(auth_entry, strategy, details, user=None, *args, **k setattr(model, field, provider_value) # Generate fullname only for IES IDP. - # We deliberately left these values hard-coded instead of using Django settings because - # it would force us to add custom settings to the edx platform code, - # which we try to avoid as we might lose track of that kind of setting. - ies_entity_ids = [ - 'https://iam-stage.pearson.com:443/auth/saml-idp-uid', - 'https://iam.pearson.com:443/auth/saml-idp-uid', - ] + ies_entity_ids = getattr(settings, 'SAML_IES_ENTITIES_IDS', []) first_name = details.get('first_name') last_name = details.get('last_name') diff --git a/lms/envs/common.py b/lms/envs/common.py index 2ba82866b64e..d961c05b6f1b 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -5312,3 +5312,17 @@ def _should_send_learning_badge_events(settings): "learning-badges-lifecycle", "enabled", ) + +# IES SAML integration. +# .. setting_name: SAML_IES_ENTITIES_IDS +# .. setting_default: [] +# .. setting_example_value: ['https://my-idp-integration-uri-id'] +# .. setting_description: This configuration allows us to define the IDs of the IES entities, to perform certain actions to the SAML IES request only. +# adding a new step to SOCIAL_AUTH_PIPELINE (edx-platform/common/djangoapps/third_party_auth/settings.py) +# is not a feasible option, since we can't override the SOCIAL_AUTH_PIPELINE from the Django or other plugin configuration, +# so we decided to handle it this way and add the necessary logic, directly in the edx-platform code +# edx-platform/common/djangoapps/third_party_auth/pipeline.py +# We will define the requried values using our Tutor plugin. +# Entity ID docs: +# https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/tpa/tpa_integrate_open/tpa_SAML_IdP.html#add-and-enable-a-saml-identity-provider +SAML_IES_ENTITIES_IDS = []