-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix: SAML provider config references to use current SAML configuration versions #36954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
robrap
merged 16 commits into
openedx:master
from
ktyagiapphelix2u:ktyagi/enahnce_saml_config_2
Aug 12, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
76e98a2
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 0c896e5
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 7542053
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u e967185
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 4eef8ea
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 18f5956
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 9289b65
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u cad5278
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 0b7cd8b
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 9b085b2
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u fb5dd42
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 1fafcbe
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u ed88236
Merge branch 'master' into ktyagi/enahnce_saml_config_2
ktyagiapphelix2u 731d0bb
Merge branch 'master' into ktyagi/enahnce_saml_config_2
ktyagiapphelix2u d003083
fix: Saml provider config references to use current SAML configuratio…
ktyagiapphelix2u 40b46ea
Merge branch 'openedx:master' into ktyagi/enahnce_saml_config_2
ktyagiapphelix2u File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Signal handlers for third_party_auth app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| """ | ||
| Signal handlers for third_party_auth app. | ||
| """ | ||
|
|
||
| from django.db.models.signals import post_save | ||
| from django.dispatch import receiver | ||
| from edx_django_utils.monitoring import set_custom_attribute | ||
|
|
||
| from common.djangoapps.third_party_auth.models import SAMLConfiguration, SAMLProviderConfig | ||
| from common.djangoapps.third_party_auth.toggles import ENABLE_SAML_CONFIG_SIGNAL_HANDLERS | ||
|
|
||
|
|
||
| @receiver(post_save, sender=SAMLConfiguration) | ||
| def update_saml_provider_configs_on_configuration_change(sender, instance, created, **kwargs): | ||
| """ | ||
| Signal handler to create a new SAMLProviderConfig when SAMLConfiguration is updated. | ||
|
|
||
| When a SAMLConfiguration is updated and a new version is created, this handler | ||
| generates a corresponding SAMLProviderConfig that references the latest | ||
| configuration version, ensuring all providers remain aligned with the most | ||
| current settings. | ||
| """ | ||
| # .. custom_attribute_name: saml_config_signal.enabled | ||
| # .. custom_attribute_description: Tracks whether the SAML config signal handler is enabled. | ||
| set_custom_attribute('saml_config_signal.enabled', ENABLE_SAML_CONFIG_SIGNAL_HANDLERS.is_enabled()) | ||
|
|
||
| # .. custom_attribute_name: saml_config_signal.new_config_id | ||
| # .. custom_attribute_description: Records the ID of the new SAML configuration instance. | ||
| set_custom_attribute('saml_config_signal.new_config_id', instance.id) | ||
|
|
||
| # .. custom_attribute_name: saml_config_signal.slug | ||
| # .. custom_attribute_description: Records the slug of the SAML configuration instance. | ||
| set_custom_attribute('saml_config_signal.slug', instance.slug) | ||
|
|
||
| if ENABLE_SAML_CONFIG_SIGNAL_HANDLERS.is_enabled(): | ||
|
robrap marked this conversation as resolved.
|
||
| try: | ||
| # Find all existing SAMLProviderConfig instances (current_set) that should be | ||
| # pointing to this slug but are pointing to an older version | ||
| existing_providers = SAMLProviderConfig.objects.current_set().filter( | ||
| site_id=instance.site_id, | ||
| saml_configuration__slug=instance.slug | ||
| ).exclude(saml_configuration_id=instance.id) | ||
|
|
||
| updated_count = 0 | ||
| for provider_config in existing_providers: | ||
| provider_config.saml_configuration = instance | ||
| provider_config.save() | ||
| updated_count += 1 | ||
|
|
||
| # .. custom_attribute_name: saml_config_signal.updated_count | ||
| # .. custom_attribute_description: The number of SAMLProviderConfig records updated to point to the new configuration. | ||
| set_custom_attribute('saml_config_signal.updated_count', updated_count) | ||
|
|
||
| except Exception as e: # pylint: disable=broad-except | ||
| # .. custom_attribute_name: saml_config_signal.error_message | ||
| # .. custom_attribute_description: Records any error message that occurs during SAML provider config updates. | ||
| set_custom_attribute('saml_config_signal.error_message', str(e)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # This file marks the directory as a Python package. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.