Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/openedx/edx-enterprise in…
Browse files Browse the repository at this point in the history
…to MueezKhan/Encryption-Fields-Added-To-MoodleConfig
  • Loading branch information
MueezKhan246 committed Nov 6, 2023
2 parents 9bf58d4 + 674febd commit a184835
Show file tree
Hide file tree
Showing 27 changed files with 650 additions and 261 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ Change Log
Unreleased
----------
[4.6.9]
[4.6.11]
-------
refactor: removing "null=true" constraint from encrypted fields
feat: added fields for holding encrypted data in database (ENT 5613)

[4.6.10]
--------
chore: Update requirements

[4.6.9]
-------
chore: returning SP metadata url from the sso orchestrator to the API caller

[4.6.8]
-------
feat: truncate API Response before writing to the APIResponseRecord
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ relevant reviewers and track review process.
Reporting Security Issues
-------------------------

Please do not report security issues in public. Please email security@edx.org.
Please do not report security issues in public. Please email security@openedx.org.

Getting Help
------------
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "4.6.9"
__version__ = "4.6.11"
2 changes: 1 addition & 1 deletion enterprise/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from django.core import exceptions as django_exceptions
from django.utils.translation import gettext_lazy as _

from enterprise import models, utils
from enterprise import models, utils # pylint: disable=cyclic-import
from enterprise.api.v1.fields import Base64EmailCSVField
from enterprise.api_client.lms import ThirdPartyAuthApiClient
from enterprise.constants import ENTERPRISE_ADMIN_ROLE, ENTERPRISE_PERMISSION_GROUPS, DefaultColors
Expand Down
14 changes: 8 additions & 6 deletions enterprise/api/v1/views/enterprise_customer_sso_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ def create(self, request, *args, **kwargs):
try:
with transaction.atomic():
new_record = EnterpriseCustomerSsoConfiguration.objects.create(**request_data)
new_record.submit_for_configuration()
sp_metadata_url = new_record.submit_for_configuration()
except (TypeError, SsoOrchestratorClientError) as e:
LOGGER.error(f'{CONFIG_CREATE_ERROR} {e}')
return Response({'error': f'{CONFIG_CREATE_ERROR} {e}'}, status=HTTP_400_BAD_REQUEST)

return Response({'data': new_record.pk}, status=HTTP_201_CREATED)
return Response({'record': new_record.pk, 'sp_metadata_url': sp_metadata_url}, status=HTTP_201_CREATED)

@permission_required(
'enterprise.can_access_admin_dashboard',
Expand Down Expand Up @@ -321,12 +321,14 @@ def update(self, request, *args, **kwargs):
try:
with transaction.atomic():
sso_configuration_record.update(**request_data)
sso_configuration_record.first().submit_for_configuration(updating_existing_record=True)
sp_metadata_url = sso_configuration_record.first().submit_for_configuration(
updating_existing_record=True
)
except (TypeError, FieldDoesNotExist, ValidationError, SsoOrchestratorClientError) as e:
LOGGER.error(f'{CONFIG_UPDATE_ERROR}{e}')
return Response({'error': f'{CONFIG_UPDATE_ERROR}{e}'}, status=HTTP_400_BAD_REQUEST)
LOGGER.error(f'{CONFIG_UPDATE_ERROR} {e}')
return Response({'error': f'{CONFIG_UPDATE_ERROR} {e}'}, status=HTTP_400_BAD_REQUEST)
serializer = self.serializer_class(sso_configuration_record.first())
return Response(serializer.data, status=HTTP_200_OK)
return Response({'record': serializer.data, 'sp_metadata_url': sp_metadata_url}, status=HTTP_200_OK)

@permission_required(
'enterprise.can_access_admin_dashboard',
Expand Down
2 changes: 1 addition & 1 deletion enterprise/api_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.apps import apps
from django.conf import settings

from enterprise.utils import NotConnectedToOpenEdX
from enterprise.utils import NotConnectedToOpenEdX # pylint: disable=cyclic-import

try:
from openedx.core.djangoapps.oauth_dispatch import jwt as JwtBuilder
Expand Down
5 changes: 3 additions & 2 deletions enterprise/api_client/sso_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _post(self, url, data=None):
f"Failed to make SSO Orchestrator API request: {response.status_code}",
response=response,
)
return response.status_code
return response.json()

def configure_sso_orchestration_record(
self,
Expand Down Expand Up @@ -131,4 +131,5 @@ def configure_sso_orchestration_record(
if is_sap or sap_config_data:
request_data['sapsfConfiguration'] = sap_config_data

return self._post(self._get_orchestrator_configure_url(), data=request_data)
response = self._post(self._get_orchestrator_configure_url(), data=request_data)
return response.get('samlServiceProviderInformation', {}).get('spMetadataUrl', {})
3 changes: 2 additions & 1 deletion enterprise/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4095,7 +4095,7 @@ def submit_for_configuration(self, updating_existing_record=False):
elif field_value := getattr(self, field):
config_data[utils.camelCase(field)] = field_value

EnterpriseSSOOrchestratorApiClient().configure_sso_orchestration_record(
sp_metadata_url = EnterpriseSSOOrchestratorApiClient().configure_sso_orchestration_record(
config_data=config_data,
config_pk=self.pk,
enterprise_data={
Expand All @@ -4109,3 +4109,4 @@ def submit_for_configuration(self, updating_existing_record=False):
)
self.submitted_at = localized_utcnow()
self.save()
return sp_metadata_url
7 changes: 5 additions & 2 deletions integrated_channels/canvas/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@

from django.apps import apps

from integrated_channels.canvas.utils import CanvasUtil
from integrated_channels.canvas.utils import CanvasUtil # pylint: disable=cyclic-import
from integrated_channels.exceptions import ClientError
from integrated_channels.integrated_channel.client import IntegratedChannelApiClient, IntegratedChannelHealthStatus
from integrated_channels.utils import generate_formatted_log, refresh_session_if_expired
from integrated_channels.utils import ( # pylint: disable=cyclic-import
generate_formatted_log,
refresh_session_if_expired,
)

LOGGER = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions integrated_channels/moodle/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def get_course_final_grade_module(self, course_id):
"""
response = self._get_course_contents(course_id)
course_module_id = None
module_name = None
if isinstance(response.json(), list):
for course in response.json():
if course.get('name') == 'General':
Expand Down
Loading

0 comments on commit a184835

Please sign in to comment.